aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2004-06-19 15:43:52 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2004-06-19 15:43:52 +0000
commitfdedc45ff6ac8d3d358f1544d3f6f2b1c66c4365 (patch)
treeba186b07f662406c6f0de492cc1dd60a46f0597d /contrib
parent90184f6712a4c0b0b8a58ab42fbec3a7eff0fe15 (diff)
downloadsrc-fdedc45ff6ac8d3d358f1544d3f6f2b1c66c4365.tar.gz
src-fdedc45ff6ac8d3d358f1544d3f6f2b1c66c4365.zip
This file was not part of the GDB 5.2.1 import and should have been
deleted from the vendor branch.
Notes
Notes: svn path=/vendor/gdb/dist/; revision=130732
Diffstat (limited to 'contrib')
-rw-r--r--contrib/gdb/ChangeLog7746
-rw-r--r--contrib/gdb/MAINTAINERS114
-rw-r--r--contrib/gdb/bfd/COPYING339
-rw-r--r--contrib/gdb/bfd/Makefile.in1090
-rw-r--r--contrib/gdb/bfd/PORTING83
-rw-r--r--contrib/gdb/bfd/TODO25
-rw-r--r--contrib/gdb/bfd/VERSION1
-rw-r--r--contrib/gdb/bfd/acconfig.h19
-rw-r--r--contrib/gdb/bfd/aclocal.m443
-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/aout-target.h607
-rw-r--r--contrib/gdb/bfd/aout0.c32
-rw-r--r--contrib/gdb/bfd/aout32.c23
-rw-r--r--contrib/gdb/bfd/aout64.c31
-rw-r--r--contrib/gdb/bfd/aoutf1.h788
-rw-r--r--contrib/gdb/bfd/aoutx.h5525
-rw-r--r--contrib/gdb/bfd/archive.c2094
-rw-r--r--contrib/gdb/bfd/archures.c720
-rw-r--r--contrib/gdb/bfd/bfd-in.h668
-rw-r--r--contrib/gdb/bfd/bfd-in2.h2479
-rw-r--r--contrib/gdb/bfd/bfd.c1144
-rw-r--r--contrib/gdb/bfd/binary.c348
-rw-r--r--contrib/gdb/bfd/bout.c1471
-rw-r--r--contrib/gdb/bfd/cache.c347
-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-i386.c493
-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/coffcode.h3612
-rw-r--r--contrib/gdb/bfd/coffgen.c2121
-rw-r--r--contrib/gdb/bfd/cofflink.c2327
-rw-r--r--contrib/gdb/bfd/coffswap.h807
-rw-r--r--contrib/gdb/bfd/config.bfd491
-rw-r--r--contrib/gdb/bfd/config.in67
-rw-r--r--contrib/gdb/bfd/configure2439
-rw-r--r--contrib/gdb/bfd/configure.bat18
-rw-r--r--contrib/gdb/bfd/configure.host128
-rw-r--r--contrib/gdb/bfd/configure.in577
-rw-r--r--contrib/gdb/bfd/corefile.c106
-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-i386.c38
-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/dep-in.sed24
-rw-r--r--contrib/gdb/bfd/doc/ChangeLog268
-rw-r--r--contrib/gdb/bfd/doc/Makefile.in311
-rw-r--r--contrib/gdb/bfd/doc/bfd.texinfo348
-rw-r--r--contrib/gdb/bfd/doc/bfdsumm.texi148
-rw-r--r--contrib/gdb/bfd/doc/chew.c1551
-rw-r--r--contrib/gdb/bfd/doc/doc.str158
-rw-r--r--contrib/gdb/bfd/doc/proto.str135
-rw-r--r--contrib/gdb/bfd/ecoff.c4740
-rw-r--r--contrib/gdb/bfd/ecofflink.c2452
-rw-r--r--contrib/gdb/bfd/ecoffswap.h853
-rw-r--r--contrib/gdb/bfd/elf-bfd.h858
-rw-r--r--contrib/gdb/bfd/elf.c3318
-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/format.c319
-rw-r--r--contrib/gdb/bfd/freebsd.h109
-rw-r--r--contrib/gdb/bfd/gen-aout.c101
-rw-r--r--contrib/gdb/bfd/genlink.h106
-rw-r--r--contrib/gdb/bfd/hash.c734
-rw-r--r--contrib/gdb/bfd/host-aout.c83
-rw-r--r--contrib/gdb/bfd/hosts/alphalinux.h6
-rw-r--r--contrib/gdb/bfd/hosts/decstation.h17
-rw-r--r--contrib/gdb/bfd/hosts/delta68.h18
-rw-r--r--contrib/gdb/bfd/hosts/dpx2.h8
-rw-r--r--contrib/gdb/bfd/hosts/hp300bsd.h13
-rw-r--r--contrib/gdb/bfd/hosts/i386bsd.h25
-rw-r--r--contrib/gdb/bfd/hosts/i386linux.h8
-rw-r--r--contrib/gdb/bfd/hosts/i386mach3.h25
-rw-r--r--contrib/gdb/bfd/hosts/i386sco.h19
-rw-r--r--contrib/gdb/bfd/hosts/i860mach3.h27
-rw-r--r--contrib/gdb/bfd/hosts/m68kaux.h16
-rw-r--r--contrib/gdb/bfd/hosts/m68klinux.h6
-rw-r--r--contrib/gdb/bfd/hosts/m88kmach3.h11
-rw-r--r--contrib/gdb/bfd/hosts/mipsbsd.h12
-rw-r--r--contrib/gdb/bfd/hosts/mipsmach3.h10
-rw-r--r--contrib/gdb/bfd/hosts/news-mips.h12
-rw-r--r--contrib/gdb/bfd/hosts/news.h9
-rw-r--r--contrib/gdb/bfd/hosts/pc532mach.h24
-rw-r--r--contrib/gdb/bfd/hosts/riscos.h10
-rw-r--r--contrib/gdb/bfd/hosts/symmetry.h20
-rw-r--r--contrib/gdb/bfd/hosts/tahoe.h12
-rw-r--r--contrib/gdb/bfd/hosts/vaxbsd.h19
-rw-r--r--contrib/gdb/bfd/hosts/vaxult.h8
-rw-r--r--contrib/gdb/bfd/hosts/vaxult2.h8
-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/i386aout.c68
-rw-r--r--contrib/gdb/bfd/i386bsd.c46
-rw-r--r--contrib/gdb/bfd/i386dynix.c80
-rw-r--r--contrib/gdb/bfd/i386freebsd.c33
-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/ihex.c1005
-rw-r--r--contrib/gdb/bfd/init.c50
-rw-r--r--contrib/gdb/bfd/irix-core.c263
-rw-r--r--contrib/gdb/bfd/libaout.h608
-rw-r--r--contrib/gdb/bfd/libbfd-in.h503
-rw-r--r--contrib/gdb/bfd/libbfd.c1197
-rw-r--r--contrib/gdb/bfd/libbfd.h735
-rw-r--r--contrib/gdb/bfd/libcoff-in.h482
-rw-r--r--contrib/gdb/bfd/libcoff.h823
-rw-r--r--contrib/gdb/bfd/libecoff.h352
-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/linker.c2781
-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/opncls.c604
-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/reloc.c2391
-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/section.c976
-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/srec.c1324
-rw-r--r--contrib/gdb/bfd/stab-syms.c57
-rw-r--r--contrib/gdb/bfd/sunos.c2767
-rw-r--r--contrib/gdb/bfd/syms.c1084
-rw-r--r--contrib/gdb/bfd/sysdep.h114
-rw-r--r--contrib/gdb/bfd/targets.c886
-rw-r--r--contrib/gdb/bfd/tekhex.c1031
-rw-r--r--contrib/gdb/bfd/trad-core.c316
-rw-r--r--contrib/gdb/bfd/versados.c906
-rw-r--r--contrib/gdb/bfd/xcofflink.c5798
-rwxr-xr-xcontrib/gdb/install.sh236
-rwxr-xr-xcontrib/gdb/move-if-change32
239 files changed, 0 insertions, 156804 deletions
diff --git a/contrib/gdb/ChangeLog b/contrib/gdb/ChangeLog
deleted file mode 100644
index 83ec2be74806..000000000000
--- a/contrib/gdb/ChangeLog
+++ /dev/null
@@ -1,7746 +0,0 @@
-2002-04-07 Andrew Cagney <ac131313@redhat.com>
-
- * Makefile.in (do-tar-bz2): Delete rule. Replace with ...
- (do-tar, do-bz2): New rules.
- (taz): Update. Replace do-tar-bz2 with do-tar and do-bz2.
- (gdb-tar): New rule.
- (gdb-taz): Rewrite. Use gdb-tar and do-bz2.
- (insight_dejagnu.tar): New rule.
- (insight.tar): New rule.
- (gdb+dejagnu.tar): New rule.
- (gdb.tar): New rule.
-
-2002-02-28 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (libstdcxx_flags): Don't add libstdc++-v3 flags for
- libjava.
- (CXX_FOR_TARGET): Add -shared-libgcc for libstdc++-v3 and libjava.
-
-2002-02-24 Andrew Cagney <ac131313@redhat.com>
-
- * texinfo/texinfo.tex: Update to version 2002-02-14.08.
-
-2002-02-23 Daniel Jacobowitz <drow@mvista.com>
-
- * config.guess: Import from master sources, rev 1.232.
- * config.sub: Import from master sources, rev 1.246.
-
-2002-02-23 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (MAKEINFO): Don't assume makeinfo will be built just
- because its Makefile is there; test for the executable instead.
-
-2002-02-09 Alexandre Oliva <aoliva@redhat.com>
-
- Contribute sh64-elf.
- 2000-12-01 Alexandre Oliva <aoliva@redhat.com>
- * configure.in: Added sh64-*-*.
-
-2002-02-04 Jeff Johnston <jjohnstn@redhat.com>
-
- * COPYING.NEWLIB: Remove advertising clause from
- Berkeley and Red Hat licenses.
-
-2002-02-01 Mo DeJong <supermo@bayarea.net>
-
- * Makefile.in: Add all-tix to deps for all-snavigator
- so that tix is built when building snavigator.
-
-2002-02-01 Ben Elliston <bje@redhat.com>
-
- * config.guess: Import from master sources, rev 1.229.
- * config.sub: Import from master sources, rev 1.240.
-
-2002-01-27 Daniel Jacobowitz <drow@mvista.com>
-
- From Steve Ellcey <sje@cup.hp.com>:
- * libtool.m4 (HPUX_IA64_MODE): Set to 32 or 64 based on ABI.
- (lt_cv_deplibs_check_method, lt_cv_file_magic_cmd,
- lt_cv_file_magic_test_file): Set to appropriate values for HP-UX
- IA64.
- * ltcf-c.sh (archive_cmds, hardcode_*): Ditto.
- * ltconfig (shlibpath_*, dynamic_linker, library_names_spec,
- soname_spec, sys_lib_search_path_spec): Ditto.
-
-2002-01-26 Jason Thorpe <thorpej@wasabisystems.com>
-
- * configure.in (*-*-netbsd*): New. Skip target-newlib,
- target-libiberty, and target-libgloss. Skip Java-related
- libraries if not supported for NetBSD on target CPU.
-
-2002-01-23 Nick Clifton <nickc@cambridge.redhat.com>
-
- * configure.in: Import StrongARM and XScale target_configdirs from
- FSF GCC version.
-
-2002-01-16 H.J. Lu (hjl@gnu.org)
-
- * config.guess: Import from master sources, rev 1.225.
- * config.sub: Import from master sources, rev 1.238.
-
- * MAINTAINERS: Updated notes on config.guess and config.sub.
-
-2002-01-11 Steve Ellcey <sje@cup.hp.com>
-
- * configure.in (ia64*-*-hpux*): New target for IA64 HP-UX,
- ld and gdb are not supported.
-
-2002-01-07 Jeff Johnston <jjohnstn@redhat.com>
-
- * Change reference to Cygnus Solutions to be Red Hat.
-
-2002-01-07 Jeff Johnston <jjohnstn@redhat.com>
-
- * COPYING.NEWLIB: Update generic copyright date.
-
-2002-01-07 Mark Salter <msalter@redhat.com>
-
- * configure.in: Remove target-bsp and target-cygmon from arm builds.
- Allow target-libgloss to be built for arm, strongarm, and xscale.
-
-2002-01-03 Ben Elliston <bje@redhat.com>
-
- * MAINTAINERS: Update URL for config.* scripts.
-
-2001-12-18 Alan Modra <amodra@bigpond.net.au>
-
- * config.sub: Import latest version.
- * config.guess: Likewise.
-
-2001-12-13 Thomas Fitzsimmons <fitzsim@redhat.com>
-
- * configure.in (FLAGS_FOR_TARGET): Remove -nostdinc and -isystem
- options for i[3456]86-pc-linux* native builds.
-
-2001-12-05 Laurent Guerby <guerby@acm.org>
-
- * MAINTAINERS: gcc adopts symlink-tree, refer more to
- libiberty.
-
- Import this patch from gcc:
-
- 2000-12-09 Laurynas Biveinis <lauras@softhome.net>
-
- * symlink-tree: handle DOS-style absolute paths.
-
-2001-11-28 DJ Delorie <dj@redhat.com>
- Zack Weinberg <zack@codesourcery.com>
-
- When build != host, create libiberty for the build machine.
-
- * Makefile.in (TARGET_CONFIGARGS, BUILD_CONFIGARGS): Replace
- CONFIG_ARGUMENTS.
- (ALL_BUILD_MODULES_LIST, BUILD_CONFIGDIRS, BUILD_SUBDIR):
- New variables.
- (ALL_BUILD_MODULES, CONFIGURE_BUILD_MODULES): New variables
- and rules.
- (all.normal): Depend on ALL_BUILD_MODULES.
- (CONFIGURE_TARGET_MODULES rule): Use TARGET_CONFIGARGS.
- (all-build-libiberty): Depend on configure-build-libiberty.
-
- * configure: Calculate and substitute proper value for
- ALL_BUILD_MODULES.
- * configure.in: Create the build subdirectory.
- Calculate and substitute TARGET_CONFIGARGS (formerly
- CONFIG_ARGUMENTS); also BUILD_SUBDIR and BUILD_CONFIGARGS (new).
-
-2001-11-26 Geoffrey Keating <geoffk@redhat.com>
-
- * config.sub: Update to version 1.232 on subversion.
-
-2001-11-20 Nick Clifton <nickc@cambridge.redhat.com>
-
- * Makefile.in (do-proto-toplev): Use msgfmt to generate .gmo
- files from .po files for a distribution.
-
-2001-11-19 Hans-Peter Nilsson <hp@bitrange.com>
-
- * COPYING.NEWLIB: Mention preserved notice in specific parts.
-
-2001-11-13 Jeff Holcomb <jeffh@redhat.com>
-
- Merged from net gcc:
- 2001-07-30 Jeff Sturm <jsturm@one-pont.com>
- * ltcf-c.sh: Use $objext, not $ac_objext.
- 2001-07-27 Mark Kettenis <kettenis@gnu.org>
- * ltcf-cxx.sh: Add support for GNU.
- 2001-07-22 Timothy Wall <twall@redhat.com>
- * ltcf-c.sh: Don't disable shared libraries for AIX5/IA64. Preserve
- default settings if using GNU tools with that configuration.
- * ltcf-cxx.sh: Ditto.
- * ltcf-gcj.sh: Ditto.
- 2001-07-21 Michael Chastain <chastain@redhat.com>
- * ltconfig: Set max_cmd_len to a maximum of 512Kb, as it seems some
- HPUX 11.0 systems have trouble with 1MB. Mark as gcc-local.
- * ltmain.sh: Mark as gcc-local.
-
-2001-11-13 Jeff Holcomb <jeffh@redhat.com>
-
- * Makefile.in (all-bison): Revert 2001-10-24.
- Don't depend on texinfo.
-
-2001-11-12 Hans-Peter Nilsson <hp@bitrange.com>
-
- * COPYING.NEWLIB: Add BSD-style license/copyright blurb for my work.
-
-2001-11-08 Phil Edwards <pedwards@disaster.jaj.com>
-
- * configure.in (--enable-languages): Be more permissive about
- syntax. Check for empty lists better. Warn about $LANGUAGES.
-
-2001-11-06 Hans-Peter Nilsson <hp@bitrange.com>
-
- * Makefile.in (MAKEINFO): Use "missing" for makeinfo older than 4.0.
-
-2001-10-24 Jeff Holcomb <jeffh@redhat.com>
-
- Makefile.in (all-bison): Don't depend on texinfo.
-
-2001-10-03 Alan Modra <amodra@bigpond.net.au>
-
- * gettext.m4: Test po/POTFILES.in exists before trying to read.
-
-2001-09-29 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (configure-target-gperf): Depend on $(ALL_GCC_CXX).
-
-2001-09-28 Hans-Peter Nilsson <hp@axis.com>
-
- * config.sub, config.guess: Import latest from subversions.
-
-2001-09-21 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (AS_FOR_TARGET, LD_FOR_TARGET,
- DLLTOOL_FOR_TARGET, WINDRES_FOR_TARGET, AR_FOR_TARGET,
- RANLIB_FOR_TARGET, NM_FOR_TARGET): Don't use double quotes to
- avoid quotes nesting problems.
- (NATIVE_CHECK_MODULES): Ditto, just for consistency.
- (DO_X): Export only variables that are set.
-
-2001-09-19 Ben Elliston <bje@redhat.com>
-
- * configure.in (sparc-sun-solaris2*): Don't use /usr/bin/which on
- Solaris when testing for the /usr/ucb/cc compiler; it has incorrect
- semantics. Use the shell built-in "type" command instead.
-
-2001-09-15 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
-
- * config.sub: Reverted the earlier change, this version is not the
- master file.
-
-2001-09-14 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
-
- * config.sub: Change machine triplets from mipsel*-* to mips*el-*.
- Add support for mips64.
-
-2001-09-03 Jeff Holcomb <jeffh@redhat.com>
-
- * configure.in: Enable libstdc++-v3 for h8300 targets.
-
-2001-08-30 Eric Christopher <echristo@redhat.com>
- Jason Eckhardt <jle@redhat.com>
-
- * config.sub: Add support for mipsisa32.
-
-2001-08-30 Eric Christopher <echristo@redhat.com>
-
- * config.sub, config.guess: Import latest from subversions.
-
-2001-08-20 Alan Modra <amodra@bigpond.net.au>
-
- * config.sub, config.guess: Import latest from subversions.
-
-2001-07-26 DJ Delorie <dj@redhat.com>
-
- * MAINTAINERS: Clarify libiberty merge rules and procedures.
-
-2001-06-19 Alan Modra <amodra@bigpond.net.au>
-
- * Makefile.in: Revert 2001-06-17.
- (VER): If AM_INIT_AUTOMAKE uses BFD_VERSION, get version from bfd/.
-
-2001-06-17 H.J. Lu <hjl@gnu.org>
-
- * Makefile.in (gas.tar.bz2): Pass TOOL=bfd PACKAGE=gas to make.
- (gas+binutils.tar.bz2): Likewise.
- (binutils.tar.bz2): Pass TOOL=bfd PACKAGE=binutils to make.
-
-Fri Jun 8 11:14:02 2001 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (VER): When present, extract the version number from
- the file version.in.
-
-2001-06-08 Alexandre Oliva <aoliva@redhat.com>, Jeff Sturm <jsturm@one-point.com>
-
- * Makefile.in (AS_FOR_TARGET, LD_FOR_TARGET, NM_FOR_TARGET): If
- gcc/xgcc is built, use -print-prog-name to find out the program
- name to use.
-
-2001-06-04 Mark Mitchell <mark@codesourcery.com>
-
- * ltcf-c.sh (archive_cmds, archive_expsym_cmds) [solaris,
- with_gcc]: Use `gcc -shared' to build a shared library.
-
-2001-06-04 John David Anglin <dave@hiauly1.hia.nrc.ca>
-
- * ltcf-c.sh (archive_cmd) [hpux, with_gcc]: Use gcc to link shared
- archives.
-
-2001-05-28 Simon Patarin <simon.patarin@inria.fr>
-
- * ltcf-cxx.sh (osf3/osf4/osf5): Support creation of C++ shared
- libraries when using g++ with native linker.
-
-2001-05-28 Alexandre Oliva <aoliva@redhat.com>
-
- * ltconfig, ltmain.sh: Upgrade to libtool 1.4a 1.641.2.256.
-
-2001-05-24 Tom Rix <trix@redhat.com>
-
- * configure.in : enable ld for aix
-
-2001-05-22 Alexandre Oliva <aoliva@redhat.com>
-
- * ltcf-cxx.sh (allow_undefined_flag, no_undefined_flag)
- [aix4*|aix5*]: Prepend blank.
-
-2001-05-20 Alexandre Oliva <aoliva@redhat.com>
-
- * ltconfig, ltmain.sh, libtool.m4, ltcf-c.sh, ltcf-cxx.sh,
- ltcf-gcj.sh: Upgraded to libtool 1.4a 1.641.2.254. Rebuilt a number
- of subdir/configure scripts to use the new libtool.m4.
-
-2001-05-14 H.J. Lu <hjl@gnu.org>
-
- * config.if (libc_interface): Set to -libc6.2- for cross
- compiling to Linux/glibc 2.2.
-
-2001-05-03 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (noconfigdirs) [*-cygwin*, *-mingw*, *-beos]: Disable
- libgcj.
-
-2001-04-26 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (noconfigdirs): Don't reset it from scratch in the
- target case; only append to it.
-
-2001-04-26 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (noconfigdirs) [hppa*-*-*, mips*-*-irix6*,
- sparc-*-solaris2.8]: Disable ${libgcj}.
-
-2001-04-25 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (libgcj_saved): Copy from $libgcj.
- (libgcj): Zero out if --enable-libgcj; add to noconfigdirs is
- --disable-libgcj.
-
-2001-04-20 Alexandre Oliva <aoliva@redhat.com>
-
- * ltconfig, ltmain.sh, ltcf-cxx.sh: Upgraded to libtool 1.4a
- 1.641.2.228.
-
-2001-04-12 Alexandre Oliva <aoliva@redhat.com>
-
- * ltconfig, ltmain.sh, libtool.m4, ltcf-c.sh, ltcf-cxx.sh,
- ltcf-gcj.sh: Upgraded to libtool 1.4a 1.641.2.226.
-
-2001-04-01 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (CXX_FOR_TARGET_FOR_RECURSIVE_MAKE, RECURSE_FLAGS):
- New macros.
- (bootstrap, cross): Use RECURSE_FLAGS.
- * configure.in: Subst CXX_FOR_TARGET_FOR_RECURSIVE_MAKE.
-
-2001-03-27 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (CXX_FOR_TARGET): Use xgcc for libstdc++-v3.
-
-2001-03-23 Nick Clifton <nickc@redhat.com>
-
- * README-maintainer-mode: Add note about inability to use "make
- distclean" in maintainer mode.
-
-2001-03-22 Alexandre Oliva <aoliva@redhat.com>
-
- Re-installed:
- 2001-01-02 Laurynas Biveinis <lauras@softhome.net>
- * ltcf-c.sh: Clear ac_cv_prog_cc_pic for DJGPP. Do not add
- '-DPIC' to ac_cv_prog_cc_pic for DJGPP.
- * ltcf-cxx.sh: Likewise.
- * ltcf-gcj.sh: Likewise.
-
-2001-03-22 Philip Blundell <philb@gnu.org>
-
- * config.sub, config.guess: Import latest from subversions.
-
-2001-03-22 Alexandre Oliva <aoliva@redhat.com>
-
- * ltconfig, ltmain.sh, libtool.m4, ltcf-c.sh, ltcf-cxx.sh,
- ltcf-gcj.sh: Upgraded to libtool 1.4a 1.641.2.198.
-
-2001-03-20 Michael Chastain <chastain@redhat.com>
-
- * Makefile.in: all-m4 depends on all-texinfo.
-
-2001-03-08 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (ALL_GCC, ALL_GCC_C, ALL_GCC_CXX): Set before use.
-
-2001-02-22 Jeff Johnston <jjohnstn@redhat.com>
-
- * COPYING.NEWLIB: Remove DJ Delorie's address because it is no
- longer valid.
-
-2001-02-16 Nick Clifton <nickc@redhat.com>
-
- * configure.in (noconfigdirs): Allow configuration of texinfo
- for Cygwin hosts.
-
-2001-02-09 Martin Schwidefsky <schwidefsky@de.ibm.com>
-
- * config.guess: Add linux target for S/390.
- * config.sub: Likewise.
- * configure.in: Likewise.
-
-2001-02-06 Ben Elliston <bje@redhat.com>
-
- * configure: Output host type to stdout, not stderr.
-
-2001-02-04 Michael Sokolov <msokolov@ivan.Harhan.ORG>
-
- * config.guess: Import from subversions.gnu.org (revision 1.181).
- * config.sub: Import from subversions.gnu.org (revision 1.199).
-
-2001-01-30 Alan Modra <alan@linuxcare.com.au>
-
- * config.guess: Handle hppa64-linux systems.
-
-2001-01-27 Michael Sokolov <msokolov@ivan.Harhan.ORG>
-
- * ltcf-cxx.sh (ac_cv_prog_cc_pic_works, ac_cv_prog_cc_static_works):
- Don't unset, it's non-portable and no longer necessary, set to empty
- instead.
-
-2001-01-27 Michael Sokolov <msokolov@ivan.Harhan.ORG>, Alexandre Oliva <oliva@lsd.ic.unicamp.br>
-
- * ltconfig: Shell portability fix for the tagname validity check.
-
-2001-01-27 Michael Sokolov <msokolov@ivan.Harhan.ORG>
-
- * ltcf-cxx.sh: Use parentheses around eval $ac_compile.
-
-2001-01-27 Alexandre Oliva <aoliva@redhat.com>
-
- * ltcf-c.sh (ld_shlibs) [aix5*]: Disable on unknown CPU types.
- * ltcf-cxx.sh, ltcf-gcj.sh: Likewise.
-
-2001-01-24 Alexandre Oliva <aoliva@redhat.com>
-
- * ltmain.sh (TAG disable-shared, TAG disable-static): Make sure we
- keep at least one of build_libtool_libs or build_old_libs set to
- yes.
-
-2001-01-24 Alexandre Oliva <aoliva@redhat.com>
-
- * ltcf-gcj.sh (lt_simple_link_test_code): Remove stray `(0)'.
- * libtool.m4 (_AC_LIBTOOL_GCJ): Pass $CPPFLAGS on.
-
-2000-11-07 Philip Blundell <pb@futuretv.com>
-
- * Makefile.in (ETC_SUPPORT): Also add configbuild.* and configdev.*.
-
-2000-11-03 Philip Blundell <pb@futuretv.com>
-
- * Makefile.in (ETC_SUPPORT): Add configure.texi and associated info
- files.
-
-2001-01-15 Jeff Johnston <jjohnstn@redhat.com>
-
- * COPYING.NEWLIB: Put into source repository.
-
-2001-01-15 Ben Elliston <bje@redhat.com>
-
- * configure.in (host_tools): Add sid.
- Always configure cgen.
- * Makefile.in (all-sid): New target.
- (check-sid, clean-sid, install-sid): Likewise.
-
-2001-01-07 Andreas Jaeger <aj@suse.de>
-
- * config.sub, config.guess: Update from subversions.
-
-2000-12-12 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in: Disable language-specific target libraries for
- languages that aren't enabled.
-
-2000-11-24 Nick Clifton <nickc@redhat.com>
-
- * configure.in (xscale-elf): Add target.
- (xscale-coff): Add target.
- (c4x, c5x, tic54x): Move after ARM targets.
-
-2000-11-23 Alexandre Oliva <aoliva@redhat.com>
-
- * ltcf-gcj.sh: Added file, required by 2000-11-18 merge.
-
-2000-11-20 Ian Lance Taylor <ian@zembu.com>
-
- * ltcf-cxx.sh: Added file, required by 2000-11-18 merge.
-
-2000-11-18 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in: Merge with GCC and libgcj.
- (ALL_GCC_C, ALL_GCC_CXX): New macros. Use them as dependencies of
- configure-target-<library> when their configure scripts need the C
- or C++ library to have already been built to work properly.
- (do_proto_toplev): Set them to an empty string.
-
-2000-11-18 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (HOST_LIB_PATH, TARGET_LIB_PATH): New macros.
- (REALLY_SET_LIB_PATH): Use them.
-
-2000-11-06 Christopher Faylor <cgf@cygnus.com>
-
- * config.sub: Add support for Sun Chorus
-
-2000-11-02 Per Lundberg <plundis@chaosdev.org>
-
- * config.sub: Add support for the *-storm-chaos OS.
-
-2000-10-30 Stephane Carrez <stcarrez@worldnet.fr>
-
- * configure.in (noconfigdirs): Don't compile some
- of the libraries for 68HC11 & 68hc12 targets.
-
-2000-09-30 Alexandre Oliva <aoliva@redhat.com>
-
- * ltconfig, ltmain.sh, libtool.m4: Updated from libtool
- multi-language branch, to work around Solaris' /bin/sh bug. Rebuilt
- all affected `configure' scripts.
-
-2000-09-25 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (DEVO_SUPPORT): Added gettext.m4, libtool.m4 and
- ltcf-c.sh.
-
-2000-09-12 Philip Blundell <philb@gnu.org>
-
- * config.sub, config.guess: Update from subversions.
-
-2000-09-06 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (all-zlib): Added dummy target.
-
- * ltconfig, ltmain.sh, libtool.m4, ltcf-c.sh: Updated from libtool
- multi-language branch.
-
-2000-09-05 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (all-bootstrap): Added all-texinfo and all-zlib.
- (bootstrap*): Depend on all-bootstrap.
-
-2000-09-02 Alexandre Oliva <aoliva@redhat.com>, DJ Delorie <dj@redhat.com>
-
- * configure.in (FLAGS_FOR_TARGET): Use -nostdinc even for Canadian
- crosses, but add gcc/include to the header search path for them.
-
-2000-08-31 Alexandre Oliva <aoliva@redhat.com>
-
- * ltconfig, ltmain.sh: Updated from libtool multi-language branch.
- * libtool.m4, ltcf-c.sh: Copied from libtool multi-language branch.
- * gettext.m4: New file, extracted from aclocal.m4.
-
-2000-08-22 Alexandre Oliva <aoliva@redhat.com>
-
- * config-ml.in (CC, CXX): Avoid trailing whitespace.
- (LD_LIBRARY_PATH, SHLIB_PATH): Adjust for multilibs and export to
- sub-configures.
-
-2000-08-20 Doug Evans <dje@casey.transmeta.com>
-
- * Makefile.in (ALL_MODULES): Add all-cgen.
- (CROSS_CHECK_MODULES,INSTALL_MODULES,CLEAN_MODULES): Similarily.
- (all-cgen): New target.
- (all-opcodes,all-sim): Depend on all-cgen.
- * configure.in (host_tools): Add cgen.
- Only configure cgen if --enable-cgen-maint.
-
-2000-08-17 Alexandre Oliva <aoliva@redhat.com>
-
- * config-ml.in (CC, CXX): Don't introduce a leading space.
-
-2000-08-16 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (libstdcxx_flags): Use
- libstdc++-v3/src/libstdc++.INC.
-
-2000-08-15 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (libstdcxx_flags): Use libstdc++-v3/src/INCLUDES.
-
-2000-08-11 Jason Merrill <jason@redhat.com>
-
- * configure.in (CC_FOR_TARGET, CHILL_FOR_TARGET,
- CXX_FOR_TARGET): Add -B$$r/gcc/ here.
- (FLAGS_FOR_TARGET): Not here.
- (CHILL_FOR_TARGET, CXX_FOR_TARGET): Don't check the list of languages.
-
-2000-08-07 DJ Delorie <dj@redhat.com>
-
- * configure.in (FLAGS_FOR_TARGET): invert test for xgcc, should mean
- "if we're also building gcc, and it's a gcc that will run on the
- build machine, we want to use its includes instead of the system's
- default includes".
-
-2000-08-03 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (libstdcxx_flags): Don't use `"'.
-
- * config-ml.in: Adjust multilib search paths to the
- appropriate multilib tree.
-
-2000-08-02 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (CHILL_FOR_TARGET, CXX_FOR_TARGET): Convert blanks to
- commas in $LANGUAGES.
-
-2000-08-01 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (qCXX_FOR_TARGET): Use echo instead of expr.
-
-2000-07-31 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (qCXX_FOR_TARGET): Quote `&' characters in
- CXX_FOR_TARGET for sed.
-
-2000-07-30 Alexandre Oliva <aoliva@redhat.com>
-
- * configure.in (CC_FOR_TARGET, CHILL_FOR_TARGET, CXX_FOR_TARGET):
- Do not override if already set in the environment or in configure.
- Don't duplicate $(FLAGS_FOR_TARGET) if it already appears in them.
- (FLAGS_FOR_TARGET): Don't use host directories on Canadian crosses.
-
-2000-07-27 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (FLAGS_FOR_TARGET): New macro.
- (GCC_FOR_TARGET): Use it.
- (CC_FOR_TARGET, CXX_FOR_TARGET, CHILL_FOR_TARGET): Now defined...
- * configure.in: ... here.
- (FLAGS_FOR_TARGET): Define. Add ld build dir to -L path.
- (libstdcxx_flags): Define and append to CXX_FOR_TARGET.
-
-2000-07-24 Alexandre Oliva <aoliva@redhat.com>
-
- * Makefile.in (configure-target-libf2c): Depend on $(ALL_GCC).
- (configure-target-libchill, configure-target-libobjc): Likewise.
-
- * configure.in: Use the same cache file for all target libs.
- * config-ml.in: But different cache files per multilib variant.
-
-2000-07-23 Michael Sokolov <msokolov@ivan.Harhan.ORG>
-
- * configure (topsrcdir): Don't use dirname.
-
-2000-07-20 Jason Merrill <jason@redhat.com>
-
- * configure.in: Remove all references to libg++ and librx.
-
- * configure, configure.in, Makefile.in: Unify gcc and binutils.
-
-2000-07-20 Hans-Peter Nilsson <hp@axis.com>
-
- * config.sub: Update to subversions version 2000-07-06.
-
-2000-07-12 Andrew Haley <aph@cygnus.com>
-
- * configure.in (host_makefile_frag): Use mh-ia64pic on IA-64 hosts.
- (target_makefile_frag): Use mt-ia64pic on IA-64 targets.
-
-2000-07-07 Phil Edwards <pme@sourceware.cygnus.com>
-
- * symlink-tree: Check number of arguments.
-
-2000-06-06 Andrew Cagney <cagney@b1.cygnus.com>
-
- * texinfo/texinfo.tex: Update to version 2000-05-28.15.
-
-2000-07-05 Jim Wilson <wilson@cygnus.com>
-
- * Makefile.in (CXX_FOR_TARGET): Add libstdc++ to the library
- search path for a g++ extracted from the build tree. This
- will allow link tests run by configure scripts in
- subdirectories to succeed.
-
-2000-07-01 Koundinya K <kk@ddeorg.soft.net>
-
- * ltconfig: Add support for mips-dde-sysv4.2MP
-
-2000-06-28 Corinna Vinschen <vinschen@cygnus.com>
-
- * ltconfig: Check for host_os beeing one of `cygwin', `mingw' or
- `os2'. Force ac_cv_exeext to be ".exe" in that case.
-
-2000-06-19 Timothy Wall <twall@cygnus.com>
-
- * configure.in (noconfigdirs): Set noconfigdirs for tic54x target.
- * config.sub: Add tic54x target.
-
-2000-06-07 Phillip Thomas <pthomas@suse.de>
-
- * README-maintainer-mode: New file: Contains notes on using
- --enable-maintainer-mode with binutils.
-
-2000-05-29 Andrew Cagney <cagney@b1.cygnus.com>
-
- * texinfo/texinfo.tex: Update. Version from makeinfo 4.0.
-
-2000-05-30 Andrew Cagney <cagney@b1.cygnus.com>
-
- * config.sub: Import CVS version 1.167 Tue May 30 09:00:07 2000.
- * config.guess: Import CVS version 1.148 Tue May 30 09:00:06 2000
-
-20000-05-21 H.J. Lu (hjl@gnu.org)
-
- * Makefile.in (CC_FOR_TARGET): Make sure as/ld in the gcc
- directory are used if they exist. Make sure
- $(build_tooldir)/include is searched for header files,
- $(build_tooldir)/lib/ for library files.
- (GCC_FOR_TARGET): Likewise.
- (CXX_FOR_TARGET): Likewise.
-
-2000-05-18 Jeffrey A Law (law@cygnus.com)
-
- * configure.in (hppa*64*-*-*): Do build ld for this configuration.
-
-2000-05-17 Alexandre Oliva <aoliva@cygnus.com>
-
- * Makefile.in (configure-target-libiberty): Depend on
- configure-target-newlib.
-
-2000-05-16 Alexandre Oliva <aoliva@cygnus.com>
-
- * configure.in, Makefile.in: Merge all libffi-related
- configury stuff from the libgcj tree.
-
-2000-05-16 Andrew Cagney <cagney@b1.cygnus.com>
-
- Thu Apr 27 11:01:48 2000 Andrew Cagney <cagney@b1.cygnus.com>:
- * Makefile.in (do-tar-bz2, do-md5sum): Skip CVS directories.
-
-2000-05-16 Andrew Cagney <cagney@b1.cygnus.com>
-
- Wed Apr 26 17:03:53 2000 Andrew Cagney <cagney@b1.cygnus.com>:
- * Makefile.in (do-djunpack): New target. Update djunpack.bat with
- current version information. Add to proto-toplev directory.
- (gdb-taz): Build do-djunpack.
-
-2000-05-15 David Edelsohn <edelsohn@gnu.org>
-
- * configure.in: Special case powerpc*-*-aix* target_makefile_frag.
-
-2000-05-13 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
-
- * ltmain.sh: Preserve in relink_command any environment
- variables that may affect the linker behavior.
-
-2000-05-12 Jeffrey A Law (law@cygnus.com)
-
- * config.sub (basic_machine): Recognize hppa64 as a valid cpu type.
-
-2000-05-10 Jim Wilson <wilson@cygnus.com>
-
- * configure.in (ia64*-*-elf*): Add gdb and friends to noconfigdirs.
-
-2000-05-08 Eli Zaretskii <eliz@is.elta.co.il>
-
- * djunpack.bat: Change the Sed script to replace @V@ in fnchange.lst
- with the version name.
-
-2000-05-01 Benjamin Kosnik <bkoz@cygnus.com>
-
- * config.if: Tweak.
-
-2000-04-23 Eli Zaretskii <eliz@is.elta.co.il>
-
- * djunpack.bat: New file.
-
-2000-04-19 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (taz, gdb-taz, gas.tar.bz2, binutils.tar.bz2,
- gas+binutils.tar.bz2, libg++.tar.bz2, gnats.tar.bz2, gdb.tar.bz2,
- dejagnu.tar.bz2, gdb+dejagnu.tar.bz2, insight.tar.bz2,
- insight+dejagnu.tar.bz2, newlib.tar.bz2): Pass MD5PROG to sub-make.
-
-2000-04-16 Dave Pitts <dpitts@cozx.com>
-
- * config.sub (case $basic_machine): Change default for "ibm-*"
- to "openedition".
-
-2000-04-12 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (gdb-taz): New target. GDB specific archive.
- (do-md5sum): New target.
- (MD5PROG): Define.
- (PACKAGE): Default to TOOL.
- (VER): Default to a shell script.
- (taz): Rewrite target. Move real work to do-proto-toplev. Include
- md5 checksum generation.
- (do-proto-toplev): New target. Create $(PACKAGE)-$(VER) link.
- (do-tar-bz2): Delete creation of $(PACKAGE)-$(VER) link.
- (gdb.tar.bz2, dejagnu.tar.bz2, gdb+dejagnu.tar.bz2,
- insight.tar.bz2): Use gdb-taz to create archive.
-
-2000-04-07 Andrew Cagney <cagney@b1.cygnus.com>
-
- * configure (warn_cflags): Delete.
-
-2000-04-05 Benjamin Kosnik <bkoz@cygnus.com>
- Martin v. Loewis <martin@loewis.home.cs.tu-berlin.de>
-
- * configure.in (enable_libstdcxx_v3): Add.
- (target_libs): Add bits here to switch between libstdc++-v2 and
- libstdc++-v3.
- * config.if: And this file too.
- * Makefile.in: Add libstdc++-v3 targets.
-
-2000-04-05 Michael Meissner <meissner@redhat.com>
-
- * config.sub (d30v): Add d30v as a basic machine type.
-
-2000-03-29 Jason Merrill <jason@casey.cygnus.com>
-
- * configure.in: -linux-gnu*, not -linux-gnu.
-
-2000-03-03 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (taz): Set PACKAGE to TOOL when not defined.
- (do-tar-bz2): Replace TOOL with PACKAGE.
- (gdb.tar.bz2): Remove GDBTK from GDB package.
- (gdb+dejagnu.tar.bz2, insight.tar.bz2, insight+dejagnu.tar.bz2,
- dejagnu.tar.bz2): New packages.
-
-2000-02-27 Andreas Jaeger <aj@suse.de>
-
- * configure.in: Add entry for mips*-*-linux*, move catch all
- *-*-*linux* entry below this one.
-
-2000-02-27 Ian Lance Taylor <ian@zembu.com>
-
- * ltconfig, ltmain.sh: Update to libtool 1.3.4.
-
-2000-02-24 Nick Clifton <nickc@cygnus.com>
-
- * config.sub: Support an OS of "wince".
-
-2000-02-24 Andrew Cagney <cagney@b1.cygnus.com>
-
- * config.guess, config.sub: Updated to match config's 2000-02-15
- version.
-
-2000-02-23 Linas Vepstas <linas@linas.org>
-
- * config.sub: Add support for Linux/IBM 370.
- * configure.in: Likewise.
-
-2000-02-22 Nick Clifton <nickc@cygnus.com>
-
- * configure.in: Add mips-pe, sh-pe and arm-wince-pe targets.
-
-2000-02-20 Christopher Faylor <cgf@cygnus.com>
-
- * config.guess: Guess "cygwin" rather than "cygwin32".
-
-2000-02-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
-
- * configure (gcc_version): When setting, narrow search to
- lines containing `version_string'.
-
-2000-02-15 Denis Chertykov <denisc@overta.ru>
-
- * config.sub: Add support for avr target.
-
-2000-02-01 Hans-Peter Nilsson <hp@bitrange.com>
-
- * config.sub: Add mmix-knuth-mmixware.
-
-2000-01-27 Christopher Faylor <cgf@redhat.com>
-
- * Makefile.in (CC_FOR_TARGET): Add new winsup directory
- structure stuff to -L library search.
- (CXX_FOR_TARGET): Ditto.
- (CROSS_CHECK_MODULES): Fix spelling mistake.
-
-2000-01-24 Mark Mitchell <mark@codesourcery.com>
-
- * Makefile.in (CXX_FOR_TARGET): Use g++, not xgcc, to invoke
- the C++ compiler.
-
-2000-01-12 Richard Henderson <rth@cygnus.com>
-
- * configure.in: Don't build some bits for beos.
-
-2000-01-12 Joel Sherrill (joel@OARcorp.com)
-
- * Makefile.in (CC_FOR_TARGET): Use newlib libraries as well
- as include files.
-
-2000-01-06 Geoff Keating <geoffk@cygnus.com>
-
- * configure.in: Use mt-aix43 to handle *_TARGET defs,
- not mh-aix43.
-
-1999-12-14 Richard Henderson <rth@cygnus.com>
-
- * config.guess (alpha-osf, alpha-linux): Detect ev67.
- * config.sub: Accept alphaev[78], alphaev8.
-
-1999-12-03 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
-
- * config.guess, config.sub: Update from autoconf.
-
-Tue Nov 23 00:57:41 1999 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
-
- * config-ml.in (sparc*-*-*): Disable sparcv9 support if the
- necessary libraries are missing.
-
-1999-10-25 Andreas Schwab <schwab@suse.de>
-
- * configure: Fix quoting inside arguments of eval.
-
-1999-10-21 Nick Clifton <nickc@cygnus.com>
-
- * config-ml.in: Allow suppression of some ARM multilibs.
-
-Tue Sep 7 23:33:57 1999 Linas Vepstas <linas@linas.org>
-
- * config.guess: Add OS/390 match pattern.
- * config.sub: Add mvs, openedition targets.
- * configure.in (i370-ibm-opened*): New.
-
-1999-09-04 Steve Chamberlain <sac@pobox.com>
-
- * config.sub: Add support for configuring for pj.
-
-1999-08-31 Nick Clifton <nickc@cygnus.com>
-
- * config.sub (maybe_os): Add support for configuring for fr30.
-
-1999-08-25 Nick Clifton <nickc@cygnus.com>
-
- * configure.in: Do not configure or build ld for AIX
- platforms. ld is known to be broken on these platforms.
-
-Wed Aug 25 01:12:25 1999 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
-
- * config-ml.in: Pass compiler flag corresponding to multidirs to
- subdir configures.
-
-1999-08-09 Ian Lance Taylor <ian@zembu.com>
-
- * Makefile.in (LDFLAGS): Define.
-
-1999-08-08 Mumit Khan <khan@xraylith.wisc.edu>
-
- * configure.in (i[3456]-*-mingw32*): Don't put gprof in
- noconfigdirs.
- (*-*-cygwin*): Likewise.
-
-1999-08-08 Ian Lance Taylor <ian@zembu.com>
-
- * mkdep: New file.
- * Makefile.in (GAS_SUPPORT_DIRS): Add mkdep.
- (BINUTILS_SUPPORT_DIRS): Add mkdep.
-
- From Eli Zaretskii <eliz@is.elta.co.il>:
- * configure (tmpfile): Change cONf$$ to cNf$$ to avoid an overly
- long file name when using DJGPP on MS-DOS.
-
-Wed Aug 4 02:07:14 1999 Jeffrey A Law (law@cygnus.com)
-
- * config.sub (vxworks case): Use os=-vxworks, not os=vxworks.
-
-1999-07-30 Alan Modra <alan@spri.levels.unisa.edu.au>
-
- * Makefile.in (check-target-libio): Remove all-target-libstdc++
- dependency as this causes "make check" to globally "make all"
-
-Tue Jun 22 23:45:18 1999 Tom Tromey <tromey@cygnus.com>
-
- * configure.in (target_libs): Added target-zlib.
- * Makefile.in (ALL_TARGET_MODULES): Added zlib.
- (CONFIGURE_TARGET_MODULES): Likewise.
- (CHECK_TARGET_MODULES): Likewise.
- (INSTALL_TARGET_MODULES): Likewise.
- (CLEAN_TARGET_MODULES): Likewise.
- (configure-target-zlib): New target.
- (all-target-zlib): Likewise.
- (all-target-libjava): Depend on all-target-zlib.
- (configure-target-libjava): Depend on configure-target-zlib.
-
- * Makefile.in (configure-target-libjava): Depend on
- configure-target-newlib.
- (configure-target-boehm-gc): New target.
- (configure-target-qthreads): New target.
-
- * configure.in (target_libs): Added target-qthreads.
- * Makefile.in (ALL_TARGET_MODULES): Added qthreads.
- (CONFIGURE_TARGET_MODULES): Likewise.
- (CHECK_TARGET_MODULES): Likewise.
- (INSTALL_TARGET_MODULES): Likewise.
- (CLEAN_TARGET_MODULES): Likewise.
- (all-target-qthreads): New target.
- (configure-target-libjava): Depend on configure-target-qthreads.
- (all-target-libjava): Depend on all-target-qthreads.
-
- * Makefile.in (ALL_TARGET_MODULES): Added libjava, boehm-gc.
- (CONFIGURE_TARGET_MODULES): Likewise.
- (CHECK_TARGET_MODULES): Likewise.
- (INSTALL_TARGET_MODULES): Likewise.
- (CLEAN_TARGET_MODULES): Likewise.
- (all-target-libjava): New target.
- (all-target-boehm-gc): Likewise.
- * configure.in (target_libs): Added libjava, boehm-gc.
-
-1999-07-22 Ian Lance Taylor <ian@zembu.com>
-
- * Makefile.in (binutils.tar.bz2): Don't pass makeall.bat and
- configure.bat in SUPPORT_FILES.
- (gas+binutils.tar.bz2): Likewise.
-
- * makeall.bat: Remove; obsolete.
-
-1999-07-21 Ian Lance Taylor <ian@zembu.com>
-
- From Mark Elbrecht:
- * configure.bat: Remove; obsolete.
-
-1999-07-11 Ian Lance Taylor <ian@zembu.com>
-
- * configure: Add -W -Wall to the default CFLAGS when compiling with
- gcc.
-
-Thu Jul 8 12:32:23 1999 John David Anglin <dave@hiauly1.hia.nrc.ca>
-
- * configure.in: Build ld, binutils & gas for hppa*-*-linux-gnu*.
-
-1999-06-30 Mark Mitchell <mark@codesourcery.com>
-
- * configure.in: Build ld on IRIX6.
-
-1999-06-12 Ian Lance Taylor <ian@zembu.com>
-
- * Makefile.in: Change distribution targets to use bzip2 instead of
- gzip.
- (TEXINFO_SUPPORT): Set to just texinfo/texinfo.tex.
- (taz): Don't use texinfo/gpl.texinfo or texinfo/lgpl.texinfo.
-
-1999-06-04 Nick Clifton <nickc@cygnus.com>
-
- * config.sub: Add mcore target.
-
-1999-05-30 Cort Dougan <cort@cs.nmt.edu>
-
- * config.guess (ppc-*-linux-gnu): Also use ld emul elf32ppclinux.
-
-1999-05-25 H.J. Lu (hjl@gnu.org)
-
- * config.guess (dummy): Changed to $dummy.
-
-1999-05-24 Nick Clifton <nickc@cygnus.com>
-
- * config.sub: Tidied up case statements.
-
-1999-05-22 Ben Elliston <bje@cygnus.com>
-
- * config.guess: Handle NEC UX/4800. Contributed by Jiro Takabatake
- <jiro@din.or.jp>.
-
- * config.guess: Merge with FSF version. Future changes will be
- more accurately recorded in this ChangeLog.
- * config.sub: Likewise.
-
-1999-05-20 Stephen L Moshier <moshier@world.std.com>
-
- * Makefile.in (GCC_FOR_TARGET): Add -I$(build_tooldir)/include.
-
-1999-04-30 Tom Tromey <tromey@cygnus.com>
-
- * ltmain.sh: [mode link] Always use CC given by ltconfig.
-
-1999-04-23 Tom Tromey <tromey@cygnus.com>
-
- * ltconfig, ltmain.sh: Update to libtool 1.2f.
-
-1999-04-20 Drew Moseley <dmoseley@cygnus.com>
-
- * configure.in (noconfigdirs): Don't build libstub for arm-elf targets.
- (noconfigdirs): Don't build any bsp stuff for for arm-oabi targets.
- Bad merge removed these two changes.
-
-Tue Apr 13 22:50:54 1999 Donn Terry (donn@interix.com)
- Martin Heller (Ing.-Buero_Heller@t-online.de)
-
- * config.guess (interix Alpha): Add.
-
-1999-04-11 Richard Henderson <rth@cygnus.com>
-
- * configure.in (i?86-*-beos*): Do config gperf; don't config
- gdb, newlib, or libgloss.
-
-1999-04-11 Alexandre Oliva <oliva@dcc.unicamp.br>
-
- * config-ml.in: On mips*-*-*, if multidirs contains mabi=64, try to
- link a trivial program with -mabi=64. If it fails, remove mabi=64
- from multidirs.
-
-1999-04-10 Philipp Thomas (kthomas@gwdg.de)
-
- * config.sub: Set basic_machine to i586 when target_alias = k6-*.
-
-1999-04-08 Nick Clifton <nickc@cygnus.com>
-
- * config.sub: Add support for mcore targets.
-
-1999-04-07 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (d30v-*): Use config/mt-d30v as makefile fragment,
- not mt-ospace, in order to shut up assembler warning about using
- symbols that are named the same as registers.
-
-1999-04-07 Drew Moseley <dmoseley@cygnus.com>
-
- * Makefile.in (all-target-cygmon): Added all-target-bsp to the
- dependency list for all-target-cygmon.
-
-1999-04-05 Doug Evans <devans@casey.cygnus.com>
-
- * config-ml.in: Check $host, not $target, for selective multilibs.
- (arm-*-*): Allow disabling of biendian, h/w fp, 26 bit apcs,
- thumb interworking, and underscore prefix multilibs.
-
-1999-04-04 Ian Lance Taylor <ian@zembu.com>
-
- * missing: Update to version from current automake.
-
-Fri Apr 2 15:11:32 1999 H.J. Lu (hjl@gnu.org)
-
- * configure (gxx_include_dir): Removed.
-
- * configure.in (gxx_include_dir): Handle it.
- * Makefile.in: Likewise.
-
-1999-03-29 Gavin Romig-Koch <gavin@cygnus.com>
-
- * config.sub (mips64vr4111,mips64vr4111el) Add.
-
-1999-03-21 Ben Elliston <bje@cygnus.com>
-
- * config.guess: Correct typo for detecting ELF on FreeBSD.
-
-Thu Mar 18 00:17:50 1999 Mark Elbrecht <snowball3@usa.net>
-
- * config/mh-go32: Delete.
- * config/mh-djgpp: New. Renamed from mh-go32.
- * configure.in (pc-msdosdjgpp): Set host_makefile_frag to
- config/mh-djgpp.
-
-Thu Mar 11 18:37:23 1999 Drew Moseley <dmoseley@cygnus.com>
-
- * Makefile.in (all-target-bsp): Added all-gcc all-binutils and
- all-target-newlib to dependency list for all-target-bsp.
-
-Thu Mar 11 01:19:31 1999 Mumit Khan <khan@xraylith.wisc.edu>
-
- * config.sub: Add i386-uwin support.
- * config.guess: Likewise.
-
-Thu Mar 11 01:07:55 1999 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
-
- * configure.in: cleanup, add mh-*pic handling for arm, special
- case powerpc*-*-aix*
-
-Wed Mar 10 18:35:07 1999 Jeff Johnston <jjohnstn@cygnus.com>
-
- * configure.in (noconfigdirs): Removed target-libgloss so libnosys.a
- can be built.
-
-Wed Mar 10 17:39:09 1999 Drew Moseley <dmoseley@cygnus.com>
-
- * configure.in: Added bsp support to arm-*-coff and arm-*-elf
- targets.
-
-1999-03-02 Nick Clifton <nickc@cygnus.com>
-
- * config.sub: Rename CYGNUS LOCAL to EGCS LOCAL
-
-1999-02-28 Geoffrey Noer <noer@cygnus.com>
-
- * config.sub: Check for "cygwin*" rather than "cygwin32*"
-
-1999-02-24 Nick Clifton <nickc@cygnus.com>
-
- * config.sub: Fix typo in arm recognition.
-
-1999-02-24 Drew Moseley <dmoseley@cygnus.com>
-
- * configure.in (noconfigdirs): Changed target_configdirs to
- include target-bsp only for m68k-*-elf* and m68k-*-coff*
- rather than m68k-*-* since it is not known to work on
- m68k-aout. Ditto for arm-*-*oabi.
-
-1999-02-24 Stan Shebs <shebs@andros.cygnus.com>
-
- * configure.in (*-*-windows*): Remove, no longer used.
- * config/mh-windows: Ditto.
-
-1999-02-19 Ben Elliston <bje@cygnus.com>
-
- * config.guess: Automatically recognise ELF on FreeBSD. From Niall
- Smart and improved by Andrew Cagney.
-
-1999-02-18 Marc Espie <espie@cvs.openbsd.org>
-
- * config.guess: Recognize openbsd-*-hppa.
-
-1999-02-17 H.J. Lu (hjl@gnu.org)
-
- * Makefile.in (REALLY_SET_LIB_PATH): Append $$$(RPATH_ENVVAR)
- only if it is not empty.
-
-1999-02-17 Nick Clifton <nickc@cygnus.com>
-
- Patch from: Scott Bambrough <scottb@corelcomputer.com>
-
- * config.guess: Modified to recognize uname's armv* syntax.
-
- * config.sub: Modified to recognize uname's armv* syntax.
-
-1999-02-17 Mark Salter <msalter@cygnus.com>
-
- * configure.in: Added target-bsp for sparclite.
-
-1999-02-08 Richard Henderson <rth@cygnus.com>
-
- * config.sub: Recognize alphapca5[67] and up to alphaev8.
-
-1999-02-08 Nick Clifton <nickc@cygnus.com>
-
- * configure.in: Add support for strongarm port.
- * config.sub: Add support for strongarm target.
-
-1999-02-07 Mumit Khan <khan@xraylith.wisc.edu>
-
- * configure.in (*-*-cygwin32*): Use config/mh-cygwin instead of
- the old name config/mh-cygwin32.
- Enable texinfo.
-
-1999-02-04 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Do build ld for ix86 Solaris.
-
-1999-02-02 Jim Wilson <wilson@cygnus.com>
-
- * Makefile.in (EXTRA_GCC_FLAGS): Set AR to $AR instead of
- $AR_FOR_TARGET. Likewise for RANLIB.
-
-1999-02-02 Catherine Moore <clm@cygnus.com>
-
- * config.sub (oabi): Recognize.
- * configure.in (arm-*-oabi): Handle.
-
-1999-01-30 Robert Lipe (robertlipe@usa.net)
-
- * config.guess: Improve detection of i686 on UnixWare 7.
-
-1999-01-30 Mumit Khan <khan@xraylith.wisc.edu>
-
- * config.guess: Add support for i386-pc-interix.
- * config.sub: Likewise.
- * configure.in: Likewise.
- * config/mh-interix: New file.
-
-1999-01-18 Christopher Faylor <cgf@cygnus.com>
-
- * Makefile.in: Remove unneeded all-target-libio from
- from all-target-winsup target since it is now unneeded.
- Add all-target-libtermcap in its place since it is now
- needed.
-
-1998-12-30 Christopher Faylor <cgf@cygnus.com>
-
- * configure.in: makefile stub for cygwin target is probably
- unnecessary. Remove it for now.
- * config/mt-cygwin: Remove.
-
-1998-12-30 Christopher Faylor <cgf@cygnus.com>
-
- * configure.in: libtermcap.a should be built when cygwin is the
- target as well as the host.
- * config.guess: Allow mixed case in cygwin uname output.
- * Makefile.in: Add libtermcap target.
- * config/mt-cygwin: New file. libtermcap target info.
-
-1998-12-23 Jeffrey A Law (law@cygnus.com)
-
- * config.sub: Clean up handling of hppa2.0.
-
-1998-12-22 Rodney Brown (rodneybrown@pmsc.com)
-
- * config.guess: Use C code to identify more HP machines.
-
-Thu Dec 17 01:22:30 1998 Jeffrey A Law (law@cygnus.com)
-
- * config.sub: Handle hppa2.0.
-
-Tue Dec 15 17:02:58 1998 Bob Manson <manson@charmed.cygnus.com>
-
- * configure.in: Add cygmon for x86-coff and x86-elf. Configure
- cygmon for all sparclite targets, regardless of object format.
-
-1998-12-15 Mark Salter <msalter@cygnus.com>
-
- * configure.in: Added target-bsp for several target architectures.
-
- * Makefile.in: Added rules for bsp.
-
-Fri Dec 4 01:34:02 1998 Jeffrey A Law (law@cygnus.com)
-
- * config.guess: Improve detection of hppa2.0 processors.
-
-Fri Dec 4 01:33:05 1998 Niall Smart <nialls@euristix.ie>
-
- * config.guess: Recognize FreeBSD using ELF automatically.
-
-1998-11-26 Manfred Hollstein <manfred@s-direktnet.de>
-
- * configure (skip-this-dir): Add handling for new shell script, which
- might be created by a sub-directory's configure to indicate, this particular
- directory is "unwanted".
- * Makefile.in ($(CONFIGURE_TARGET_MODULES)): Likewise.
-
-Wed Nov 18 18:28:45 1998 Geoffrey Noer <noer@cygnus.com>
-
- * ltconfig: import from libtool, after changing libtool to
- account for the cygwin name change.
-
-Wed Nov 18 18:09:14 1998 Geoffrey Noer <noer@cygnus.com>
-
- * Makefile.in: CC_FOR_TARGET and CXX_FOR_TARGET should also
- include newlib/libc/sys/cygwin and newlib/libc/sys/cygwin32.
-
-Wed Nov 18 20:13:29 1998 Christopher Faylor <cgf@cygnus.com>
-
- * configure.in: Add libtermcap to list of cygwin dependencies.
-
-1998-11-17 Geoffrey Noer <noer@cygnus.com>
-
- * Makefile.in: modify CC_FOR_TARGET and CXX_FOR_TARGET so that
- they include winsup/include when it's a cygwin target.
-
-1998-11-12 Tom Tromey <tromey@cygnus.com>
-
- * configure.in (host_tools): Added zip.
- * Makefile.in (all-target-libjava): Depend on all-zip.
- (all-zip): New target.
- (ALL_MODULES): Added all-zip.
- (NATIVE_CHECK_MODULES): Added check-zip.
- (INSTALL_MODULES): Added install-zip.
- (CLEAN_MODULES): Added clean-zip.
-
-1998-11-12 Geoffrey Noer <noer@cygnus.com>
-
- * Makefile.in: lose "32" from comment about cygwin.
-
-1998-11-05 Nick Clifton <nickc@cygnus.com>
-
- * configure.in: Use -Os to build target libraries for the fr30.
-
-1998-11-04 Dave Brolley <brolley@cygnus.com>
-
- * config.sub: Add fr30.
-
-1998-11-02 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: drop "32" from config/mh-cygwin32. Check
- cygwin* instead of cygwin32*.
- * config.sub: Check cygwin* instead of cygwin32*.
-
-1998-10-22 Robert Lipe <robertl@dgii.com>
-
- * config.guess: Match any version of Unixware7.
-
-1998-10-20 Syd Polk <spolk@cygnus.com>
-
- * Makefile.in configure.in: Add the ability to use tcl8.1 and tk8.1
- if desired.
-
-1998-10-18 Jeffrey A Law (law@cygnus.com)
-
- * config.if (cxx_interface, libstdcxx_interface): Do not try to set
- these if the appropriate directories and files to not exist.
-
-1998-10-14 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (DEVO_SUPPORT): Add config.if.
-
-1998-10-13 Manfred Hollstein <manfred@s-direktnet.de>
-
- * configure: Add pattern to replace "build_tooldir"'s
- definition in the generated Makefile with "tooldir"'s
- actual value.
-
-Tue Oct 13 09:17:06 1998 Jeffrey A Law (law@cygnus.com)
-
- * config.sub: Bring back lost sparcv9.
-
- * Makefile.in (all-snvavigator): Remove all-flexlm dependency.
-
-Mon Oct 12 12:09:44 1998 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (CHILL_FOR_TARGET): Mirror recent changes to
- CC_FOR_TARGET and friends.
-
-Mon Oct 12 12:09:30 1998 Alexandre Oliva <oliva@dcc.unicamp.br>
-
- * Makefile.in (build_tooldir): New variable, same as tooldir.
- (CC_FOR_TARGET, GCC_FOR_TARGET, CXX_FOR_TARGET): Add
- -B$(build_tooldir)/bin/.
- (BASE_FLAGS_TO_PASS): Pass build_tooldir down.
-
-Wed Sep 30 22:20:50 1998 Robert Lipe <robertl@dgii.com>
-
- * config.sub: Add support for i[34567]86-pc-udk.
- * configure.in: Likewise.
-
-Wed Sep 30 19:23:48 1998 Geoffrey Noer <noer@cygnus.com>
-
- * Makefile.in: add bzip2 package building bits for user
- tools module
- * configure.in: ditto
-
-Wed Sep 30 03:00:05 1998 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (TARGET_CONFIGDIRS): Add libobjc.
- (ALL_TARGET_MODULES): Add all-target-libobjc.
- (CONFIGURE_TARGET_MODULES, CHECK_TARGET_MODULES): Similarly.
- (INSTALL_TARGET_MODULES, CLEAN_TARGET_MODULES): Similarly.
- (all-target-libchill): Add dependencies.
- * configure.in (target_libs): Add libchill.
-
-1998-09-30 Manfred Hollstein <manfred@s-direktnet.de>
-
- * configure.in (target_subdir): Remove duplicate line.
-
-Tue Sep 29 22:45:41 1998 Felix Lee <flee@cygnus.com>
-
- * Makefile.in (all-automake): fix dependencies.
-
-Mon Sep 28 04:04:27 1998 Jeffrey A Law (law@cygnus.com)
-
- * configure.in: Minor cleanups for building in the $(target_alias)
- subdir.
-
-1998-09-22 Jim Wilson <wilson@cygnus.com>
-
- * Makefile.in (bootstrap): Set r and s before make all. Use
- BASE_FLAGS_TO_PASS in make all.
- (cross): Likewise.
-
-1998-09-20 Mark Mitchell <mark@markmitchell.com>
-
- * Makefile.in (bootstrap): Pass TARGET_FLAGS_TO_PASS to `make all'.
-
-Sun Sep 20 00:13:02 1998 Richard Henderson <rth@cygnus.com>
-
- * config.sub: Fix typo in last change.
-
-1998-09-19 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
-
- * config.sub: Add support for C4x target.
- * configure.in: Likewise.
-
-1998-09-13 David S. Miller <davem@pierdol.cobaltmicro.com>
-
- * config.sub: Recognize sparcv9 just like sparc64.
-
-Wed Sep 9 15:44:52 1998 Robert Lipe <robertl@dgii.com>
-
- * config.guess: Match "Pent II" or "PentII" for OpenServer.
-
-Tue Sep 8 01:18:39 1998 Jeffrey A Law (law@cygnus.com)
-
- * config.guess: Correctly identify Pentium II sco boxes.
-
- * config.guess: Fix "tr" code. From Weiwen Liu.
-
-Sat Sep 5 13:56:52 1998 John Hughes <john@Calva.COM>
-
- * configure.in: Do not assume x86-svr4 or x86-unixware can handle
- stabs.
-
-Sat Sep 5 02:12:02 1998 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (TARGET_CONFIGDIRS): Add libchill.
- (ALL_TARGET_MODULES): Add all-target-libchill.
- (CONFIGURE_TARGET_MODULES, CHECK_TARGET_MODULES): Similarly.
- (INSTALL_TARGET_MODULES, CLEAN_TARGET_MODULES): Similarly.
- (all-target-libchill): Add dependencies.
- * configure.in (target_libs): Add libchill.
-
-Sun Aug 30 22:27:02 1998 Lutz Wohlrab <lutz.wohlrab@informatik.tu-chemnitz.de>
-
- * config.guess: Avoid assumptions about "tr" behaves when
- LANG is set to something other than English.
-
-Sun Aug 30 22:14:44 1998 H.J. Lu (hjl@gnu.org)
-
- * configure (gxx_include_dir): Changed to
- '${prefix}/include/g++'-${libstdcxx_interface}.
-
- * config.if: New to determine the interfaces.
-
-Sun Aug 30 21:15:19 1998 Mark Klein (mklein@dis.com)
-
- * config.guess: Detect and handle MPE/IX.
- * config.sub: Deal with MPE/IX.
-
-Sat Aug 29 14:32:55 1998 David Edelsohn <edelsohn@mhpcc.edu>
-
- * configure.in: Use mh-aix43.
-
-1998-07-29 Manfred Hollstein <manfred@s-direktnet.de>
-
- * configure: Fix --without/--disable cases for gxx-include-dir.
-
-Fri Aug 28 12:28:26 1998 Per Bothner <bothner@cygnus.com>
-
- * mdata-sh: Imported. Needed for automake support.
-
-Thu Aug 13 12:49:29 1998 H.J. Lu <hjl@gnu.org>
-
- * Makefile.in (taz): Try "chmod -R og=u ." before
- "chmod og=u `find . -print`".
-
-Fri Jul 31 09:38:33 1998 Catherine Moore <clm@cygnus.com>
-
- * configure.in: Add arm-elf and thumb-elf support.
-
-Mon Jul 27 16:23:58 1998 Doug Evans <devans@canuck.cygnus.com>
-
- * Makefile.in: Undo previous patch.
-
-Fri Jul 24 19:55:24 1998 Doug Evans <devans@canuck.cygnus.com>
-
- * Makefile.in (INSTALL_TARGET): Move EXTRA_TARGET_HOST_INSTALL_MODULES
- to here ...
- (install-no-fixedincludes): and here
- (INSTALL_MODULES): ... from here.
-
-Fri Jul 24 17:01:42 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub: Merge with FSF.
-
- * config.guess: Merge with FSF.
-
-Fri Jul 24 08:43:36 1998 Doug Evans <devans@canuck.cygnus.com>
-
- * configure (extraconfigdirs): New variable.
- (SUBDIRS): Add extraconfigdirs and recurse on them too.
- * Makefile.in (all): Move higher in file.
- (EXTRA_TARGET_HOST_ALL_MODULES): New variable.
- (EXTRA_TARGET_HOST_{INSTALL,CHECK}_MODULES): New variables.
- (ALL_MODULES): Add EXTRA_TARGET_HOST_ALL_MODULES.
- (CROSS_CHECK_MODULES): Add EXTRA_TARGET_HOST_CHECK_MODULES.
- (INSTALL_MODULES): Add EXTRA_TARGET_HOST_INSTALL_MODULES.
-
-1998-07-23 Brendan Kehoe <brendan@cygnus.com>
-
- * Makefile.in (all-target-libjava): Depend on all-gcc and
- all-target-newlib.
- (configure-target-libjava): Depend on $(ALL_GCC).
-
-Sat Jul 18 14:32:43 CDT 1998 Robert Lipe <robertl@dgii.com>
-
- * config.guess: (*-pc-sco3.2v5) Add detection for Pentium II.
- (*-pc-unixware7) Add detection for Pentium II, Pentium Pro.
-
-Fri Jul 17 13:30:18 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ylwrap: Change absolute path checks to check for DOS style path
- names.
-
- * ylwrap: Don't use a full path name if the source file is in the
- same directory. From hjl@lucon.org (H.J. Lu).
-
- * config-ml.in: Default to being verbose, to match Feb 18 change to
- configure.
-
-Thu Jul 16 12:29:51 1998 Ian Lance Taylor <ian@cygnus.com>
-
- Brought over from egcs:
-
- Sat Jun 27 22:46:32 1998 Jeffrey A Law (law@cygnus.com)
-
- * configure.in (target_subdir): Set to ${target_alias} instead
- of "libraries".
-
- Mon Sep 1 16:45:44 1997 Jim Wilson <wilson@cygnus.com>
-
- * configure.in (target_subdir): Set to libraries if enable_multilib.
-
-Wed Jul 15 01:00:54 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in ($(CONFIGURE_TARGET_MODULES)): If there are any
- multilibs, force reconfiguration the first time we create
- multilib.out in a subdirectory, in case TARGET_SUBDIR is `.'.
-
-Tue Jul 14 23:41:03 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Strip any --no option from CONFIG_ARGUMENTS, to
- avoid confusion with --no-recursion.
-
-Tue Jul 14 15:37:41 1998 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: Win32 hosts shouldn't use install -x
- * install-sh: remove -x option, and special .exe-handling
- hack.
-
-Tue Jul 14 15:28:41 1998 Richard Henderson <rth@cygnus.com>
-
- * config.guess: Recognize i586-pc-beos.
- * configure.in: Don't build some bits for beos.
-
-Tue Jul 14 13:22:18 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: If CC is set but CFLAGS is not, and CC is gcc, make
- CFLAGS default to -O2.
-
- * ltmain.sh: Add some hacks to make SunOS --enable-shared work
- when using GNU ld.
-
-Fri Jul 10 13:18:23 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltmain.sh: Correct install when using a different shell.
-
-Tue Jul 7 15:24:38 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig, ltmain.sh: Update to libtool 1.2b.
-
-Thu Jul 2 13:57:36 1998 Klaus Kaempf <kkaempf@rmi.de>
-
- * makefile.vms: Update to build binutils/makefile.vms. Add install
- target.
-
-Wed Jul 1 16:45:21 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig: Update to correct AIX handling.
-
-Sat Jun 27 22:46:32 1998 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (BASE_FLAGS_TO_PASS): Add TARGET_SUBDIR.
-
- * configure.in (target_subdir): Set to ${target_alias} instead
- of "libraries".
-
-1998-06-26 Manfred Hollstein <manfred@s-direktnet.de>
-
- * Makefile.in (BASE_FLAGS_TO_PASS): Add gcc_version_trigger.
- (Makefile): Depend on $(gcc_version_trigger).
-
- * configure (gcc_version): Change default initializer to empty
- string.
- (gcc_version_trigger): New variable; pass this variable down
- to subdir configures to enable them checking gcc's version
- themselves. Emit make macros for both gcc_version vars.
- (topsrcdir): Initialize reliably.
- (recursion line): Remove --with-gcc-version=${gcc_version}.
-
-1998-06-24 Manfred Hollstein <manfred@s-direktnet.de>
-
- * configure (enable_version_specific_runtime_libs): Implement new flag
- --enable-version-specific-runtime-libs which installs C++ runtime stuff
- in $(libsubdir); emit definition in each generated Makefile.
- (gxx_include_dir): Initialize depending on
- $enable_version_specific_runtime_libs.
-
-1998-06-24 Manfred Hollstein <manfred@s-direktnet.de>
-
- * configure (gcc_version): Initialize properly depending on
- how and where configure is started.
- (recursion line): Pass a --with-gcc-version=${gcc_version}
- to configures in subdirs.
-
-Wed Jun 24 16:01:59 1998 John Metzler <jmetzler@cygnus.com>
-
- * configure.in (noconfigdirs): Add configure pattern for mips tx39
- cygmon
-
-Tue Jun 23 22:42:32 1998 Mark Alexander <marka@cygnus.com>
-
- * configure.in: Add cygmon and libstub support for mn10200.
-
-1998-06-19 Manfred Hollstein <manfred@s-direktnet.de>
-
- * configure (gcc_version): Add new variable describing the
- particular gcc version we're building.
- * Makefile.in (libsubdir): Add new macro for the directory
- in which the compiler finds executables, libraries, etc.
- (BASE_FLAGS_TO_PASS): Pass down gcc_version, target_alias
- and libsubdir.
-
-Fri Jun 19 02:36:59 1998 Alexandre Oliva <oliva@dcc.unicamp.br>
-
- * Makefile.in (local-clean): Remove *.log.
- (warning.log): Built with warn_summary from build.log.
- (mail-report.log): Run test_summary.
- (mail-report-with-warnings.log): Run test_summary including
- warning.log in the report.
-
-Thu Jun 18 11:26:03 1998 Robert Lipe <robertl@dgii.com>
-
- * config.guess: Detection of Pentium II for *-sco-3.2v5*.
-
-Mon Jun 15 14:53:54 1998 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (grep): Grep no longer depends on libiberty.
-
-Fri Jun 12 14:03:34 1998 Syd Polk <spolk@cygnus.com>
-
- * Makefile.in: all-snavigator needs all-libgui.
-
-Thu Jun 11 19:43:47 1998 Mark Alexander <marka@cygnus.com>
-
- * configure.in: Add cygmon and libstub support for mn10300.
-
-Wed Jun 10 11:19:47 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * missing: Update to version from automake 1.3.
-
- * ltmain.sh: On installation, don't get confused if the same name
- appears more than once in the list of library names.
-
-Wed Jun 3 14:51:42 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub: Accept m68060 and m5200 as CPU names.
-
-Mon Jun 1 17:25:16 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Use && rather than using -a in test, because odd
- strings can confuse test.
- * configure.in: Likewise.
-
-Thu May 28 19:31:13 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig, ltmain.sh: Bring in Visual C++ support.
-
-Sat May 23 23:44:13 1998 Alexandre Oliva <oliva@dcc.unicamp.br>
-
- * Makefile.in (boostrap2-lean, bootstrap3-lean,
- bootstrap4-lean): New targets.
-
-Mon May 11 23:55:56 1998 Jeffrey A Law (law@cygnus.com)
-
- * mpw-* Delete. Not used.
-
-Mon May 11 23:11:34 1998 Jeffrey A Law (law@cygnus.com)
-
- * COPYING.LIB: Update FSF address.
-
-Fri May 8 01:30:20 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig, ltmain.sh: Update to libtool 1.2a.
-
- * Makefile.in (GASB_SUPPORT_DIRS): Remove intl; already included via
- GAS_SUPPORT_DIRS.
-
-Thu May 7 17:27:35 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig, ltmain.sh: Avoid producing a version number if
- -version-info was not used.
-
-Tue May 5 18:02:24 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Add --with-newlib to CONFIG_ARGUMENTS if we are
- building with newlib.
-
-1998-04-30 Paul Eggert <eggert@twinsun.com>
-
- * Makefile.in (EXTRA_GCC_FLAGS): Remove backslash at end;
- Solaris `make' causes it to continue to next definition.
-
-Tue Apr 28 16:24:24 1998 Jason Molenda (crash@bugshack.cygnus.com)
-
- * Makefile.in (install-gdbtk): Call this 'install-gdb' so that
- the right GUI libraries and files are installed along with GDB.
-
-Tue Apr 28 18:11:24 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Change alpha to alpha* in several places.
-
-Tue Apr 28 07:42:00 1998 Mark Alexander <marka@cygnus.com>
-
- * config.sub: Recognize sparc86x.
-
-Tue Apr 28 07:35:02 1998 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (--enable-target-optspace): Remove debug echo.
-
-Thu Apr 23 21:31:16 1998 Jim Wilson <wilson@cygnus.com>
-
- * configure: Set CXXFLAGS from CXXFLAGS, not CFLAGS.
-
-Thu Apr 23 12:26:38 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig: Update cygwin32 support.
-
- * Makefile.in (GAS_SUPPORT_DIRS): Add intl.
- (BINUTILS_SUPPORT_DIRS, GASB_SUPPORT_DIRS): Likewise.
- (GDB_SUPPORT_DIRS): Likewise.
-
-Wed Apr 22 12:30:10 1998 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (target_makefile_frag): If --enable-target-optspace,
- use -Os to compile target libraries rather than -O2. Default to
- using -Os for d10v and m32r if --{enable,disable}-target-optspace is
- not used.
- * configure.in (target_cflags): Ditto for d30v.
-
-Tue Apr 21 23:06:54 1998 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.in (all-bfd): Depend on all-intl.
- (all-binutils): Likewise.
- (all-gas): Likewise.
- (all-gprof): Likewise.
- (all-ld): Likewise.
-
-1998-04-19 Brendan Kehoe <brendan@cygnus.com>
-
- * configure.in (host_tools): Fix typo, lbtool -> libtool.
-
-Fri Apr 17 16:20:42 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (all-bfd): Depend upon all-libiberty.
-
- * ltconfig, ltmain.sh: Bring in newer cygwin32 support.
-
-Fri Apr 17 12:22:22 1998 Bob Manson <manson@charmed.cygnus.com>
-
- * Makefile.in: Add libstub.
-
- * configure.in: Ditto. Build libstub for targets that have cygmon
- support.
-
-Tue Apr 14 18:01:55 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Don't set PICFLAG on ix86-cygwin32.
-
-Tue Apr 14 12:24:45 1998 J. Kean Johnston <jkj@sco.com>
-
- * configure.in: Recognise i[3456]96-*-sysv5* as a valid host, and
- use mh-sysv5 if specified. Support gprof on SCO Open Server.
-
-Tue Apr 14 11:33:51 1998 Krister Walfridsson <cato@df.lth.se>
-
- * configure: Define DEFAULT_M4 by searching PATH.
- * Makfile.in: Use DEFAULT_M4.
-
-Mon Apr 13 15:37:24 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig: Add cygwin32 support.
-
- * Makefile.in, configure.in: Add libtool as a native only directory
- to configure and build.
-
-Sun Apr 12 20:58:46 1998 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (INSTALL_MODULES): Remove texinfo.
-
-Wed Apr 8 13:18:56 1998 Philippe De Muyter <phdm@macqel.be>
-
- * Makefile.in (EXTRA_GCC_FLAGS): XFOO lines shortened.
-
-Thu Apr 2 14:48:44 1998 Geoffrey Noer <noer@cygnus.com>
-
- * Makefile.in: add ash make rules
- * configure.in: add ash to native_only and host_tools lists
-
-Thu Mar 26 12:53:20 1998 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.in (all-gettext, all-intl): New targets.
- (ALL_MODULES): Added all-gettext, all-intl.
- (CROSS_CHECK_MODULES): Added check-gettext, check-intl.
- (INSTALL_MODULES): Added install-gettext, install-intl.
- (CLEAN_MODULES): Added clean-gettext, clean-intl.
-
- * configure.in (host_tools): Added gettext.
- (native_only): Likewise.
- (noconfigdirs) [various cases]: Likewise.
- (host_libs): Added intl.
-
-Thu Mar 26 15:00:11 1998 Keith Seitz <keiths@onions.cygnus.com>
-
- * configure: Do not disable building gdbtk for cygwin32 hosts.
-
-Wed Mar 25 10:04:18 1998 Nick Clifton <nickc@cygnus.com>
-
- * configure.in: Add thumb-coff target.
- * config.sub: Add thumb-coff target.
-
-Wed Mar 25 11:49:12 1998 Jason Molenda (crash@bugshack.cygnus.com)
-
- * Makefile.in: Revert yesterday's change.
- (all-target-winsup): all-target-librx stays out of here.
-
-Tue Mar 24 16:58:29 1998 Jason Molenda (crash@bugshack.cygnus.com)
-
- * Makefile.in (TARGET_CONFIGDIRS, ALL_TARGET_MODULES,
- CONFIGURE_TARGET_MODULES, CHECK_TARGET_MODULES,
- INSTALL_TARGET_MODULES, CLEAN_TARGET_MODULES, all-target-winsup):
- Remove references to librx and libg++.
-
-Tue Mar 24 18:28:12 1998 Eric Mumpower <nocturne@cygnus.com>
-
- * Makefile.in (BASE_FLAGS_TO_PASS): Pass $(lispdir) down to
- recursive makes
-
-Tue Mar 24 11:37:45 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (CC_FOR_TARGET): Use $(TARGET_SUBDIR) when passing -B
- for newlib directory.
- (CXX_FOR_TARGET): Likewise.
-
-Mon Mar 23 11:30:21 1998 Jeffrey A Law (law@cygnus.com)
-
- * ltconfig: Update after libtool/ltconfig.in change for
- hpux11.
-
-Fri Mar 20 18:51:43 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig, ltmain.sh: Update to libtool 1.2.
-
-Fri Mar 20 09:32:14 1998 Manfred Hollstein <manfred@s-direktnet.de>
-
- * Makefile.in (install-gcc): Don't specify LANGUAGES here.
- (install-gcc-cross): Instead, override LANGUAGES here.
-
-1998-03-18 Dave Love <d.love@dl.ac.uk>
-
- * Makefile.in ($(CONFIGURE_TARGET_MODULES)): Set CONFIG_SITE to a
- non-existent file since /dev/null loses with bash 2.0/autoconf 2.12.
-
-Wed Mar 18 09:24:59 1998 Nick Clifton <nickc@cygnus.com>
-
- * configure.in: Add Thumb-pe target.
-
-Tue Mar 17 16:59:00 1998 Syd Polk <spolk@cygnus.com>
-
- * Makefile.in - changed sn targets to snavigator
- * configure.in - changed sn targets to snavigator
-
-Tue Mar 17 10:33:28 1998 Manfred Hollstein <manfred@s-direktnet.de>
-
- * config-ml.in: After building symlink tree call make distclean
- if a Makefile got linked into ${ml_dir}/${ml_libdir}; this happens
- to be the case for libiberty.
-
-Tue Mar 17 10:22:37 1998 H.J. Lu (hjl@gnu.ai.mit.edu)
-
- * configure: When making link, also check the current
- directory. The configure scripts may create one.
-
-Fri Mar 6 01:02:03 1998 Richard Henderson <rth@cygnus.com>
-
- * config.sub: Accept alphapca56 and alphaev6 properly.
-
-Fri Mar 6 00:14:55 1998 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
-
- * configure.in: Revert 3 Jan change for powerpc-linux-gnulibc1.
-
-Mon Feb 23 15:09:18 1998 Bruno Haible <bruno@linuix.mathematik.uni-karlsruhe.de
-
- * config.sub (sco5): Fix typo.
-
-Mon Feb 23 14:46:06 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (INSTALL_MODULES): Move install-tcl before
- install-itcl.
- (install-itcl): Remove dependency on install-tcl.
-
-Mon Feb 23 09:53:28 1998 Mark Alexander <marka@cygnus.com>
-
- * configure.in: Remove libgloss from noconfigdirs for MN10300.
-
-Thu Feb 19 13:40:41 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Don't build libgui for a cygwin32 target when not on
- a cygwin32 host.
-
-Wed Feb 18 12:29:00 1998 Jason Molenda (crash@bugshack.cygnus.com)
-
- * configure (redirect): Set to null, so default behavior of
- configure is now --verbose.
-
-1998-02-16 Dave Love <d.love@dl.ac.uk>
-
- * Makefile.in ($(CONFIGURE_TARGET_MODULES)): Run configure with
- CONFIG_SITE=/dev/null to forestall lossage with site configuration.
-
-Mon Feb 16 12:23:53 1998 Manfred Hollstein <Manfred.Hollstein@ks.sel.alcatel.de>
-
- * Makefile.in (BASE_FLAGS_TO_PASS, EXTRA_TARGET_FLAGS): Really add
- this change to sync Makefile.in with its ChangeLog entries.
-
-Thu Feb 12 15:03:08 1998 H.J. Lu <hjl@gnu.org>
-
- * ltmain.sh (mkdir): Check that the directory doesn't exist
- before we exit with error, so that we don't get races during
- parallel builds.
-
-Sat Feb 7 15:19:18 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig, ltmain.sh: Update from libtool 1.0i.
-
-Fri Feb 6 01:33:52 1998 Manfred Hollstein <manfred@s-direktnet.de>
-
- * Makefile.in (BASE_FLAGS_TO_PASS): Don't pass PICFLAG and
- PICFLAG_FOR_TARGET.
- (EXTRA_TARGET_FLAGS): Don't pass PICFLAG_FOR_TARGET.
-
- * configure: Emit a definition for the new macro enable_shared
- into each Makefile.
-
- * config/mh-sparcpic (PICFLAG): Define to properly according
- to current multilib configuration.
- * config/mt-sparcpic (PICFLAG_FOR_TARGET): Define to properly
- according to current multilib configuration.
-
-Thu Feb 5 17:01:12 1998 Jason Molenda (crash@bugshack.cygnus.com)
-
- * configure.in (host_tools, native_only): Add libtool.
-
-Wed Feb 4 16:53:58 1998 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: add target-gperf to noconfigdirs for Cygwin32.
- Fix typo in ming config comment.
-
-Wed Feb 4 18:56:13 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * ltconfig, ltmain.sh: Update from libtool 1.0h.
-
-Mon Feb 2 19:38:19 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub: Add tic30 cases, and map c30 to tic30.
-
-Sun Feb 1 02:40:41 1998 Richard Henderson <rth@cygnus.com>
-
- * Makefile.in (TARGET_CONFIGDIRS): Add libf2c.
- (ALL_TARGET_MODULES, CONFIGURE_TARGET_MODULES): Similarly
- (CHECK_TARGET_MODULES, INSTALL_TARGET_MODULES): Similarly
- (CLEAN_TARGET_MODULES): Similarly
- (all-target-libf2c): Add dependences.
- * configure.in (target_libs): Add libf2c.
-
-Fri Jan 30 17:18:32 1998 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: Remove expect from noconfigdirs when target
- is cygwin32. OK to build expect and dejagnu with Canadian
- Cross.
-
-Wed Jan 28 12:58:49 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Do build expect, dejagnu, and cvssrc for a cygwin32
- host.
-
- * config.guess: Use ${UNAME_MACHINE} rather than i386 for cygwin32
- and mingw32.
-
-Wed Jan 28 10:26:37 1998 Manfred Hollstein <manfred@s-direktnet.de>
-
- * Makefile.in (BASE_FLAGS_TO_PASS): Remove passing $(local_prefix)
- here as it is not defined in the toplevel Makefile.
-
-Tue Jan 27 23:25:06 1998 Manfred Hollstein <manfred@s-direktnet.de>
-
- * configure (package_makefile_rules_frag): New variable, which names
- a file with generic rules, ...
- Change comment to mention we now have FIVE parts.
- * configure: Undo last change.
-
-Tue Jan 27 23:15:55 1998 Lassi A. Tuura <lat@iki.fi>
-
- * config.guess: More accurate determination of HP processor types.
- * config.sub: More accurate determination of HP processor types.
-
-Sat Jan 24 01:59:45 1998 Manfred Hollstein <manfred@s-direktnet.de>
-
- * configure (package_makefile_frag): Move inserting the
- ${package_makefile_frag} to where it should be according
- to the comment.
-
-Fri Jan 23 00:29:28 1998 Philip Blundell <pb@nexus.co.uk>
-
- * config.guess: Add support for Linux/ARM.
-
-Thu Jan 22 15:14:01 1998 Fred Fish <fnf@cygnus.com>
-
- * .cvsignore: Remove *-info and *-install since they match
- release-info and mpw-install, which we don't want to just ignore.
-
-Thu Jan 22 01:38:33 1998 Richard Henderson <rth@cygnus.com>
-
- * configure.in: Revert 3 Jan change for alpha-linux-gnulibc1.
-
-Sat Jan 17 21:28:08 1998 Pieter Nagel <pnagel@epiuse.co.za>
-
- * Makefile.in (FLAGS_TO_PASS): Pass down gcc_include_dir and
- local_prefix to sub-make invocations.
-
-Sat Jan 17 21:04:59 1998 H.J. Lu (hjl@gnu.org)
-
- * configure.in: Check makefile fragments in the source
- directory.
-
-Fri Jan 16 00:41:37 1998 Alexandre Oliva <oliva@dcc.unicamp.br>
-
- * configure.in: Check whether host and target makefile
- fragments exist before adding them to *_makefile_frag.
-
-Wed Jan 14 23:39:10 1998 Bob Manson <manson@charmed.cygnus.com>
-
- * configure.in (target_configdirs): Add cygmon for sparc64-elf.
-
-Wed Jan 14 12:48:07 1998 Keith Seitz <keiths@pizza.cygnus.com>
-
- * configure.in: Make sure we only replace RPATH_ENVVAR on
- lines which begin with RPATH_ENVVAR, i.e. add "^" to the
- regexp to sed.
-
- * Makefile.in (BASE_FLAGS_TO_PASS): Pass RRPATH_ENVVAR down
- to sub-makes.
-
-1998-01-13 Lee Iverson (leei@ai.sri.com)
-
- * config-ml.in (multi-do): LDFLAGS must include multilib
- designator.
-
-Tue Jan 13 01:13:24 1998 Robert Lipe (robertl@dgii.com)
-
- * config.guess: Recognize i[3456]-i586-UnixWare7-sysv5.
-
-Sun Jan 4 01:06:55 1998 Mumit Khan <khan@xraylith.wisc.edu>
-
- * config.sub: Add mingw32 support.
- * configure.in: Likewise.
- * config/mh-mingw32: New file.
-
-Sat Jan 3 12:11:05 1998 Franz Sirl <franz.sirl-kernel@lauterbach.com>
-
- * configure.in: Finalize support for {alpha|powerpc}*-*-linux-gnulibc1
-
-Sun Dec 28 11:28:58 1997 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (INSTALL_TARGET): Do install-gcc first.
- * configure (gxx_include_dir): Provide a definition for subdirs
- which do not use autoconf.
-
-Wed Dec 24 22:46:55 1997 Jeffrey A Law (law@cygnus.com)
-
- * config.guess: Sync with egcs. Picks up new alpha support,
- BeOS & some additional linux support.
-
-Tue Dec 23 12:44:24 1997 Jeffrey A Law (law@cygnus.com)
-
- * config.guess: HP 9000/803 is a PA1.1 machine.
-
-Mon Dec 22 02:39:24 1997 Richard Henderson <rth@cygnus.com>
-
- * configure.in: It's alpha*-...
-
-Sun Dec 21 16:53:12 1997 H.J. Lu (hjl@gnu.ai.mit.edu)
-
- * configure.in (host_makefile_frag, target_makefile_frag):
- Handle multiple config files.
- (alpha-*-linux*): Treat alpha-*-linux* as alpha-*-linux* and
- alpha-*-*.
-
-Thu Dec 18 13:13:03 1997 Doug Evans <devans@canuck.cygnus.com>
-
- * mkdep: New file.
-
-Wed Dec 17 09:53:02 1997 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (d30v-*-*): Allow configuring of libide, vmake, etc.
-
-Tue Dec 16 17:36:05 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in: Add libgui directory.
- (GDB_TK): Add all-libgui.
- * configure.in: Add libgui directory.
- * configure: Add all-libgui to GDB_TK.
-
-Mon Dec 15 16:12:28 1997 Nick Clifton <nickc@cygnus.com>
-
- * config-ml.in (multidirs): Add m32r to multilib list.
-
-Fri Dec 12 10:43:31 1997 Brendan Kehoe <brendan@canuck.cygnus.com>
-
- * Makefile.in (all-target-gperf): Change dependency to
- all-target-libstdc++.
-
-Thu Dec 11 23:30:51 1997 Fred Fish <fnf@ninemoons.com>
-
- * config.guess: Add BeOS support.
-
-Wed Dec 10 15:10:38 1997 Ian Lance Taylor <ian@cygnus.com>
-
- Source directory cvs renamed to cvssrc:
- * configure.in (host_tools): Change cvs to cvssrc.
- (native_only): Likewise.
- (noconfigdirs) [various cases]: Likewise.
- * Makefile.in (ALL_MODULES): Change all-cvs to all-cvssrc.
- (CROSS_CHECK_MODULES): Change check-cvs to check-cvssrc.
- (INSTALL_MODULES): Change install-cvs to install-cvssrc.
- (CLEAN_MODULES): Change clean-cvs to clean-cvssrc.
- (all-cvssrc): Rename target from all-cvs.
-
-Wed Dec 3 07:55:59 1997 Jeffrey A Law (law@cygnus.com)
-
- * configure (gxx_include_dir): Fix thinko.
-
-Tue Dec 2 10:55:34 1997 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (INSTALL_TARGET_CROSS): Define.
- (install-cross, install-gcc-cross): New targets.
-
-Tue Dec 2 10:08:31 1997 Nick Clifton <nickc@cygnus.com>
-
- * configure.in (noconfigdirs): Add support for Thumb target.
-
- * config.sub (maybe_os): Add support for Thumb target.
-
-Sun Nov 30 16:12:27 1997 Bob Manson <manson@charmed.cygnus.com>
-
- * Makefile.in: Add rules for cygmon.
-
- * configure.in: Build cygmon for sparc-elf and sparclite-aout.
-
-Thu Nov 27 01:31:30 1997 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (INSTALL_TARGET): Do install-gcc first.
- * configure (gxx_include_dir): Provide a definition for subdirs
- which do not use autoconf.
-
-Wed Nov 26 11:53:33 1997 Keith Seitz <keiths@onions.cygnus.com>
-
- * Makefile.in, configure, configure.in, ChangeLog: merge with foundry's
- 11/18/97 build
-
-Wed Nov 26 16:08:50 1997 Jeffrey A Law (law@cygnus.com)
-
- * From Franz Sirl.
- * config.guess (powerpc*-*-linux): Handle glibc2 beta release
- found on RedHat Linux systems.
-
-Fri Nov 21 09:51:01 1997 Jeffrey A Law (law@cygnus.com)
-
- * config.guess (alpha stuff): Merge with FSF to avoid incorrect
- guesses.
-
-Thu Nov 13 11:38:37 1997 Jeffrey A Law (law@cygnus.com)
-
- * configure.in (i[3456]86-ncr-sysv4.3*): Tweak.
-
-Mon Nov 10 15:23:21 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
-
- * ltmain.sh: If mkdir fails, check whether the directory was created
- anyhow by some other process.
-
-Mon Nov 10 14:38:03 1997 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (d30v-*-*): Configure all directories.
-
-Sun Nov 9 17:36:20 1997 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (d30v-*-*): Configure newlib, libiberty directories
- for the D30V.
-
-Sat Nov 8 14:42:59 1997 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (d30v-*-*): Configure target-libgloss on the D30V.
-
-Fri Nov 7 10:34:09 1997 Rob Savoye <rob@darkstar.cygnus.com>
-
- * include/libiberty.h: Add extern "C" { so it can be used with C++
- progrms.
- * include/remote-sim.h: Add extern "C" { so it can be used with C++
- programs.
-
-Thu Oct 30 11:09:29 1997 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (d30v-*-*): Configure GCC now.
-
-Mon Oct 27 13:17:24 1997 Stan Shebs <shebs@andros.cygnus.com>
-
- * configure.in: Remove a "second pass" of tweaking noconfigdirs,
- is no longer needed.
-
-Mon Oct 27 12:03:53 1997 Jason Merrill <jason@yorick.cygnus.com>
-
- * Makefile.in: check-target-libio depends on all-target-libstdc++.
-
-Sun Oct 26 11:48:27 1997 Manfred Hollstein (manfred@s-direktnet.de)
-
- * Makefile.in (bootstrap-lean): Combined with `normal' bootstrap
- targets using "$@" to provide support for similar but not identical
- targets without having to duplicate code.
-
-Mon Oct 20 15:28:49 1997 Klaus K"ampf <kkaempf@progis.de>
-
- * makefile.vms: Fix to work with DEC C.
-
-Tue Oct 7 23:58:57 1997 Gavin Koch <gavin@cygnus.com>
-
- * config.sub: Add mips-tx39-elf to marketing names.
-
-Tue Oct 7 14:24:41 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * ltmain.sh: Handle symlinks in generated script.
-
-Wed Oct 1 13:11:27 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Handle autoconf style directory options: --bindir,
- --datadir, --includedir, --infodir, --libdir, --libexecdir,
- --mandir, --oldincludedir, --sbindir, --sharedstatedir,
- --sysconfdir.
- * Makefile.in (sbindir, libexecdir, sysconfdir): New variables.
- (sharedstatedir, localstatedir, oldincludedir): New variables.
- (BASE_FLAGS_TO_PASS): Pass down bindir, datadir, includedir,
- infodir, libdir, libexecdir, localstatedir, mandir, oldincludedir,
- sbindir, sharedstatedir, and sysconfdir.
-
-Mon Sep 29 00:38:08 1997 Aaron Jackson <jackson@negril.msrce.howard.edu>
-
- * Makefile.in (bootstrap-lean): New target.
-
-Wed Sep 24 18:06:27 1997 Stu Grossman <grossman@babylon-5.cygnus.com>
-
- * configure.in (d30v): Remove tcl, tk, expect, gdb, itcl, tix, db,
- sn, and gnuserv from noconfigdirs.
-
-Wed Sep 24 15:18:32 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * ltmain.sh: Tweak shell pattern to avoid bug in NetBSD /bin/sh.
-
-Thu Sep 18 23:58:27 1997 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (cross): New target.
-
-Thu Sep 18 21:43:23 1997 Alexandre Oliva <oliva@dcc.unicamp.br>
- Jeff Law <law@cygnus.com>
-
- * Makefile.in (bootstrap2, bootstrap3): New targets.
- (all-bootstrap): Remove outdated and confusing target.
- (bootstrap, bootstrap2, bootstrap3): Don't pass BOOT_CFLAGS down.
-
-Thu Sep 18 15:37:42 1997 Andrew Cagney <cagney@b1.cygnus.com>
-
- * configure (tooldir): enable_gdbtk=YES for cygwin32, NO for
- windows. Consistent with gdb/configure.
-
-1997-09-15 02:37 Ulrich Drepper <drepper@cygnus.com>
-
- * config/mt-linux: Define CXXFLAGS to make sure -fvtable-thunks is
- used.
- * configure.in: Name Linux target fragment.
-
- * configure: Rewrite so that project Makefile fragment is inserted
- first and appears last in the resulting Makefile.
-
-Tue Sep 16 09:55:07 1997 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (install-itcl): Install tcl first.
-
-Sun Sep 14 20:53:42 1997 Geoffrey Noer <noer@cygnus.com>
-
- * config/mh-cygwin32: ok to build split texinfo files
-
-Fri Sep 12 16:19:20 1997 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: remove bison from noconfigdirs for Cygwin32 host
-
-Thu Sep 11 16:40:46 1997 H.J. Lu (hjl@gnu.ai.mit.edu)
-
- * Makefile.in (local-distclean): Also remove mh-frag mt-frag.
-
- * configure.in (skipdirs): Add target-librx for Linux.
- (alpha-*-linux*): Use config/mh-elfalphapic and config/mt-elfalphapic.
-
-Wed Sep 10 21:29:54 1997 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in (bootstrap): New target.
-
-Wed Sep 10 15:19:22 1997 Jeffrey A Law (law@cygnus.com)
-
- * config.sub: Accept 'amigados' for backward compatability.
-
-Mon Sep 8 20:46:20 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * config.guess: Merge with FSF.
-
-Sun Sep 7 23:18:32 1997 Fred Fish <fnf@ninemoons.com>
-
- * config.sub: Change 'amigados' to 'amigaos' to match current usage.
-
-Sun Sep 7 15:55:28 1997 Gavin Koch <gavin@cygnus.com>
-
- * config.sub: Add "marketing-names" patch.
-
-Fri Sep 5 16:11:28 1997 Joel Sherrill (joel@OARcorp.com)
-
- * configure.in (*-*-rtems*): Do not build libgloss for rtems.
-
-Fri Sep 5 12:27:17 1997 Jeffrey A Law (law@cygnus.com)
-
- * config.sub: Handle v850-elf.
-
-Wed Sep 3 22:01:58 1997 Fred Fish <fnf@ninemoons.com>
-
- * .cvsignore (*-install): Remove.
-
-Wed Sep 3 12:15:24 1997 Chris Provenzano <proven@cygnus.com>
-
- * ltconfig: Set CONFIG_SHELL in libtool.
- * ltmain.sh: Use CONFIG_SHELL instead of /bin/sh
-
-Mon Sep 1 16:45:44 1997 Jim Wilson <wilson@cygnus.com>
-
- * configure.in (target_subdir): Set to libraries if enable_multilib.
-
-Wed Aug 27 16:15:11 1997 Jim Wilson <wilson@cygnus.com>
-
- * config.guess: Update from gcc directory.
-
-Tue Aug 26 16:46:46 1997 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (all-sim): Depends on all-readline.
-
-Wed Aug 20 19:57:37 1997 Jason Merrill <jason@yorick.cygnus.com>
-
- * Makefile.in (BISON, YACC): Use $$s.
- (all-bison): Depend on all-texinfo.
-
-Tue Aug 19 01:41:32 1997 Jason Merrill <jason@yorick.cygnus.com>
-
- * Makefile.in (BISON): Add -L flag.
- (YACC): Likewise.
-
-Mon Aug 18 11:30:50 1997 Nick Clifton <nickc@cygnus.com>
-
- * configure.in (noconfigdirs): Add support for v850e target.
-
- * config.sub (maybe_os): Add support for v850e target.
-
-Mon Aug 18 11:30:50 1997 Nick Clifton <nickc@cygnus.com>
-
- * configure.in (noconfigdirs): Add support for v850ea target.
-
- * config.sub (maybe_os): Add support for v850ea target.
-
-Mon Aug 18 09:24:06 1997 Gavin Koch <gavin@cygnus.com>
-
- * config.sub: Add mipstx39. Delete r3900.
-
-Mon Aug 18 17:20:10 1997 Jason Molenda (crash@godzilla.cygnus.co.jp)
-
- * Makefile.in (all-autoconf): Depends on all-texinfo.
-
-Fri Aug 15 23:09:26 1997 Michael Meissner <meissner@cygnus.com>
-
- * config-ml.in ({powerpc,rs6000}*-*-*): Update to current AIX and
- eabi targets.
-
-Thu Aug 14 14:42:17 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Get CFLAGS and CXXFLAGS from Makefile, if possible.
-
- * configure: When handling a Canadian Cross, handle YACC as well as
- BISON. Just set BISON to bison. When setting YACC, prefer bison.
- * Makefile.in (all-bison): Depend upon all-texinfo.
-
-Tue Aug 12 20:09:48 1997 Jason Merrill <jason@yorick.cygnus.com>
-
- * Makefile.in (BISON): bison, not byacc or bison -y.
- (YACC): bison -y or byacc or yacc.
- (various): Add *-bison as appropriate.
- (taz): No need to mess with BISON anymore.
-
-Tue Aug 12 22:33:08 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: If OSTYPE matches *win32*, try to find a good value for
- CONFIG_SHELL.
-
-Sun Aug 10 14:41:11 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (taz): Get the version number from AM_INIT_AUTOMAKE in
- configure.in if it is present.
-
-Sat Aug 9 00:58:01 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (LD_FOR_TARGET): Change ld.new to ld-new.
-
-Fri Aug 8 16:30:13 1997 Doug Evans <dje@canuck.cygnus.com>
-
- * config.sub: Recognize `arc' cpu.
- * configure.in: Likewise.
- * config-ml.in: Likewise.
-
-Thu Aug 7 11:02:34 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in ($(INSTALL_X11_MODULES)): Depend upon installdirs.
-
-Wed Aug 6 16:27:29 1997 Chris Provenzano <proven@cygnus.com>
-
- * configure: Changed sed delimiter from ':' to '|' when
- attempting to substitute ${config_shell} for SHELL. On
- NT ${config_shell} may contain a ':' in it.
-
-Wed Aug 6 12:29:05 1997 Jason Merrill <jason@yorick.cygnus.com>
-
- * Makefile.in (EXTRA_GCC_FLAGS): Fix for non-bash shells.
-
-Wed Aug 6 00:42:35 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (AS_FOR_TARGET): Change as.new to as-new.
-
-Tue Aug 5 14:08:51 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (NM_FOR_TARGET): Change nm.new to nm-new.
-
- * ylwrap: If the program is a relative path, force it to be
- absolute.
-
-Tue Aug 5 12:12:44 1997 Andrew Cagney <cagney@b1.cygnus.com>
-
- * configure (tooldir): Set BISON to `bison -y' and not just bison.
-
-Mon Aug 4 22:59:02 1997 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (CC_FOR_TARGET): When winsup/Makefile present,
- correctly specify the target build directory $(TARGET_SUBDIR)/winsup
- for libraries.
-
-Mon Aug 4 12:40:24 1997 Jason Merrill <jason@yorick.cygnus.com>
-
- * Makefile.in (EXTRA_GCC_FLAGS): Fix handling of macros with values
- separated by spaces.
-
-Thu Jul 31 19:49:49 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * ylwrap: New file.
- * Makefile.in (DEVO_SUPPORT): Add ylwrap.
-
- * ltmain.sh: Handle /bin/sh at start of install program.
-
- * Makefile.in (DEVO_SUPPORT): Add ltconfig, ltmain.sh, and missing.
-
- * ltconfig, ltmain.sh: New files, from libtool 1.0.
- * missing: New file, from automake 1.2.
-
-Thu Jul 24 12:57:56 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in: Treat tix like tk, putting it in X11_MODULES. Add
- check-tk to CHECK_X11_MODULES.
-
-Wed Jul 23 17:03:29 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub: Merge with FSF.
-
-Tue Jul 22 19:08:29 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * config.guess: Merge with FSF.
-
-Tue Jul 22 14:50:42 1997 Robert Hoehne <robert.hoehne@Mathematik.TU-Chemnitz.DE>
-
- * configure: Treat msdosdjgpp like go32.
- * configure.in: Likewise. Don't remove gprof for go32.
-
- * configure: Change Makefile.tem2 to Makefile.tm2.
-
-Mon Jul 21 10:31:26 1997 Stephen Peters <speters@cygnus.com>
-
- * configure.in (noconfigdirs): For alpha-dec-osf*, don't ignore grep.
-
-Tue Jul 15 14:33:03 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * install-sh (chmodcmd): Set to null if the DST directory already
- exists. Same as Nov 11th change.
-
-Mon Jul 14 11:01:15 1997 Martin M. Hunt <hunt@cygnus.com>
-
- * configure (GDB_TK): Needs itcl and tix.
-
-Mon Jul 14 00:32:10 1997 Jason Merrill <jason@yorick.cygnus.com>
-
- * config.guess: Update from FSF.
-
-Fri Jul 11 11:57:11 1997 Martin M. Hunt <hunt@cygnus.com>
-
- * Makefile.in (GDB_TK): Depend on itcl and tix.
-
-Fri Jul 4 13:25:31 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (INSTALL_PROGRAM_ARGS): New variable.
- (INSTALL_PROGRAM): Use $(INSTALL_PROGRAM_ARGS).
- (INSTALL_SCRIPT): New variable.
- (BASE_FLAGS_TO_PASS): Pass down INSTALL_SCRIPT.
- * configure.in: If host is *-*-cygwin32*, set INSTALL_PROGRAM_ARGS
- to -x.
- * install-sh: Add support for -x option.
-
-Mon Jun 30 15:51:30 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in, Makefile.in: Treat tix like itcl.
-
-Thu Jun 26 13:59:19 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (WINDRES): New variable.
- (WINDRES_FOR_TARGET): New variable.
- (BASE_FLAGS_TO_PASS): Add WINDRES_FOR_TARGET.
- (EXTRA_HOST_FLAGS): Add WINDRES.
- (EXTRA_TARGET_FLAGS): Add WINDRES.
- (EXTRA_GCC_FLAGS): Add WINDRES.
- ($(DO_X)): Pass down WINDRES.
- ($(CONFIGURE_TARGET_MODULES)): Set WINDRES when configuring.
- * configure: Treat WINDRES like DLLTOOL, and WINDRES_FOR_TARGET like
- DLLTOOL_FOR_TARGET.
-
-Wed Jun 25 15:01:26 1997 Felix Lee <flee@cygnus.com>
-
- * configure.in: configure sim before gdb for win32-x-ppc
-
-Wed Jun 25 12:18:54 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- Move gperf into the toplevel, from libg++.
- * configure.in (target_tools): Add target-gperf.
- (native_only): Add target-gperf.
- * Makefile.in (all-target-gperf): New target, depend on
- all-target-libg++.
- (configure-target-gperf): Empty rule.
- (ALL_TARGET_MODULES): Add all-target-gperf.
- (CONFIGURE_TARGET_MODULES): Add configure-target-gperf.
- (CHECK_TARGET_MODULES): Add check-target-gperf.
- (INSTALL_TARGET_MODULES): Add install-target-gperf.
- (CLEAN_TARGET_MODULES): Add clean-target-gperf.
-
-Mon Jun 23 10:51:53 1997 Jeffrey A Law (law@cygnus.com)
-
- * config.sub (mn10200): Recognize new basic machine.
-
-Thu Jun 19 14:16:42 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * configure.in: Don't set ENABLE_MULTILIB, so we'll be passing
- --enable-multilib down to subdirs; setting TARGET_SUBDIR was enough.
-
-Tue Jun 17 15:31:20 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * configure.in: If we're building mips-sgi-irix6* native, turn on
- ENABLE_MULTILIB and set TARGET_SUBDIR.
-
-Tue Jun 17 12:20:59 1997 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.in (all-sn): Depend on all-grep.
-
-Mon Jun 16 11:11:10 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Use mh-ppcpic and mt-ppcpic for powerpc*-* targets.
-
- * configure: Set CFLAGS and CXXFLAGS, and substitute them into
- Makefile. From Jeff Makey <jeff@cts.com>.
- * Makefile.in: Add comment for CFLAGS and CXXFLAGS.
-
- * Makefile.in (DISTBISONFILES): Remove.
- (taz): Don't futz with DISTBISONFILES. Change BISON to use
- $(DEFAULT_YACC).
-
- * configure.in: Build itl, db, sn, etc., when building for native
- cygwin32.
-
- * Makefile.in (LD): New variable.
- (EXTRA_HOST_FLAGS): Pass down LD.
- ($(DO_X)): Likewise.
-
-Mon Jun 16 11:10:35 1997 Philip Blundell <Philip.Blundell@pobox.com>
-
- * Makefile.in (INSTALL): Use $(SHELL) when executing install-sh.
-
-Fri Jun 13 10:22:56 1997 Bob Manson <manson@charmed.cygnus.com>
-
- * configure.in (targargs): Strip out any supplied --build argument
- before adding our own. Always add --build.
-
-Thu Jun 12 21:12:28 1997 Bob Manson <manson@charmed.cygnus.com>
-
- * configure.in (targargs): Pass --build if we're doing
- a cross-compile.
-
-Fri Jun 6 21:38:40 1997 Rob Savoye <rob@chinadoll.cygnus.com>
-
- * configure: Use '|' instead of ":" as the separator in
- sed. Otherwise sed chokes on NT path names with drive
- designators. Also look for "?:*" as the leading characters in an
- absolute pathname.
-
-Mon Jun 2 13:05:20 1997 Gavin Koch <gavin@cygnus.com>
-
- * config.sub: Support for r3900.
-
-Wed May 21 17:33:31 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Use install-sh, not install.sh.
-
-Wed May 14 16:06:51 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (taz): Improve check for BISON so it doesn't try to
- apply it twice.
-
-Fri May 9 17:22:05 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (INSTALL_MODULES): Put install-opcodes before
- install-binutils.
-
-Thu May 8 17:29:50 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in: Add automake targets.
- * configure.in (host_tools): Add automake.
-
-Tue May 6 15:49:52 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Default CXX to c++, not gcc.
- * Makefile.in (CXX): Set to c++, not gcc.
- (CXX_FOR_TARGET): When cross, transform c++, not gcc.
-
-Thu May 1 10:11:43 1997 Geoffrey Noer <noer@cygnus.com>
-
- * install-sh: try appending a .exe if source file doesn't
- exist
-
-Wed Apr 30 12:05:36 1997 Jason Merrill <jason@yorick.cygnus.com>
-
- * configure.in: Turn on multilib by default.
- (cross_only): Remove target-libiberty.
-
- * Makefile.in (all-gcc): Don't depend on libiberty.
-
-Mon Apr 28 18:39:45 1997 Michael Snyder <msnyder@cleaver.cygnus.com>
-
- * config.guess: improve algorithm for recognizing Gnu Hurd x86.
-
-Thu Apr 24 19:30:07 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (DEVO_SUPPORT): Add mpw-install.
- (DISTBISONFILES): Add ld/Makefile.in
-
-Tue Apr 22 17:17:28 1997 Geoffrey Noer <noer@pizza.cygnus.com>
-
- * configure.in: if target is cygwin32 but host isn't cygwin32,
- don't configure gdb tcl tk expect, not just gdb.
-
-Mon Apr 21 13:33:39 1997 Tom Tromey <tromey@cygnus.com>
-
- * configure.in: Added gnuserv everywhere sn appears.
-
- * Makefile.in (ALL_MODULES): Added all-gnuserv.
- (CROSS_CHECK_MODULES): Added check-gnuserv.
- (INSTALL_MODULES): Added install-gnuserv.
- (CLEAN_MODULES): Added clean-gnuserv.
- (all-gnuserv): New target.
-
-Thu Apr 17 13:57:06 1997 Per Fogelstrom <pefo@openbsd.org>
-
- * config.guess: Fixes for MIPS OpenBSD systems.
-
-Tue Apr 15 12:21:07 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (INSTALL_XFORM): Remove.
- (BASE_FLAGS_TO_PASS): Remove INSTALL_XFORM.
-
- * mkinstalldirs: New file, copied from automake.
- * Makefile.in (installdirs): Rename from install-dirs. Use
- mkinstalldirs. Change all users.
- (DEVO_SUPPORT): Add mkinstalldirs.
-
-Mon Apr 14 11:21:38 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * install-sh: Rename from install.sh.
- * Makefile.in (INSTALL): Change install.sh to install-sh.
- (DEVO_SUPPORT): Likewise.
-
- * configure: Use ${config_shell} with ${moveifchange}. From Thomas
- Graichen <graichen@rzpd.de>.
-
-Fri Apr 11 16:37:10 1997 Niklas Hallqvist <niklas@appli.se>
-
- * config.guess: Recognize OpenBSD systems correctly.
-
-Fri Apr 11 17:07:04 1997 Jason Molenda (crash@godzilla.cygnus.co.jp)
-
- * README, Makefile.in (ETC_SUPPORT): Remove references to
- cfg-paper*, configure.{texi,man,info*}._
-
-Sun Apr 6 18:47:57 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
-
- * Makefile.in (all.normal): Ensure that gcc is built after all
- the x11 - ie gdb - targets.
-
-Tue Apr 1 16:28:50 1997 Klaus Kaempf <kkaempf@progis.de>
-
- * makefile.vms: Don't run conf-a-gas.
-
-Mon Mar 31 16:26:55 1997 Joel Sherrill <joel@oarcorp.com>
-
- * configure.in (hppa1.1-*-rtems*): New target, like hppa-*-*elf*.
-
-Sun Mar 30 12:38:27 1997 Fred Fish <fnf@cygnus.com>
-
- * configure.in: Remove noconfigdirs case since gdb also
- configures and builds for tic80-coff.
-
-Fri Mar 28 18:28:52 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Set cache_file to config.cache.
- * Makefile.in (local-distclean): Remove config.cache.
-
-Wed Mar 26 18:49:39 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * COPYING: Update FSF address.
-
-Wed Mar 26 10:38:25 1997 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (tic80-*-*): Remove G++ libraries and libgloss from
- noconfigdirs.
-
-Mon Mar 24 15:02:39 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (install-dirs): Don't crash if prefix, and hence
- MAKEDIRS, is empty.
-
-Mon Mar 24 12:40:55 1997 Doug Evans <dje@canuck.cygnus.com>
-
- * config.sub: Tweak mn10300 entry.
-
-Fri Mar 21 15:35:27 1997 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (host_tools): Put sim before gdb, so gdb's
- configure.tgt can determine if the simulator was configured.
-
-Sun Mar 16 16:07:08 1997 Fred Fish <fnf@cygnus.com>
-
- * config.sub: Move BeOS $os case to be with other Cygnus
- local cases.
-
-Sun Mar 16 01:34:55 1997 Martin Hunt <hunt@cygnus.com>
-
- * config.sub: Remove misplaced comment that broke Linux.
-
-Sat Mar 15 22:50:15 1997 Fred Fish <fnf@cygnus.com>
-
- * config.sub: Add BeOS support.
-
-Mon Mar 10 13:30:11 1997 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.in (CHECK_X11_MODULES): Don't run check-tk.
-
-Wed Mar 5 12:09:29 1997 Martin <hunt@cygnus.com>
-
- * configure.in (noconfigdirs): Remove tcl and tk from
- noconfigdirs for cygwin32 builds.
-
-Fri Feb 28 18:20:15 1997 Fred Fish <fnf@cygnus.com>
-
- * configure.in (tic80-*-*): Remove ld from noconfigdirs.
-
-Thu Feb 27 14:57:26 1997 Ken Raeburn <raeburn@cygnus.com>
-
- * Makefile.in (GAS_SUPPORT_DIRS, BINUTILS_SUPPORT_DIRS): Remove
- make-all.com, use makefile.vms instead.
-
-Tue Feb 25 18:46:14 1997 Stan Shebs <shebs@andros.cygnus.com>
-
- * config.sub: Accept -lnews*.
-
-Tue Feb 25 13:19:14 1997 Andrew Cagney <cagney@kremvax.tpgi.com.au>
-
- * configure.in (noconfigdirs): Disable target-newlib,
- target-examples and target-libiberty for d30v.
-
-Fri Feb 21 17:56:25 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
-
- * configure.in (noconfigdirs): Enable ld for d30v.
-
-Fri Feb 21 20:58:51 1997 Michael Meissner <meissner@cygnus.com>
-
- * configure.in (tic80-*-*): Build compiler.
-
-Sun Feb 16 15:41:09 1997 Andrew Cagney <cagney@critters.cygnus.com>
-
- * configure.in (d30v-*): Remove sim directory from list of
- unsupported d30v directories
-
-Tue Feb 18 17:32:42 1997 Martin M. Hunt <hunt@pizza.cygnus.com>
-
- * config.sub, configure.in: Add d30v target cpu.
-
-Thu Feb 13 22:04:44 1997 Klaus Kaempf <kkaempf@progis.de>
-
- * makefile.vms: New file.
- * make-all.com: Remove.
-
-Wed Feb 12 12:54:18 1997 Jim Wilson <wilson@cygnus.com>
-
- * Makefile.in (EXTRA_GCC_FLAGS): Add LIBGCC2_DEBUG_CFLAGS.
-
-Sat Feb 8 20:36:49 1997 Michael Meissner <meissner@cygnus.com>
-
- * Makefile.in (all-itcl): The rule is all-itcl, not all-tcl.
-
-Tue Feb 4 11:39:29 1997 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.in (ALL_MODULES): Added all-db.
- (CROSS_CHECK_MODULES): Addec check-db.
- (INSTALL_MODULES): Added install-db.
- (CLEAN_MODULES): Added clean-db.
-
-Mon Feb 3 13:29:36 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * config.guess: Merge with latest FSF sources.
-
-Tue Jan 28 09:20:37 1997 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.in (ALL_MODULES): Added all-itcl.
- (CROSS_CHECK_MODULES): Added check-itcl.
- (INSTALL_MODULES): Added install-itcl.
- (CLEAN_MODULES): Added clean-itcl.
-
-Thu Jan 23 01:44:27 1997 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: build gdb for mn10200
-
-Fri Jan 17 15:32:15 1997 Doug Evans <dje@canuck.cygnus.com>
-
- * Makefile.in (all-target-winsup): Depend on all-target-libio.
-
-Mon Jan 13 22:46:54 1997 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (tic80-*-*): Turn off most targets right now.
-
-Fri Jan 3 16:04:03 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (MAKEINFO): Check for the existence of the Makefile,
- rather than the makeinfo program.
- (do-info): Depend upon all-texinfo.
-
-Tue Dec 31 16:00:31 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Remove uses of config/mh-linux.
-
- * config.sub, config.guess: Merge with latest FSF sources.
-
-Fri Dec 27 23:04:33 1996 Fred Fish <fnf@cygnus.com>
-
- * config.sub (case $basic_machine): Add tic80 entries.
-
-Fri Dec 27 12:07:59 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub, config.guess: Merge with latest FSF sources.
-
-Wed Dec 18 22:46:39 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-build.in: Build ld before gcc, use NewFolderRecursive.
- * mpw-config.in: Test for NewFolderRecursive.
- * mpw-install: Use symbolic name for startup filename.
- * mpw-README: Add various additional details.
-
-Wed Dec 18 13:11:46 1996 Jim Wilson <wilson@cygnus.com>
-
- * configure.in (mips*-sgi-irix6*): Remove binutils from noconfigdirs.
-
-Wed Dec 18 10:29:31 1996 Jeffrey A Law (law@cygnus.com)
-
- * configure.in: Do build gcc and the target libraries for
- the mn10200.
-
-Wed Dec 4 16:53:05 1996 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: don't avoid building gdb for mn10300 any more
- * Makefile.in: double-quote GCC_FOR_TARGET line in EXTRA_GCC_FLAGS
- instead of single-quoting it.
-
-Tue Dec 3 23:26:50 1996 Jason Merrill <jason@yorick.cygnus.com>
-
- * configure.in: Don't use --with-stabs on IRIX 6.
-
-Tue Dec 3 09:05:25 1996 Doug Evans <dje@canuck.cygnus.com>
-
- * configure.in (m32r): Build gdb, libg++ now.
-
-Sun Dec 1 00:18:59 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * configure.in (mips*-sgi-irix6*): Remove gdb and related
- directories from noconfigdirs.
-
-Tue Nov 26 11:45:33 1996 Kim Knuttila <krk@cygnus.com>
-
- * config.sub (basic_machine): added mips16 configuration
-
-Sat Nov 23 19:26:22 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config.sub: Handle d10v-unknown.
-
-Sat Nov 23 10:23:01 1996 Gavin Koch <gavin@cygnus.com>
-
- * config.sub: Handle v850-unknown.
-
-Thu Nov 21 16:19:44 1996 Geoffrey Noer <noer@cygnus.com>
-
- * Makefile.in: add findutils
- * configure.in: add findutils to list of host_tools
-
-Wed Nov 20 10:09:01 1996 Jeffrey A Law (law@cygnus.com)
-
- * config.sub: Handle mn10200 and mn10300.
-
-Tue Nov 19 16:35:14 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (d10v-*): Do not build librx.
-
-Mon Nov 18 13:28:41 1996 Jeffrey A Law (law@cygnus.com)
-
- * configure.in (mn10300): Build everything except gdb & libgloss.
-
-Wed Nov 13 14:59:46 1996 Per Bothner <bothner@deneb.cygnus.com>
-
- * config.guess: Patch for Dansk Data Elektronik servers,
- from Niels Skou Olsen <nso@dde.dk>.
-
- For ncr, use /bin/uname rather than uname, since GNU uname does not
- support -p. Suggested by Mark Mitchell <mmitchell@usa.net>.
-
- Patch for MIPS R4000 running System V,
- from Eric S. Raymond <esr@snark.thyrsus.com>.
-
- Fix thinko for nextstep.
-
- Patch for OSF1 in i?86, from Dan Murphy <dlm@osf.org> via Harlan Stenn.
-
- Sat Jun 24 18:58:17 1995 Morten Welinder <terra+@cs.cmu.edu>
- * config.guess: Guess mips-dec-mach_bsd4.3.
-
- Thu Oct 10 04:07:04 1996 Harlan Stenn <harlan@pfcs.com>
- * config.guess (i?86-ncr-sysv*): Emit just enough of the minor
- release numbers.
- * config.guess (mips-mips-riscos*): Emit just enough of the
- release number.
-
- Tue Oct 8 10:37:22 1996 Frank Vance <fvance@waii.com>
- * config.guess (sparc-auspex-sunos*): Added.
- (f300-fujitsu-*): Added.
-
- Wed Sep 25 22:00:35 1996 Jeff Woolsey <woolsey@jlw.com>
- * config.guess: Recognize a Tadpole as a sparc.
-
-Wed Nov 13 00:53:09 1996 David J. MacKenzie <djm@churchy.gnu.ai.mit.edu>
-
- * config.guess: Don't assume that NextStep version is either 2 or
- 3. NextStep 4 (aka OpenStep 4) has come out now.
-
-Mon Nov 11 23:52:03 1996 David J. MacKenzie <djm@churchy.gnu.ai.mit.edu>
-
- * config.guess: Support Cray T90 that reports itself as "CRAY TS".
- From Rik Faith <faith@cs.unc.edu>.
-
-Fri Nov 8 11:34:58 1996 David J. MacKenzie <djm@geech.gnu.ai.mit.edu>
-
- * config.sub: Contributions from bug-gnu-utils to:
- Support plain "hppa" (no version given) architecture, reported by
- OpenStep.
- OpenBSD like NetBSD.
- LynxOs is not a hardware supplier.
-
- * config.guess: Contributions from bug-gnu-utils to add support for:
- OpenBSD like NetBSD.
- Stratus systems.
- More Pyramid systems.
- i[n>4]86 Intel chips.
- M680[n>4]0 Motorola chips.
- Use unknown instead of lynx for hardware manufacturer.
-
-Mon Nov 11 10:09:08 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * install.sh (chmodcmd): Set to null if the DST directory already
- exists.
-
-Mon Nov 11 10:43:41 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (powerpc*-{eabi,elf,linux,rtem,sysv,solaris}*): Do
- not use mt-ppc target Makefile fragment any more.
-
-Sun Nov 3 19:17:07 1996 Stu Grossman (grossman@critters.cygnus.com)
-
- * configure.in (*-*-windows): Exclude everything but those dirs
- needed to build windows.
-
-Tue Oct 29 16:41:31 1996 Doug Evans <dje@canuck.cygnus.com>
-
- * Makefile.in (all-target-winsup): Depend on all-target-librx.
-
-Mon Oct 28 17:32:46 1996 Stu Grossman (grossman@critters.cygnus.com)
-
- * configure.in: Exclude mmalloc from i386-windows.
- * config/mh-windows: Add rules for building MSVC makefiles.
-
-Thu Oct 24 09:22:46 1996 Stu Grossman (grossman@critters.cygnus.com)
-
- * Undo my previous change.
-
-Thu Oct 24 12:12:04 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (EXTRA_GCC_FLAGS): Pass down GCC_FOR_TARGET
- unconditionally.
- (MAKEOVERRIDES): Define (revert this part of October 18 change).
-
-Thu Oct 24 09:02:07 1996 Stu Grossman (grossman@critters.cygnus.com)
-
- * Makefile.in (FLAGS_TO_PASS): Add $(HOST_FLAGS) to allow the
- host to add it's own flags.
- * config/mh-windows (HOST_FLAGS): Set srcroot, which is needed
- for MSVC build procedure.
-
-Tue Oct 22 15:20:26 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Handle GCC_FOR_TARGET like CC_FOR_TARGET.
-
-Fri Oct 18 13:37:13 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (CC_FOR_TARGET): Check for xgcc, not Makefile.
- (CXX_FOR_TARGET): Likewise.
- (GCC_FOR_TARGET): Define.
- (BASE_FLAGS_TO_PASS): Remove GCC_FOR_TARGET.
- (EXTRA_GCC_FLAGS): Define GCC_FOR_TARGET based on whether
- CC_FOR_TARGET was specified on the command line.
- (MAKEOVERRIDES): Don't define.
-
-Thu Oct 17 10:27:56 1996 Doug Evans <dje@canuck.cygnus.com>
-
- * configure.in (m32r): Fix spelling of libg++ libs.
-
-Thu Oct 10 10:37:17 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * config.sub (-apple*): Remove, now redundant.
-
-Thu Oct 10 12:30:54 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Don't get confused by CPU-VENDOR-linux-gnu.
-
- * configure: Rework yesterday's sed script patch.
-
- * config.sub: Merge with FSF.
-
-Wed Oct 9 17:24:59 1996 Per Bothner <bothner@deneb.cygnus.com>
-
- * config.guess: Merge from FSF.
-
- 1996-09-12 Richard Stallman <rms@ethanol.gnu.ai.mit.edu>
- * config.guess: Use pc instead of unknown, for pc clone systems.
- Change linux to linux-gnu.
-
- Mon Jul 15 23:51:11 1996 Karl Heuer <kwzh@gnu.ai.mit.edu>
- * config.guess: Avoid non-portable tr syntax.
-
-Wed Oct 9 06:06:46 1996 Jeffrey A Law (law@cygnus.com)
-
- * test-build.mk (HOLES): Add "xargs" for gdb.
-
- * configure: Avoid hpux10.20 sed bug.
-
-Tue Oct 8 08:32:48 1996 Stu Grossman (grossman@critters.cygnus.com)
-
- * configure.in config/mh-windows: Add support for windows host
- (that is a build done under the Microsoft build environment).
-
-Tue Oct 8 10:39:08 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in: Replace all uses of srcroot with s, to shrink
- command line lengths.
-
- Patches from Geoffrey Noer <noer@cygnus.com>:
- * configure.in: If configuring for newlib, pass --with-newlib to
- subdirectories.
- * Makefile.in (CC_FOR_TARGET): If winsup/Makefile exists, pass a
- -Bnewlib/ and -Lwinsup to gcc.
- (CXX_FOR_TARGET): Likewise.
-
-Mon Oct 7 10:59:35 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (ETC_SUPPORT): Add configure.
-
-Fri Oct 4 12:22:58 1996 Angela Marie Thomas (angela@cygnus.com)
-
- * configure.in: Use config/mh-dgux386 for i[345]86-dg-dgux
- host configuration file.
-
-Thu Oct 3 09:28:25 1996 Jeffrey A Law (law@cygnus.com)
-
- * configure.in: Break mn10x00 support into separate
- mn10200 and mn10300 configurations.
- * config.sub: Likewise.
-
-Wed Oct 2 22:27:52 1996 Jeffrey A Law (law@cygnus.com)
-
- * configure.in: Add lots of stuff to noconfigdirs for
- the mn10x00 targets.
-
- * config.sub, configure.in: Add mn10x00 support.
-
-Wed Oct 2 15:52:36 1996 Klaus Kaempf <kkaempf@progis.de>
-
- * make-all.com: Call conf-a-gas, not config-a-gas.
-
-Tue Oct 1 01:28:41 1996 James G. Smith <jsmith@cygnus.co.uk>
-
- * configure.in (noconfigdirs): Don't build libgloss for arm-coff
- targets.
-
-Mon Sep 30 14:24:01 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-README: Add much more detail for native PowerMac.
- * mpw-install: New file.
- * mpw-configure: Add --norecursion and --help options.
- * mpw-config.in: Translate readme and install files when
- copying to objdir.
- * mpw-build.in: Don't always depend on byacc and flex.
- (install-only-top): New action.
-
-Fri Sep 27 17:39:44 1996 Stu Grossman (grossman@critters.cygnus.com)
-
- * configure.in: You can now configure GDB for the v850.
-
-Tue Sep 24 19:05:12 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * configure.in (noconfigdirs): Don't configure any C++ dirs
- if targeting D10V.
-
-Tue Sep 17 12:15:31 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub: Recognize mips64vr5000.
-
-Mon Sep 16 17:00:52 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Use a single line for host_tools and native_only.
-
-Tue Sep 16 09:55:07 1997 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (install-itcl): Install tcl first.
-
-Sun Sep 14 20:53:42 1997 Geoffrey Noer <noer@cygnus.com>
-
- * config/mh-cygwin32: ok to build split texinfo files
-
-Fri Sep 12 16:19:20 1997 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: remove bison from noconfigdirs for Cygwin32 host
-
-Mon Sep 9 12:21:30 1996 Doug Evans <dje@canuck.cygnus.com>
-
- * config.sub, configure.in: Add entries for m32r.
-
-Mon Sep 8 20:46:20 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * config.guess: Merge with FSF.
-
-Thu Sep 5 13:52:47 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (inet-install): Don't run install-gzip.
-
-Wed Sep 4 17:26:13 1996 Stu Grossman (grossman@critters.cygnus.com)
-
- * configure.in: Don't config lots of things for *-*-windows*.
-
-Sat Aug 31 11:45:57 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-config.in: Test for mpw-true, true, and null-command scripts.
- (host_libs, host_tools): Copy from configure.in.
- * mpw-configure: Don't complain about directories not found.
-
-Thu Aug 29 16:44:58 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (i[345]86): Recognize i686 for pentium pro.
- (i[3456]86-*-dgux*): Use config/mh-sysv for the host configuration
- file.
-
- * config.guess (i[345]86): Ditto.
-
-Mon Aug 26 18:34:42 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
-
- * configure.in (noconfigdirs): Removed gdb for D10V.
-
-Thu Aug 22 17:13:52 1996 Jeffrey A Law (law@cygnus.com)
-
- * configure.in: Remove ld, target-libio, target-libg++, and
- target-libstdc++ from noconfigdirs.
-
-Wed Aug 21 18:56:38 1996 Fred Fish <fnf@cygnus.com>
-
- * configure: Fix three locations where shell scripts were
- being run directly rather than with config_shell.
-
-Tue Aug 20 13:08:47 1996 J.T. Conklin <jtc@hippo.cygnus.com>
-
- * configure.in (v850-*-*): Set up initial $noconfigdirs.
- * config.sub (basic_machine): Recognize v850.
-
-Thu Aug 15 12:19:33 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-configure: Handle multiple enable/disable options and
- pass them down recursively, handle -c and -s flags appropriately
- depending on choice of compiler, add escape mechanism for
- quoted arguments to gC.
-
-Mon Aug 12 13:15:13 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (powerpc*-*-*): For eabi, system V.4, Linux, and
- solaris targets, use config/mt-ppc to set C{,XX}FLAGS_FOR_TARGETS
- so that -mrelocatable-lib and -mno-eabi are used.
-
- * Makefile.in (CONFIGURE_TARGET_MODULES): If target compiler does
- not support --print-multi-lib, don't abort.
-
-Sun Aug 11 20:51:50 1996 Stu Grossman (grossman@critters.cygnus.com)
-
- * config/mh-cygwin32 (CFLAGS): Define _WIN32 to be compatible
- with normal Windows compilation environment.
-
-Thu Aug 8 12:18:59 1996 Klaus Kaempf <kkaempf@progis.de>
-
- * make-all.com: Run config-a-gas.
- * setup.com: Don't copy subdirectory files around.
-
-Tue Jul 30 17:49:31 1996 Brendan Kehoe <brendan@cygnus.com>
-
- * configure.in (*-*-ose): Remove exclusion of libgloss for this
- target, it now compiles correctly.
-
-Sat Jul 27 15:10:43 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-config.in: Generate Mac include for elf/dwarf2.h.
-
-Tue Jul 23 10:47:04 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
-
- * configure.in (d10v-*-*): Remove ld from $noconfigdirs.
-
-Mon Jul 22 13:28:51 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * configure.in (native_only): Add prms.
-
-Mon Jul 22 12:27:58 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (GAS_SUPPORT_DIRS): Add make-all.com and setup.com.
- (BINUTILS_SUPPORT_DIRS): Likewise.
-
-Thu Jul 18 12:55:40 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (d10v-*-*): Don't configure ld or gdb until the
- d10v support is added.
-
-Wed Jul 17 14:33:09 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
-
- * configure.in (d10v-*-*): New target.
-
-Mon Jul 15 11:53:00 1996 Jeffrey A Law (law@cygnus.com)
-
- * config.guess (HP 9000/811): Recognize this as a PA1.1
- machine.
-
-Fri Jul 12 23:21:17 1996 Ken Raeburn <raeburn@cygnus.com>
-
- * Makefile.in (do-tar-gz): New target, split out from tail end of
- taz target. Run each command separately, don't use pipes.
- (taz): Use it.
-
-Fri Jul 12 12:08:04 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-configure: Look for g-mpw-make.sed in config/mpw.
- * mpw-build.in: No builds should depend on building byacc or flex,
- they are assumed to be installed already.
-
-Fri Jul 12 09:52:52 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * Makefile.in (CONFIGURE_TARGET_MODULES): Set r environment
- variable that CC_FOR_TARGET needs.
-
-Thu Jul 11 10:09:45 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * Makefile.in (CONFIGURE_TARGET_MODULES): Determine if the multlib
- options have changed since the last time the subdirectory was
- configured, and if it has, reconfigure.
- (CLEAN_TARGET_MODULES): Delete multilib.out and tmpmulti.out, which
- CONFIGURE_TARGET_MODULES uses to remember the old multilib options.
-
-Wed Jul 10 18:56:59 1996 Doug Evans <dje@canuck.cygnus.com>
-
- * Makefile.in (ALL_MODULES,CROSS_CHECK_MODULES,INSTALL_MODULES,
- CLEAN_MODULES): Add bash.
- (all-bash): New target.
-
-Mon Jul 8 17:33:14 1996 Jim Wilson <wilson@cygnus.com>
-
- * configure.in (mips-sgi-irix6*): Use mh-irix6 instead of mh-irix5.
-
-Mon Jul 1 13:31:35 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config.sub (basic_machine): Recognize d10v as a valid processor.
-
-Fri Jun 28 12:14:35 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-configure: Add support for --bindir.
- * mpw-build.in: Use a GCC-specific build script for GCC actions.
-
-Wed Jun 26 17:20:12 1996 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: add bash, time, gawk to list of hosttools and things
- to only build for native toolchains
-
-Tue Jun 25 23:09:03 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
-
- * Makefile.in (docdir): Remove.
-
-Tue Jun 25 19:00:08 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
-
- * Makefile.in (datadir): Set to $(prefix)/share.
-
-Mon Jun 24 23:26:07 1996 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: build diff and patch for cygwin32-hosted
- toolchains.
-
-Mon Jun 24 15:01:12 1996 Joel Sherrill <joel@merlin.gcs.redstone.army.mil>
-
- * config.sub: Accept -rtems*.
-
-Sun Jun 23 22:41:54 1996 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: enable dosrel for cygwin32-hosted builds,
- remove diff from the list of things not buildable
- via Canadian Cross
-
-Sat Jun 22 11:39:01 1996 Jason Merrill <jason@yorick.cygnus.com>
-
- * Makefile.in (TARGET_SUBDIR): Move comment to previous line so we
- don't get ". ".
-
-Fri Jun 21 17:24:48 1996 Jim Wilson <wilson@cygnus.com>
-
- * configure.in (mips*-sgi-irix6*): Set noconfigdirs appropriately.
-
-Thu Jun 20 16:57:40 1996 Ken Raeburn <raeburn@cygnus.com>
-
- * Makefile.in (taz): Handle case where tex3patch didn't even get
- checked out. Also, if it was found, put the symlink in a new util
- subdirectory.
-
-Thu Jun 20 12:20:33 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config.guess (*:Linux:*:*): Add support for PowerPC Linux.
-
-Tue Jun 18 14:24:12 1996 Klaus Kaempf (kkaempf@progis.de)
-
- * config.sub: Recognize -openvms.
- * configure.in (alpha*-*-*vms*): Set noconfigdirs.
- * make-all.com, setup.com: New files.
-
-Mon Jun 17 16:34:46 1996 Jason Merrill <jason@yorick.cygnus.com>
-
- * Makefile.in (taz): tex3patch moved to texinfo/util.
-
-Sat Jun 15 17:13:25 1996 Geoffrey Noer <noer@cygnus.com>
-
- * configure: enable_gdbtk=no for cygwin32-hosted toolchains
- * configure.in: remove make from disable-if-Can-Cross list
- enable gdb if ${host} and ${target} are cygwin32
-
-Fri Jun 7 18:16:52 1996 Harlan Stenn <harlan@pfcs.com>
-
- * config.guess (i?86-ncr-sysv*): Emit minor release numbers.
- Recognize the NCR 4850 machine and NCR Pentium-based platforms.
-
-Wed Jun 5 00:09:17 1996 Per Bothner <bothner@wombat.gnu.ai.mit.edu>
-
- * config.guess: Combine mips-mips-riscos cases, and use cpp to
- distinguish sysv/svr4/bsd variants.
- Based on a patch from Harlan Stenn <harlan@pfcs.com>.
-
-Fri Jun 7 14:24:49 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * configure.in: Added copyright notice.
- * move-if-change: Added copyright notice.
-
-Thu Jun 6 16:27:05 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (powerpcle-*-solaris*): Until we get shared
- libraries working, don't build gdb, sim, make, tcl, tk, or
- expect.
-
-Tue Jun 4 20:41:45 1996 Per Bothner <bothner@deneb.cygnus.com>
-
- * config.guess: Merge with FSF:
-
- Mon Jun 3 08:49:14 1996 Karl Heuer <kwzh@gnu.ai.mit.edu>
- * config.guess (*:Linux:*:*): Add guess for sparc-unknown-linux.
-
- Fri May 24 18:34:53 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
- * config.guess (AViiON:dgux:*:*): Fix typo in recognizing mc88110.
-
- Fri Apr 12 20:03:59 1996 Per Bothner <bothner@spiff.gnu.ai.mit.edu>
- * config.guess: Combine two OSF1 rules.
- Also recognize field test versions. From mjr@zk3.dec.com.
- * config.guess (dgux): Use /usr/bin/uname rather than uname,
- because GNU uname does not support -p. From pmr@pajato.com.
-
-Tue Jun 4 11:07:25 1996 Tom Tromey <tromey@csk3.cygnus.com>
-
- * Makefile.in (MAKEDIRS): Removed $(tooldir).
-
-Tue May 28 12:30:50 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-README: Document GCCIncludes.
-
-Sun May 26 15:16:27 1996 Fred Fish <fnf@cygnus.com>
-
- * configure.in (alpha-*-linux*): Set enable_shared to yes.
-
-Tue May 21 15:41:39 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-configure: Handle --enable-FOO and --disable-FOO.
-
-Mon May 20 10:12:29 1996 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in (*-*-cygwin32): Configure make.
-
-Tue May 7 14:19:42 1996 Tom Tromey <tromey@snuffle.cygnus.com>
-
- * Makefile.in (inet-install): Quote value of INSTALL_MODULES.
-
-Fri May 3 08:57:17 1996 Tom Tromey <tromey@lisa.cygnus.com>
-
- * Makefile.in (all-inet): Depend on all-perl.
-
- * Makefile.in (inet-install): New target.
-
- * Makefile.in (all-inet): Depend on all-tcl.
- (all-inet): Depend on all-send-pr.
-
-Tue Apr 30 13:55:51 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (powerpcle-*-solaris*): Turn off tk and tcl
- temporarily.
-
-Thu Apr 25 11:48:20 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Don't configure --with-gnu-ld on AIX.
-
-Thu Apr 25 06:33:36 1996 Michael Meissner <meissner@wogglebug.tiac.net>
-
- * configure.in (powerpcle-*-solaris*): Turn off gdb temporarily.
-
-Tue Apr 23 09:07:39 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (ALL_MODULES): Added all-inet.
- (CROSS_CHECK_MODULES): Added check-inet.
- (INSTALL_MODULES): Added install-inet.
- (CLEAN_MODULES): Added clean-inet.
- (all-indent): New target.
-
- * configure.in (host_tools): Added inet.
- (native_only): Added inet.
- (noconfigdirs): Added inet.
-
-Fri Apr 19 15:35:29 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Don't configure libgloss if we are not configuring
- newlib.
-
-Wed Apr 17 19:30:01 1996 Rob Savoye <rob@chinadoll.cygnus.com>
-
- * configure.in: Don't configure libgloss for unsupported
- architectures.
-
-Tue Apr 16 11:17:05 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * Makefile.in (CLEAN_MODULES): Add clean-apache.
-
-Mon Apr 15 15:09:05 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (ALL_MODULES): Include all-apache.
- (CROSS_CHECK_MODULES): Include check-apache.
- (INSTALL_MODULES): Include install-apache.
- (all-apache): New target.
-
- * configure.in: Added apache everywhere perl is seen.
-
-Mon Apr 15 14:59:13 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * Makefile.in: Add support for clean-{module} and
- clean-target-{module} rules.
-
-Wed Apr 10 21:37:41 PDT 1996 Marilyn E. Sander <msander@cygnus.com>
-
- * configure.in (*-*-ose) do not build libgloss.
-
-Mon Apr 8 16:16:20 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config.guess (prep*:SunOS:5.*:*): Turn into
- powerpele-unknown-solaris2.
-
-Mon Apr 8 14:45:41 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Permit --enable-shared to specify a list of
- directories.
-
-Fri Apr 5 08:17:57 1996 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (host==solaris): Pass only the first word of $CC
- to /usr/bin/which when checking if we're using /usr/ccs/bin/cc.
-
-Fri Apr 5 03:16:13 1996 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * Makefile.in (BASE_FLAGS_TO_PASS): pass down $(MAKE).
-
-Thu Mar 28 14:11:11 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (ALL_MODULES): Include all-perl.
- (CROSS_CHECK_MODULES): Include check-perl.
- (INSTALL_MODULES): Include install-perl.
- (ALL_X11_MODULES): Include all-guile.
- (CHECK_X11_MODULES): Include check-guile.
- (INSTALL_X11_MODULES): Include install-guile.
- (all-perl): New target.
- (all-guile): New target.
-
- * configure.in (host_tools): Include perl and guile.
- (native_only): Include perl and guile.
- (noconfigdirs): Don't build guile and perl; no ports have been
- done.
-
-Tue Mar 26 21:18:50 1996 Andrew Cagney <cagney@kremvax.highland.com.au>
-
- * configure (--enable-*): Handle quoted option lists such as
- --enable-sim-cflags='-g0 -O' better.
-
-Thu Mar 21 11:53:08 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * Makefile.in ({,inst}all-target): New rule so we can make and
- install all of the target directories easily.
-
-Wed Mar 20 18:10:57 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
-
- * configure.in: Add missing global flag in sed substitution when
- deleting `target-' from ${configdirs}.
-
-Thu Mar 14 19:15:06 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (DO_X): Don't get confused if CC contains `=' in an
- option.
-
- * configure.in (mips*-nec-sysvr4*): Use a host_makefile_frag of
- config/mh-necv4.
-
- * install.sh: Correct misspelling of transformbasename.
-
- * config.guess: Recognize mips-*-sysv*.
-
-Mon Mar 11 15:36:42 1996 Dawn Perchik <dawn@critters.cygnus.com>
-
- * config.sub: Recognize mon960.
-
-Sun Mar 10 13:18:38 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Restore Canadian Cross handling of BISON and LEX,
- removed in Feb 20 change.
-
-Fri Mar 8 20:07:09 1996 Per Bothner <bothner@kalessin.cygnus.com>
-
- * README: Suggestions from Torbjorn Granlund <tege@matematik.su.se>:
- Mention make install. Remove the old copyright date as well the
- clumsy and rather pointless copyright on the README file.
-
-Fri Mar 8 17:51:35 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in ($(CONFIGURE_TARGET_MODULES)): If there is a
- Makefile after running symlink-tree, then run `make distclean' to
- avoid clobbering any generated files in srcdir.
-
-Tue Mar 5 08:21:44 1996 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in (m68k-*-netbsd*): Build everything now.
-
-Wed Feb 28 12:25:46 1996 Jason Merrill <jason@yorick.cygnus.com>
-
- * Makefile.in (taz): Fix quoting.
-
-Tue Feb 27 11:33:57 1996 Doug Evans <dje@charmed.cygnus.com>
-
- * configure.in (sparclet-*-*): Build everything now.
-
-Tue Feb 27 14:31:51 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
-
- * configure.in (m68k-*-linux*): New host.
-
-Mon Feb 26 14:32:44 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Check for bison before byacc.
-
-Tue Feb 20 23:12:35 1996 Stu Grossman (grossman@critters.cygnus.com)
-
- * Makefile.in configure: Change the way LEX and BISON/YACC are
- set. configure now defines DEFAULT_LEX and DEFAULT_YACC by
- searching PATH. These are used as fallbacks by Makefile.in if
- flex/bison/byacc aren't in objdir.
-
-Mon Feb 19 11:45:30 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in: Make everything which depends upon all-bfd also
- depend upon all-opcodes, in case --with-commonbfdlib is used.
-
-Thu Feb 15 19:50:50 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (host *-*-cygwin32): Don't build gdb if we are
- building NT native compilers on Unix.
-
-Thu Feb 15 17:42:25 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Don't get CC from the host Makefile fragment if we
- can find gcc in PATH, or if this is a Canadian Cross. Move the
- Solaris test for /usr/ucb/cc to the post target script, just after
- the compiler sanity test.
-
-Wed Feb 14 16:57:40 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub: Merge with FSF.
-
-Tue Feb 13 14:27:48 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (RPATH_ENVVAR): New variable.
- (REALLY_SET_LIB_PATH): Use it.
- * configure.in: On HP/UX, set RPATH_ENVVAR to SHLIB_PATH.
-
-Mon Feb 12 15:28:49 1996 Doug Evans <dje@charmed.cygnus.com>
-
- * config.sub, configure.in: Recognize sparclet cpu.
-
-Mon Feb 12 15:33:59 1996 Christian Bauernfeind <chrisbfd@theorie3.physik.uni-erlangen.de>
-
- * config.guess: Support m68k-cbm-sysv4.
-
-Sat Feb 10 12:06:42 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
-
- * config.guess (*:Linux:*:*): Guess m68k-unknown-linux and
- m68k-unknown-linuxaout from linker help string. Put quotes around
- $ld_help_string.
-
-Thu Dec 7 09:03:24 1995 Tom Horsley <Tom.Horsley@mail.hcsc.com>
-
- * config.guess (powerpc-harris-powerunix): Add guess for port
- to new target.
-
-Thu Feb 8 15:37:52 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * config.guess (UNAME_VERSION): Recognize X4.x as an OSF version.
-
-Mon Feb 5 16:36:51 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: If --enable-shared was used, set SET_LIB_PATH to
- $(REALLY_SET_LIB_PATH) in Makefile.
- * Makefile.in (SET_LIB_PATH): New variable.
- (REALLY_SET_LIB_PATH): New variable.
- ($(DO_X)): Use $(SET_LIB_PATH).
- (install.all, gcc-no-fixedincludes, $(ALL_MODULES)): Likewise.
- ($(NATIVE_CHECK_MODULES), $(CROSS_CHECK_MODULES)): Likewise.
- ($(INSTALL_MODULES), $(CONFIGURE_TARGET_MODULES)): Likewise.
- ($(ALL_TARGET_MODULES), $(CHECK_TARGET_MODULES)): Likewise.
- ($(INSTALL_TARGET_MODULES), $(ALL_X11_MODULES)): Likewise.
- ($(CHECK_X11_MODULES), $(INSTALL_X11_MODULES)): Likewise.
- (all-gcc, all-bootstrap, check-gcc, install-gcc): Likewise.
- (install-dosrel): Likewise.
- (all-opcodes): Depend upon all-libiberty.
-
-Sun Feb 4 16:51:11 1996 Steve Chamberlain <sac@slash.cygnus.com>
-
- * config.guess (*:CYGWIN*): New
-
-Sat Feb 3 10:42:35 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * Makefile.in (all-target-winsup): All all-target-libiberty.
-
-Fri Feb 2 17:58:56 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (noconfigdirs): Add missing # in front of comment.
-
-Thu Feb 1 14:38:13 1996 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: add second pass to things added to noconfigdirs
- so *-gm-magic can exclude libgloss properly.
-
-Thu Feb 1 11:10:16 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-configure (extralibs_name, rez_name): Set correctly
- for MWC68K compiler.
-
- * mpw-README: Add more info on the necessary build tools.
-
-Thu Feb 1 10:22:38 1996 Steve Chamberlain <sac@slash.cygnus.com>
-
- * configure.in, config.sub: Recognize cygwin32.
-
-Wed Jan 31 14:17:10 1996 Richard Henderson <rth@tamu.edu>
-
- * config.guess, config.sub: Recognize A/UX.
-
-Wed Jan 31 13:52:14 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub: Merge with gcc/config.sub.
-
-Thu Jan 25 11:01:10 1996 Raymond Jou <rjou@mexican.cygnus.com>
-
- * mpw-build.in (do-binutils): Add build of stamps.
-
-Thu Jan 25 17:05:26 1996 James G. Smith <jsmith@cygnus.co.uk>
-
- * config.sub: Add recognition for mips64vr4100*-* targets.
-
-Wed Jan 24 12:47:55 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * test-build.mk: Add checking of `hpux9' rather than just `hpux'.
- Add creation of gconfigargs with `--enable-shared' turned on.
- ($(host)-stamp-stage2-configured): Pass $(gconfigargs).
- ($(host)-stamp-stage3-configured): Likewise.
- (HOLES): Add chatr and ldd.
- (i386-ncr-sysv4.3*): Add use of /usr/ccs/bin in the PATH and HOLE_DIRS.
-
-Wed Jan 24 20:32:30 1996 Torbjorn Granlund <tege@noisy.matematik.su.se>
-
- * configure: Pass --nfp to recursive configures.
-
-Mon Jan 22 10:41:56 1996 Steve Chamberlain <sac@slash.cygnus.com>
-
- * Makefile.in (DLLTOOL): New.
- (DLLTOOL_FOR_TARGET): New.
- (EXTRA_HOST_FLAGS): Pass down DLLTOOL.
- (EXTRA_TARGET_FLAGS): Ditto.
- (EXTRA_GCC_FLAGS): Ditto.
- (CONFIGURE_TARGET_MODULES): Ditto.
- (DO_X): Ditto.
- * configure: Add DLLTOOL.
-
-Fri Jan 19 13:30:15 1996 Stan Shebs <shebs@andros.cygnus.com>
-
- SCO OpenServer 5 changes from Robert Lipe <robertl@dgii.com>:
- * configure.in (i[345]86-*-sco3.2v5*): Use mh-sysv instead of
- mh-sco, since old workarounds no longer needed, and don't
- build ld, since libraries have weak symbols in COFF.
-
-Sun Jan 14 23:01:31 1996 Fred Fish <fnf@cygnus.com>
-
- * Makefile.in (CONFIGURE_TARGET_MODULES): Add missing ';'.
-
-Fri Jan 12 15:25:35 1996 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Make sure that ${CC} can be used to compile an
- executable.
-
-Sat Jan 6 07:23:33 1996 Michael Meissner <meissner@wogglebug.tiac.net>
-
- * Makefile.in (all-gdb): Depend on $(GDB_TK).
- * configure (GDB_TK): Set GDB_TK to either "all-tcl all-tk" or
- nothing depending on whether gdbtk is being built.
-
-Wed Jan 3 17:54:41 1996 Doug Evans <dje@canuck.cygnus.com>
-
- * Makefile.in (newlib.tar.gz): Delete building of newlib's info files.
-
-Mon Jan 1 19:09:14 1996 Brendan Kehoe <brendan@rtl.cygnus.com>
-
- * configure.in (noconfigdirs): Put ld or gas in this early, if the
- user specifically used --with-gnu-ld=no or --with-gnu-as=no.
-
-Sat Dec 30 16:08:57 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * config-ml.in: Add support for
- --disable-{softfloat,m68881,m68000,m68020} on m68*-*-*.
- Simplify setting of multidirs from --disable-foo.
-
-Fri Dec 29 07:56:11 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * Makefile.in (EXTRA_GCC_FLAGS): If any of the make variables
- LANGUAGES, BOOT_CFLAGS, STMP_FIXPROTO, LIMITS_H_TEST,
- LIBGCC1_TEST, LIBGCC2_CFLAGS, LIBGCC2_INCLUDES, and ENQUIRE are
- non-empty, pass them on to the GCC make.
- (all-bootstrap): New rule that is like all-gcc, except it executes
- the GCC bootstrap rule instead of the GCC all rule.
-
-Wed Dec 27 15:51:48 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * config-ml.in (ml_realsrcdir): New, to account for ${subdir}.
-
-Tue Dec 26 11:45:31 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config.guess (AViiON:dgux:*:*): Update from FSF to add pentium
- DG/UX support.
-
-Fri Dec 15 10:01:27 1995 Stan Cox <coxs@dg-rtp.dg.com>
-
- * config.sub (i*86*) Change [345] to [3456]
-
-Wed Dec 20 17:41:40 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * configure.in (noconfigdirs): Add gas or ld if --with-gnu-as=no or
- --with-gnu-ld=no.
-
-Wed Dec 20 15:15:35 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config-ml.in (rs6000*, powerpc*): Add switches to control which
- AIX multilibs get built.
-
-Mon Dec 18 17:55:46 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (i386-win32): Don't build expect if we're not
- building the tcl subdir.
-
-Mon Dec 18 11:47:19 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * Makefile.in: (configure-target-examples, all-target-examples):
- New targets, configure and build example programs.
-
-Fri Dec 15 16:13:03 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-configure: If an mpw-config.in generated a file mk.sed,
- use it as input to sedit the generated MPW makefile.
- * mpw-README: Add a suggestion about Gestalt.h.
-
-Wed Dec 13 16:43:51 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub: Accept *-*-ieee*.
-
-Tue Dec 12 11:52:57 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (local-distclean): Remove $(TARGET_SUBDIR). From
- Ronald F. Guilmette <rfg@monkeys.com>.
-
-Mon Dec 11 15:31:58 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (host==powerpc-pe): Add many directories to noconfigdirs
- for powerpc-pe native.
- (target==i386-win32): add tcl, make to noconfigdirs if canadian cross.
- (target==powerpc-pe): duplicate i386-win32 entry.
-
-Sat Dec 9 14:58:28 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * configure.in (noconfigdirs): Exclude target-newlib for all versions
- of vxworks, not just vxworks5.1.
-
-Mon Dec 4 12:05:40 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-configure: Add support for exec-prefix.
-
-Mon Dec 4 10:22:50 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * config.guess: Recognize HP model 816 machines as having
- a PA1.1 processor.
-
-Mon Dec 4 12:38:15 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Ignore new autoconf configure options.
-
-Thu Nov 30 14:45:25 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * config/mt-v810 (CC_FOR_TARGET): Add -ansi flag. NEC compiler
- defaults to K&R mode, but doesn't have varargs.h, so we have to
- compile in ANSI mode.
-
-Thu Nov 30 16:57:33 1995 Per Bothner <bothner@wombat.gnu.ai.mit.edu>
-
- * config.guess: Recognize Pentium under SCO.
- From Robert Lipe <robertl@arnet.com>.
-
-Wed Nov 29 13:49:08 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in (noconfigdirs): Disable target-libio on v810-*-*.
- * config/mt-v810 (CC_FOR_TARGET, AS_FOR_TARGET, AR_FOR_TARGET,
- RANLIB_FOR_TARGET): Set as appropriate for NEC v810 toolchain.
-
-Wed Nov 29 12:12:01 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Don't configure gas for alpha-dec-osf*.
-
-Tue Nov 28 17:16:48 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Default to --with-stabs for some targets for which
- it makes sense: mips*-*-*, alpha*-*-osf*, i[345]86*-*-sysv4* and
- i[345]86*-*-unixware*.
-
-Mon Nov 27 13:44:15 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * config-ml.in: Get list of multidirs using gcc --print-multi-lib
- rather than basing it on the target. Simplify handling of options
- controlling which directories to configure. Remove extraneous
- slash in multi-clean target.
-
-Fri Nov 24 17:29:29 1995 Doug Evans <dje@deneb.cygnus.com>
-
- * config-ml.in: Prefix more variables with ml_ so they don't collide
- with configure's.
-
-Wed Nov 22 11:27:02 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Don't turn -v into --v.
-
-Tue Nov 21 16:48:02 1995 Doug Evans <dje@deneb.cygnus.com>
-
- * configure.in (targargs): Fix typo.
-
- * Makefile.in (DEVO_SUPPORT): Add symlink-tree.
-
-Tue Nov 21 14:08:28 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Strip --host and --target options from
- CONFIG_ARGUMENTS, and always configure for --host only. Add
- --with-cross-host option when building with a cross-compiler.
- * configure: Canonicalize the arguments put into config.status by
- always using `=' for an option with an argument. Pass a presumed
- --host or --target explicitly.
-
-Fri Nov 17 17:50:30 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * config.sub: Merge -macos*, -magic*, -pe*, and -win32 cases
- into general OS recognition case.
-
-Fri Nov 17 17:42:25 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (target_configdirs): add target-winsup only
- for win32 target systems.
-
-Thu Nov 16 14:04:47 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (all-target-libgloss): Depend upon
- configure-target-newlib, since when libgloss is built it looks to
- see if the newlib directory exists.
-
-Wed Nov 15 14:47:52 1995 Ken Raeburn <raeburn@cygnus.com>
-
- * Makefile.in (DEVO_SUPPORT): Use config-ml.in instead of
- cfg-ml-*.in.
-
-Wed Nov 15 11:45:23 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Handle LD and LD_FOR_TARGET when configuring a
- Canadian Cross.
-
-Tue Nov 14 15:03:12 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * config/mh-i386win32: add LD_FOR_TARGET.
-
-Tue Nov 14 14:56:11 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (target_libs): add target-winsup.
- (target==i386-win32): add patch diff flex make to $noconfigdirs.
- (target==ppcle-pe): remove ld from $noconfigdirs.
-
-Tue Nov 14 01:25:50 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * Makefile.in (CONFIGURE_TARGET_MODULES): Pass --with-target-subdir.
- Preserve relative path names in $srcdir. Build symlink tree if
- configuring cross target dir and srcdir=. (= no VPATH support).
- (configure-target-libg++): Depend on configure-target-librx.
- * cfg-ml-com.in, cfg-ml-pos.in: Deleted.
- * config-ml.in: New file.
- * symlink-tree: New file.
- * configure: Ensure srcdir="." if that's what it is.
-
-Mon Nov 13 12:34:20 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-README: Clarify some phrasing, add notes about CodeWarrior
- includes and FLEX_SKELETON setting.
- * mpw-configure (--with-gnu-ld): New option, controls whether
- to use PPCLink or ld with PowerMac GCC.
- * mpw-build.in (all-grez, do-grez, install-grez): New targets.
- * mpw-config.in: Configure grez if targeting Mac.
-
- * config.sub: Accept pmac and pmac-mpw as names for PowerMacs,
- accept mpw and mac-mpw as names for m68k Macs, change macos7 to
- just macos.
- * configure.in: Configure grez resource compiler if targeting Mac.
- * Makefile.in (all-grez, install-grez): New targets.
-
-Wed Nov 8 17:33:51 1995 Jason Merrill <jason@yorick.cygnus.com>
-
- * configure: CXX defaults to gcc, not g++. If we find
- gcc in the path, set CC to gcc -O2.
-
-Tue Nov 7 15:45:17 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Default ${build} correctly. Avoid picking up extra
- spaces when reading CC and CXX from Makefile. When doing a
- Canadian Cross, use plausible default values for numerous
- variables.
- * configure.in: When doing a Canadian Cross, don't try to
- configure tools whose configure script can't handle it.
-
-Mon Nov 6 19:32:17 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * cfg-ml-com.in (sh-*-*): Add m2 and ml/m2 to multidirs.
-
-Sun Nov 5 00:15:41 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * configure: Remove dubious bug reporting address.
-
-Fri Nov 3 08:17:54 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * Makefile.in ($(CONFIGURE_TARGET_MODULES)): If subdir has
- configure script, run that instead of this directory's configure.
- In either case, print a message that we're configuring the sub-dir.
-
-Thu Nov 2 23:23:36 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * configure.in: Before checking for the existence of various files,
- use sed to filter out "target-".
-
-Thu Nov 2 13:24:56 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (DO_X): Split rule to decrease command line length
- for systems with small ARG_MAX values. From phdm@info.ucl.ac.be
- (Philippe De Muyter).
-
-Wed Nov 1 15:18:35 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * Makefile.in (all-patch): depend on all-libiberty.
-
-Wed Nov 1 12:23:20 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: If the only directory in target_configdirs which
- actually exists is libiberty, then set target_configdirs to empty,
- to avoid trying to build a target libiberty in a gas or gdb
- distribution.
-
-Tue Oct 31 17:52:39 1995 J.T. Conklin <jtc@slave.cygnus.com>
-
- * configure.in (host_makefile_frag): Use m68k-sun-sunos* instead
- of m68k-sun-* when selecting mh-sun3 to avoid matching NetBSD/sun3
- systems.
-
-Tue Oct 31 16:57:32 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * configure.in (copy_dirs): Use sys-include instead of include
- for --with-headers option.
-
-Tue Oct 31 10:29:36 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * Makefile.in, configure.in: Make winsup builds work with
- new scheme.
-
-Mon Oct 30 18:57:09 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Build the linker on AIX.
-
-Mon Oct 30 12:27:16 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * Makefile.in (CC_FOR_TARGET, CXX_FOR_TARGET): Add $(TARGET_SUBDIR)
- where needed.
-
-Mon Oct 30 12:45:25 1995 Doug Evans <dje@cygnus.com>
-
- * Makefile.in (all-gcc): Fix typo.
-
-Sat Oct 28 10:27:59 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * Makefile.in ($(CHECK_TARGET_MODULES)): Fix typo.
-
-Fri Oct 27 23:14:12 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * configure.in: Rename libFOO to target-libFOO, and xiberty
- to target-xiberty, to provide more flexibility.
- (target_subdir): Define. Create if cross.
- Set TARGET_SUBDIR in Makefile to ${target_subdir}.
- * Makefile.in: Rename all-libFOO -> all-target-libFOO, all-xiberty
- -> all-target-libiberty, configure-libFOO -> configure-target-libFOO,
- check-libFOO -> check-target-libFOO, etc.
- ($(DO_X)): Iterate over TARGET_CONFIGDIRS after SUBDIRS.
- ($(CONFIGURE_TARGET_MODULES), $(CHECK_TARGET_MODULES),
- $(ALL_TARGET_MODULES), $(INSTALL_TARGET_MODULES)): Update accordingly.
- (configure-target-XXX): Depend on $(ALL_GCC), not all-gcc, to
- allow ALL_GCC="" to only configure.
- (DEVO_SUPPORT): Add cfg-ml-com.in and cfg-ml-pos.in.
- (ETC_SUPPORT, ETC_SUPPORT_PFX): Merge; update 'taz' accordingly.
- (LIBGXX_SUPPORT_DIRS): Remove xiberty.
-
-Sat Oct 28 01:53:49 1995 Ken Raeburn <raeburn@cygnus.com>
-
- * Makefile.in (taz): Build "info" in etc explicitly.
-
-Fri Oct 27 09:32:30 1995 Stu Grossman (grossman@cygnus.com)
-
- * configure.in: Make sure that CC is undefined (as opposed to
- null) if toplevel/config/mh-{host} doesn't define it. Fixes a
- problem with autoconf trying to configure on a host without GCC.
-
-Thu Oct 26 22:35:01 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-configure: Set host alias from choice of host compiler,
- only use generic MPW Makefile sed if present, edit a file
- named "hacked_Makefile.in" instead of "Makefile.in" if present.
- * mpw-README: Add problem notes about CW6 and CW7.
-
-Thu Oct 26 05:45:10 1995 Ken Raeburn <raeburn@kr-pc.cygnus.com>
-
- * Makefile.in (taz): Use ";" instead of ";;".
-
-Wed Oct 25 15:18:24 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * Makefile.in (taz): Grep for '^diststuff:' or '^info:' in
- sub-directory Makefiles, instead of using DISTSTUFFDIRS and
- DISTDOCDIRS.
- (DISTSTUFFDIRS, DISTDOCDIRS): Removed - no longer used.
- (newlib.tar.gz): Don't pass DISTDOCDIRS to recursive make.
-
-Wed Oct 25 14:43:55 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * Makefile.in (DISTDOCDIRS): Remove ld gprof bnutils gas libg++ gdb
- and gnats, because they are now subsumed by DISTSTUFFDIRS.
- Move bfd to DISTSTUFFDIRS.
-
-Tue Oct 24 18:19:09 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * Makefile.in (X11_LIB): Removed.
- (X11_FLAGS_TO_PASS): pass only X11_EXTRA_CFLAGS and X11_EXTRA_LIBS.
-
- * configure.in (host_makefile_frag): mh-aix & mh-sun removed.
-
-Sun Oct 22 13:04:42 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * cfg-ml-com.in (powerpc*): Shorten some of the multilib directory
- names.
-
-Fri Oct 20 18:02:10 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * cfg-ml-com.in (powerpc*-eabi*): Add mcall-aixdesc varients.
-
-Thu Oct 19 10:40:57 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * configure.in (i[345]86-*-win32): Always build newlib.
- Don't configure cvs, autoconf or texinfo.
- * Makefile.in (LD_FOR_TARGET): New.
- (BASE_FLAGS_TO_PASS, EXTRA_TARGET_FLAGS, CONFIGURE_TARGET_MODULES):
- Pass down LD_FOR_TARGET.
-
-Wed Oct 18 15:53:56 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * winsup: New directory.
- * Makefile.in: Build winsup.
- * configure.in: Winsup is configured when target is win32.
- Can only build win32 target GDB when native.
-
-Mon Oct 16 09:42:31 1995 Jeffrey A Law (law@cygnus.com)
-
- * config.guess: Recognize HP model 819 machines as having
- a PA 1.1 processor.
-
-Mon Oct 16 10:49:43 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Fix sed loop which substitutes for CC and CXX to
- avoid bug found in various sed implementations.
-
-Wed Oct 11 16:16:20 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * cfg-ml-com.in (powerpc-*-eabisim): Delete separate rule for
- simulator. Use standard powerpc-*-eabi*.
-
-Mon Oct 9 17:21:56 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Stop putting gas and binutils in noconfigdirs for
- powerpc-*-aix* and rs6000-*-*.
-
-Mon Oct 9 12:38:40 1995 Michael Meissner <meissner@cygnus.com>
-
- * cfg-ml-com.in (powerpc*-*-eabisim*): Add support for building
- -mcall-aixdesc libraries.
-
-Fri Oct 6 16:17:57 1995 Ken Raeburn <raeburn@cygnus.com>
-
- Mon Sep 25 22:49:32 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
-
- * config.sub (arm | armel | armeb): Fix shell syntax.
-
-Fri Oct 6 14:40:28 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * cfg-ml-com.in ({powerpc,rs6000}-ibm-aix*): Add multilibs for
- -msoft-float and -mcpu=common support.
- (powerpc*-*-eabisim*): Add support for building -mcall-aix
- libraries.
-
-Thu Oct 5 13:26:37 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * configure.in: Allow configuration and build of emacs19 for the alpha.
-
-Wed Oct 4 22:05:36 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (CC): Get ^CC, not just any old CC, from
- ${host_makefile_frag}.
-
-Wed Oct 4 21:55:00 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (CC): Try to get CC from
- ${srcdir}/${host_makefile_frag}, not ${host_makefile_frag}.
-
-Wed Oct 4 21:44:12 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * Makefile.in (TARGET_CONFIGDIRS): configure targetdirs
- only if it exists in $(srcdir).
-
-Wed Oct 4 11:52:31 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: If CC and CXX are not set in the environment, set
- them, based on either an existing Makefile or on searching for gcc
- in PATH. Substitute for CC and CXX in Makefile.
- * configure.in: Remove libm from target_libs. Separate
- target_configdirs from configdirs. If CC is not set in
- environment, try to get it from a host Makefile fragment. Rewrite
- changes of configdirs to use skipdirs instead. A few minor
- tweaks. Take directories out of target_configdirs as they are
- taken out of configdirs. Remove existing Makefile files from
- subdirectories. Substitute for TARGET_CONFIGDIRS and
- CONFIG_ARGUMENTS in Makefile.
- * Makefile.in (TARGET_CONFIGDIRS): New variable, automatically set
- by configure.in.
- (CONFIG_ARGUMENTS): Likewise.
- (CONFIGURE_TARGET_MODULES): New variable.
- ($(DO_X)): Loop over TARGET_CONFIGDIRS as well as SUBDIRS.
- ($(CONFIGURE_TARGET_MODULES)): New target.
- (configure-libg++, configure-libio): New targets.
- (all-libg++): Depend upon configure-libg++.
- (all-libio): Depend upon configure-libio.
- (configure-libgloss, all-libgloss): New targets.
- (configure-libstdc++): New target.
- (all-libstdc++): Depend upon configure-libstdc++.
- (configure-librx, all-librx): New targets.
- (configure-newlib): New target.
- (all-newlib): Depend upon configure-newlib
- (configure-xiberty): New target.
- (all-xiberty): Depend upon configure-xiberty.
-
-Sat Sep 30 04:32:59 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (host i[345]86-*-win32): Expand the
- noconfigdirs again.
-
-Thu Sep 28 21:18:49 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-configure: Fix sed command file name.
-
-Thu Sep 28 17:39:56 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * configure.in (host i[345]86-*-win32): Reduce the
- noconfigdirs again.
-
-Wed Sep 27 12:24:00 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Don't configure ld and gdb for powerpc*-*-winnt*
- or powerpc*-*-pe*, since they are not yet supported.
-
-Tue Sep 26 14:30:01 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- Add PowerMac support and many other enhancements.
- * mpw-configure: New option --cc to select compiler to use,
- paste options set according to --cc into the generated
- Makefile, generate the Makefile by sed'ing the Unix Makefile.in
- if mpw-make.sed is present.
- * mpw-config.in: Don't test for gC1, test for mpw-touch,
- add forward includes for PowerPC include files.
- * mpw-build.in: Build using Makefile.PPC if present.
- (do-byacc, etc): Remove separate version resource builds.
- (do-gas): Build "stamps" before "all".
- (do-gcc): Build "stamps-h" and "stamps-c" before "all".
- * mpw-README: Update to reflect --cc option, PowerMac support,
- and recently-reported compatibility problems.
-
-Fri Sep 22 12:15:42 1995 Doug Evans <dje@deneb.cygnus.com>
-
- * cfg-ml-com.in (m68*-*-*): Only build multilibs for
- embedded m68k systems (-aout, -coff, -elf, -vxworks).
- (--with-multilib-top): Pass to recursive invocations.
-
-Tue Sep 19 13:51:05 1995 J.T. Conklin <jtc@blues.cygnus.com>
-
- * configure.in (noconfigdirs): Disable libg++ and libstdc++ on
- v810-*-*.
-
-Mon Sep 18 23:08:26 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in (noconfigdirs): Disable bfd, binutils, gas, gcc,
- gdb, ld and opcodes on v810-*-*.
-
-Sat Sep 16 18:31:08 PDT 1995 Angela Marie Thomas <angela@cygnus.com>
-
- * config/mh-ncrsvr43: Removed AR_FLAGS
-
-Tue Sep 12 18:03:31 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (DO_X): Change do-realclean to do-maintainer-clean.
- (local-maintainer-clean): New target.
- (maintainer-clean): New target.
- (realclean): Just depend upon maintainer-clean.
-
-Fri Sep 8 17:11:14 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in (noconfigdirs): Disable gdb on m68k-*-netbsd*.
-
-Fri Sep 8 16:46:29 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Build ld in mips*-*-bsd* case.
-
-Thu Sep 7 20:03:41 1995 Ken Raeburn <raeburn@cygnus.com>
-
- * config.sub: Accept -lites* OS. From Ian Dall.
-
-Fri Sep 1 08:06:58 1995 James G. Smith <jsmith@beauty.cygnus.com>
-
- * config.sub: recognise mips64vr4300 and mips64vr4300el as valid
- targets.
-
-Wed Aug 30 21:06:50 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in: treat i386-win32 canadian cross the same as
- i386-go32 canadian cross.
-
-Thu Aug 24 14:53:20 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * cfg-ml-com.in (powerpc*-*-eabisim): Add support for PowerPC
- running under the simulator to build a reduced set of libraries.
- (powerpc-*-eabiaix): Add fine grained multilib support added to
- other powerpc targets yesterday.
-
-Wed Aug 23 09:41:56 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * cfg-ml-com.in (powerpc*): Add support for -disable-biendian,
- -disable-softfloat, -disable-relocatable, -disable-aix, and
- -disable-sysv to control which multilib libraries get built.
-
-Thu Aug 17 16:03:41 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
-
- * configure: Add Makefile.tem to list of files to remove in trap
- handler.
-
-Mon Aug 14 19:27:56 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * config.guess (*Linux*): Add missing "exit"s.
- Also, need specific check for alpha-unknown-linux (uses COFF).
-
-Fri Aug 11 15:38:20 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * config.guess: Merge with FSF:
-
- Wed Jun 28 17:57:27 1995 David Edelsohn <edelsohn@mhpcc.edu>
- * config.guess (AIX4): More robust release numbering discovery.
-
- Thu Jun 22 19:01:24 1995 Kenneth Stailey (kstailey@eagle.dol-esa.gov)
- * config.guess (i386-sequent-ptx): Properly get version number.
-
- Thu Jun 22 18:36:42 1995 Uwe Seimet (seimet@iris1.chemie.uni-kl.de)
- * config.guess (mips:*:4*:UMIPS): New case.
-
-Mon Aug 7 09:21:35 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * configure.in (i386-go32 host): Fix typo (deja-gnu -> dejagnu).
- (i386-win32 host): Likewise. Don't build readline.
-
-Sat Aug 5 09:51:49 1995 Fred Fish <fnf@rtl.cygnus.com>
-
- * Makefile.in (GDBTK_SUPPORT_DIRS): Define and pass as part of
- SUPPORT_FILES to submakes.
-
-Fri Aug 4 13:04:36 1995 Fred Fish <fnf@cygnus.com>
-
- * Makefile.in (GDB_SUPPORT_DIRS): Add utils.
- (DEVO_SUPPORT): Add mpw-README, mpw-build.in, mpw-config.h and
- mpw-configure.
-
-Wed Aug 2 16:32:40 1995 Ken Raeburn <raeburn@cygnus.com>
-
- * configure.in (appdirs): Use =, not ==, in test expression when
- trying to build the text to print in the warning message for
- Solaris users.
-
-Mon Jul 31 09:56:18 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * cfg-ml-com.in (z8k-*-coff): Add 'std' multilib build.
-
-Fri Jul 28 00:16:31 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * config.guess: Recognize lynx-2.3.
-
-Thu Jul 27 15:47:59 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * config.sub (z8ksim): Deleted
- (z8k-*-coff): New, this is the one true name of the target.
-
-Thu Jul 27 14:33:33 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * cfg-ml-pos.in (dotdot): Work around SunOS sed bug.
-
-Thu Jul 27 13:31:05 1995 Fred Fish (fnf@cygnus.com)
-
- * config.guess (*:Linux:*:*): First try asking the linker what the
- default object file format is (elf, aout, or coff). Then if this
- fails, try previous methods.
-
-Thu Jul 27 11:28:17 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in: Don't build newlib for *-*-vxworks5.1.
-
-Thu Jul 27 11:18:47 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * configure.in: Don't build newlib for a29k-*-vxworks5.1.
- * test-build.mk: Add setting of --with-headers for a29k-vxworks5.1.
-
-Tue Jul 25 21:25:39 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * cfg-ml-pos.in (MULTITOP): Trim excess trailing "/.".
-
-Fri Jul 21 10:41:12 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * cfg-ml-com.in: New file.
- * cfg-ml-pos.in: New file.
-
-Wed Jul 19 00:37:27 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * COPYING.NEWLIB: Add HP free copyright to list.
-
-Tue Jul 18 10:58:51 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config.sub: Recognize -eabi* for the system, not just -eabi.
-
-Mon Jul 3 13:44:51 1995 Steve Chamberlain <sac@slash.cygnus.com>
-
- * Makfile.in (DLLTOOL_FOR_TARGET): New name, pass it down.
- * config.sub, configure.in (win32): New target and host.
-
-Wed Jun 28 23:57:08 1995 Steve Chamberlain <sac@slash.cygnus.com>
-
- * configure.in: Add i386-pe configuration.
-
-Fri Jun 23 14:28:44 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-build.in (install): Install GDB after LD.
-
-Thu Jun 22 17:10:53 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-config.in (elf/mips.h): Always forward-include, needed
- for GDB to build.
-
-Wed Jun 21 15:17:30 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * testsuite: New directory for customer acceptance and whole tool
- chain tests.
-
-Wed Jun 21 16:50:29 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
-
- * configure: If per-host line isn't found, but AC_OUTPUT is found
- and a configure script exists, run it instead.
-
-Thu Jun 15 21:09:24 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * config.guess: Update from FSF, for alpha-dec-winnt3.5 and Crays.
-
-Tue Jun 13 21:43:27 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * configure: Set build_{cpu,vendor,os,alias} to host values when
- --build isn't specified.
-
-Mon Jun 5 18:26:36 1995 Jason Merrill <jason@phydeaux.cygnus.com>
-
- * Makefile.in (PICFLAG, PICFLAG_FOR_TARGET): New macros.
- (FLAGS_TO_PASS): Pass them.
- (EXTRA_TARGET_FLAGS): Ditto.
-
- * config/m?-*pic: Define PICFLAG* instead of LIB*FLAGS*.
-
-Wed May 31 22:27:42 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * Makefile.in (all-libg++): Depend on all-libstdc++.
-
-Thu May 25 22:40:59 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in (noconfigdirs): Enable all packages for
- i386-unknown-netbsd.
-
-Sat May 20 13:22:31 1995 Angela Marie Thomas <angela@cirdan.cygnus.com>
-
- * configure.in (noconfigdirs): Don't configure tk for i386-go32
- hosted builds (DOS builds)
-
-Thu May 18 18:08:49 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
-
- Changes for ARM based on patches from Richard Earnshaw:
- * config.sub: Handle armeb and armel.
- * configure.in: Omit arm linker only for riscix.
-
-Thu May 11 17:23:26 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * config.guess: Update from FSF.
-
-Tue May 9 15:52:05 1995 Michael Meissner <meissner@cygnus.com>
-
- * config.sub: Recognize powerpcle as the little endian varient of
- the PowerPC. Recgonize ppc as a PowerPC variant, and ppcle as a
- powerpcle variant. Convert pentium into i586, not i486. Add p5
- alias for i586. Map new x86 variants p6, k5, nexgen into i586
- temporarily.
-
-Tue May 2 16:29:41 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * configure.in (hppa*-*-lites*): Treat like hppa*-*-*elf*.
-
-Sun Apr 30 21:38:09 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * config.sub: Accept -lites* as a basic system type.
-
-Thu Apr 27 11:33:29 1995 Michael Meissner (meissner@cygnus.com)
-
- * config.guess (*:Linux:*:*): Check for whether the pre-BFD linker is
- installed, and if so return linuxoldld as the system name.
-
-Wed Apr 26 10:59:02 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * config.guess: Add hppa1.1-hp-lites support.
-
-Tue Apr 25 11:08:11 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * configure.in: Don't build newlib for m68k-vxworks5.1.
-
-Wed Apr 19 17:02:43 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * configure.in (mips-sgi-irix6): Use mh-irix5.
-
-Fri Apr 14 15:21:17 1995 Doug Evans <dje@chestnut.cygnus.com>
-
- * Makefile.in (all-gcc): Depend on all-ld (for libgcc1-test).
-
-Wed Apr 12 16:06:01 1995 Jason Merrill <jason@phydeaux.cygnus.com>
-
- * test-build.mk: Enable building of shared libraries on IRIX 5 and
- OSF/1. Fix compiler flags.
- * build-all.mk: Support Linux and OSF/1 3.0. Fix compiler flags.
-
-Tue Apr 11 18:55:40 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * configure.in: Recognize --with-newlib.
- (sparc-*-sunos4*): Build sim, dejagnu, expect, tcl if cross target.
-
-Mon Apr 10 14:38:20 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * Makefile.in: move {all,check,install}-gdb from *_MODULES
- to *_X11_MODULES due to gdbtk needing X include files et al.
-
-Mon Apr 10 11:42:22 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: Add generic include forwards for cpu-specific
- include files in aout and elf directories.
-
- * mpw-configure: Added copyright.
- * mpw-config.in: Check for presence of required build tools.
- (target_libs): Add newlib.
- (target_tools): Add examples.
- (Read Me): Generate as "Read Me for MPW" instead.
- * mpw-build.in: Base sub-builds on all-foo instead of do-foo.
- (all-byacc, do-byacc, all-flex, do-flex, do-newlib): New actions.
- (do-gas, do-gcc, do-gdb, do-ld): Build Version.r first.
-
- * mpw-configure: Remove subdir-specific makefile hackery,
- delete mk.tmp after using it.
-
- * mpw-build.in (all): Display start and end times.
-
- * mpw-configure (host_canonical): Set.
- (target_cpu): Always add to makefiles.
- (ARCHDEFS, EMUL): Add to makefile only if nonempty.
- (TM_FILE, XM_FILE, NM_FILE): No longer add to makefile.
- (mpw-mh-mpw): Look for in srcdir and srcroot.
- Use sed instead of mpw-edit-prefix to edit prefix definitions.
-
- * mpw-build.in: (install-only): New target.
-
- * mpw-configure (host_alias, target_alias): Rename from hostalias
- and targetalias, add into generated Makefile.
- (mk.tmp): If present, add into generated Makefile.
- * mpw-build.in (all-gas): Build config.h first before gas proper.
-
- * mpw-configure (config.status): Write only if changed.
- * mpw-config.in (readline): Configure it (not built, just used for
- definitions).
-
- * mpw-config.in (elf/mips.h): Add a forward include.
-
- * mpw-config.in: Forward-include most .h files in include into
- extra-include.
- (readline): Don't build.
- mpw-build.in (install): Install GDB.
-
- * mpw-configure (prefix, mpw_prefix): Handle it.
- * mpw-config.in (mmalloc, readline): Don't configure.
- * mpw-build.in (thisscript): Rename to ThisScript.
- Use mpw-build instead of BuildProgram everywhere.
- (mmalloc, readline): Don't build.
- * mpw-README: New file, basic documentation about the MPW port.
-
- * mpw-config.in: Use forward-include to create include files.
-
- * mpw-configure: Add more things to the top of each configured
- Makefile, including contents of config/mpw-mh-mpw.
- * mpw-config.in (extra-include): Create this directory and fill it
- with Posix-like include files when configuring.
-
- * config.sub (apple, mac, mpw): Add various aliases.
-
- * mpw-build.in: New file, top-level build script fragment for MPW.
- * mpw-configure: New file, configure script for MPW.
- * mpw-config.in: New file, config fragment for MPW.
-
-Fri Apr 7 19:33:16 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in (host_libs): Remove glob, since it is gone from the
- sources.
-
-Fri Mar 31 11:36:17 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * Makefile.in: define empty GDB_NLM_DEPS var.
-
- * configure.in(target_makefile_frag): use config/mt-netware
- for netware targets.
-
-Thu Mar 30 13:51:43 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * config.sub: Merge in recent FSF changes. Remove linux special
- cases.
-
-Tue Mar 28 14:47:34 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- build-all.mk,config/mh-solaris: revert these two changes:
-
- Tue Mar 30 10:03:09 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * build-all.mk: Use CC=cc -Xs on Solaris.
-
- Mon Mar 29 19:59:26 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config/mh-solaris: SunPRO C needs -Xs to be able to get a
- working xmakefile for Emacs.
-
-Tue Mar 21 10:43:32 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * glob/*: Removed. Schauer's 24 Feb 1994 readline change made us
- stop using it.
- * Makefile.in: Nuke all references to glob subdirectory.
-
-Thu Mar 16 13:35:30 1995 Jason Merrill <jason@phydeaux.cygnus.com>
-
- * configure.in: Fix --enable-shared logic in per-host.
-
-Mon Mar 13 12:33:15 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in (*-hp-hpux[78]*): Use mh-hpux8.
-
-Mon Mar 6 10:21:58 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in (noconfigdirs): Don't build gas on AIX, for
- powerpc*-*-aix* as well as for rs6000*-*-aix*.
-
-Wed Mar 1 12:51:53 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Fix --cache-file to work if the file argument is a
- relative path.
-
-Tue Feb 28 17:36:07 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: If the --cache-file is used, pass it down to
- configure in subdirectories.
-
-Mon Feb 27 12:52:46 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * config.sub: add vxworks29k configuration.
-
-Fri Feb 10 16:12:26 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
-
- * Makefile.in (taz): Do "diststuff" part quietly.
-
-Sun Feb 5 14:16:35 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * config.sub: Mini-merge with gcc/config.sub.
-
-Sat Feb 4 12:11:35 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * config.guess (IRIX): Sed - to _.
-
-Fri Feb 3 11:54:42 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * Makefile.in (source-vault, binary-vault): New targets.
-
-Thu Jan 26 13:00:11 1995 Michael Meissner <meissner@cygnus.com>
-
- * config.sub: Recognize -eabi as a basic system type.
-
-Thu Jan 12 13:13:23 1995 Jason Merrill <jason@phydeaux.cygnus.com>
-
- * configure.in (enable_shared stuff): Fix typo.
-
-Thu Jan 12 01:36:51 1995 deanm@medulla.LABS.TEK.COM (Dean Messing)
-
- * Makefile.in (BASE_FLAGS_TO_PASS): Fix typo in passing LIBCXXFLAGS*.
-
-Wed Jan 11 16:29:53 1995 Jason Merrill <jason@phydeaux.cygnus.com>
-
- * Makefile.in (LIBCXXFLAGS_FOR_TARGET): Add -fno-implicit-templates.
-
-Mon Jan 9 12:48:01 1995 Jim Kingdon <kingdon@lioth.cygnus.com>
-
- * configure.in (rs6000-*-*): Don't build gas.
-
-Wed Jan 4 23:53:49 1995 Ian Lance Taylor <ian@tweedledumb.cygnus.com>
-
- * Makefile.in: Use /x/x/ instead of /brokensed/brokensed/, to
- reduce command line length.
- (AS_FOR_TARGET): Check for as.new, not Makefile.
- (NM_FOR_TARGET): Check for nm.new, not Makefile.
-
-Wed Jan 4 13:02:39 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * config.guess: Merge from FSF.
-
-Thu Dec 15 17:11:37 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * configure: Don't use $ when handling program_suffix.
-
-Mon Dec 12 12:09:37 1994 Stu Grossman (grossman@cygnus.com)
-
- * configure.in: Configure tk for hppa/hpux.
-
-Fri Dec 2 15:55:38 1994 Per Bothner <bothner@kalessin.cygnus.com>
-
- * Makefile.in (LIBGXX_SUPPORT_DIRS): Add libstdc++.
-
-Tue Nov 29 19:37:56 1994 Per Bothner <bothner@kalessin.cygnus.com>
-
- * Makefile.in: Move -fno-implicit-template from CXXFLAGS
- to LIBCXXFLAGS. Tests are better run without it.
-
-Wed Nov 23 10:29:25 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
-
- * Makefile.in (all-ispell): Depend on all-emacs19 instead of all-emacs.
-
-Mon Nov 21 11:14:01 1994 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in (*-*-netware*): Don't configure xiberty.
-
-Mon Nov 14 08:49:15 1994 Stu Grossman (grossman@cygnus.com)
-
- * configure.in: Remove tk from native_only list.
-
-Fri Nov 11 15:31:26 1994 Bill Cox (bill@rtl.cygnus.com)
-
- * build-all.mk: Add mips-ncd-elf target to sun4 targets
- for special NCD build.
-
-Mon Nov 7 20:58:17 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
-
- * Makefile.in (DEVO_SUPPORT): Remove configure.bat and
- makeall.bat, they're only useful for binutils snapshots.
- (binutils.tar.gz, gas+binutils.tar.gz): Add configure.bat and
- makeall.bat to specified SUPPORT_FILES.
-
-Mon Nov 7 17:25:18 1994 Bill Cox (bill@cirdan.cygnus.com)
-
- * build-all.mk: Add Ericsson targets to sun4 and solaris
- hosts. Add BNR's sun4 target to solaris host, so their
- build-from-source will be tested in-house first.
-
-Sat Nov 5 18:43:30 1994 Jason Merrill (jason@phydeaux.cygnus.com)
-
- * Makefile.in (LIBCFLAGS): New variable.
- (CFLAGS_FOR_TARGET): Ditto.
- (LIBCFLAGS_FOR_TARGET): Ditto.
- (LIBCXXFLAGS): Ditto.
- (CXXFLAGS_FOR_TARGET): Ditto.
- (LIBCXXFLAGS_FOR_TARGET): Ditto.
- (BASE_FLAGS_TO_PASS): Pass them.
- (EXTRA_TARGET_FLAGS): Ditto.
-
- * configure.in, config/m[th]-*pic: Support --enable-shared.
-
-Sat Nov 5 15:44:00 1994 Per Bothner <bothner@kalessin.cygnus.com>
-
- * configure.in (target_libs): Include libstdc++ again.
- * config.guess: Update from FSF (for FreeBSD).
-
-Thu Nov 3 16:32:30 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
-
- * Makefile.in (DEVO_SUPPORT): Include configure.bat and
- makeall.bat.
- (DISTDOCDIRS): Add `etc'.
- (ETC_SUPPORT_PFX): New variable.
- (taz): Include anything from etc starting with a word in
- ETC_SUPPORT_PFX.
-
-Wed Oct 26 16:19:35 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * config.sub: Update for recent FSF changes. Remove obsolete
- h8300hds entry. Add -windows* and -osx as basic os. Minor
- spacing changes.
-
-Thu Oct 20 18:41:56 1994 Per Bothner <bothner@kalessin.cygnus.com>
-
- * configure.in (target_libs): Remove libstdc++ for libg++-2.6.1.
-
- * config.guess: Merge with FSF.
- * configure.in: Match on i?86-ncr-sysv4.3, not i?86-ncr-sysv43.
-
-Thu Oct 20 19:26:56 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
-
- * configure: Since the "trap 0" handler will override the exit
- status on many systems, only use it for "exit 1", and make it set
- a non-zero exit status; reset it before "exit 0". Also, check
- exit status of config.sub, and error out if it failed.
-
-Wed Oct 19 18:49:55 1994 Rob Savoye (rob@cygnus.com)
-
- * Makefile.in: (ALL_TARGET_MODULES,INSTALL_TARGET_MODULES) Build
- and install libgloss.
-
-Tue Oct 18 15:25:24 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * Makefile.in (all-binutils): Depend upon all-byacc.
-
- * configure.in: Don't build emacs on Irix 5.
-
-Mon Oct 17 16:22:12 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * configure.in (*-*-netware*): Add libio.
-
-Thu Oct 13 15:51:20 1994 Jason Merrill (jason@phydeaux.cygnus.com)
-
- * Makefile.in (ALL_TARGET_MODULES): Add libstdc++.
- (CHECK_TARGET_MODULES): Ditto.
- (INSTALL_TARGET_MODULES): Ditto.
- (TARGET_LIBS): Ditto.
- (all-libstdc++): Note dependencies.
-
-Thu Oct 13 01:43:08 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
-
- * Makefile.in (BINUTILS_SUPPORT_DIRS): Add gas.
-
-Tue Oct 11 12:12:29 1994 Jason Merrill (jason@phydeaux.cygnus.com)
-
- * Makefile.in (CXXFLAGS): Use -fno-implicit-templates instead of
- -fexternal-templates.
-
- * configure.in (target_libs): Add libstdc++.
- (noconfigdirs): Add libstdc++ as appropriate.
-
-Thu Oct 6 18:00:54 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess: Update from FSF.
-
-Tue Oct 4 12:05:42 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * configure: Use ${config_shell} when running ${configsub}.
-
-Mon Oct 3 14:28:34 1994 Doug Evans <dje@canuck.cygnus.com>
-
- * config.sub: No longer recognize h8300h.
-
-Mon Oct 3 12:40:54 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * config.sub: Remove extraneous differences between config.sub and
- gcc/config.sub.
-
-Sat Oct 1 00:23:12 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
-
- * Makefile.in (DISTSTUFFDIRS): Add gas.
-
-Thu Sep 22 19:04:55 1994 Doug Evans (dje@canuck.cygnus.com)
-
- * COPYING.NEWLIB: New file.
-
-Mon Sep 19 18:25:40 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess (HP-UX): Patch from Harlan Stenn
- <harlan@landmark.com> to also emit release level.
-
-Wed Sep 7 13:15:25 1994 Jim Wilson (wilson@sphagnum.cygnus.com)
-
- * config.guess (sun4*:SunOS:*:*): Change '-JL' to '_JL'.
-
-Tue Sep 6 23:23:18 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.sub: Merge nextstep cleanup from FSF.
-
-Mon Sep 5 05:01:30 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com)
-
- * configure.in (arm-*-*): Don't configure ld for this target.
-
-Thu Sep 1 09:35:00 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * configure.in (*-*-netware): don't configure libg++, libio,
- librx, or newlib.
-
-Wed Aug 31 13:52:08 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * configure.in (alpha-dec-osf*): Use osf*, not osf1*. Don't
- configure ld--it works, but it doesn't support shared libraries.
-
-Sun Aug 28 18:13:45 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess (*-unknown-freebsd*): Get rid of possible
- trailing "(Release)" in version string.
- Patch from Paul Richards <paul@isl.cf.ac.uk>.
-
-Sat Aug 27 15:00:49 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess: Fix i486-ncr-sysv43 -> i486-ncr-sysv4.3.
- Fix type: *-next-neststep -> *-next-nextstep.
-
- * config.guess: Merge from FSF:
-
- Fri Aug 26 18:45:25 1994 Philippe De Muyter (phdm@info.ucl.ac.be)
-
- * config.guess: Recognize powerpc-ibm-aix3.2.5.
-
- Wed Apr 20 06:36:32 1994 Philippe De Muyter (phdm@info.ucl.ac.be)
-
- * config.guess: Recognize UnixWare 1.1 (UNAME_SYSTEM is SYSTEM_V
- instead of UNIX_SV for UnixWare 1.0).
-
-Sat Aug 27 01:56:30 1994 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in (all-gdb): Add dependencies on all-gcc and all-ld
- to make gdb/nlm/* build after the compiler and linker.
-
-Fri Aug 26 14:30:05 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess (netbsd, freebsd, linux): Accept any machine,
- not just i[34]86.
- (m68k-atari-sysv4): Relocate to match FSF version.
-
- * config.guess: More merges from the FSF:
-
- Add a space before function call or macro invocation.
-
- Tue May 10 16:53:55 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
-
- * config.guess: Add trap cmd to remove dummy.c and dummy when
- interrupted.
-
- Wed Apr 20 18:07:13 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
-
- * config.guess (dummy.c): Redirect stderr for `hostinfo' command.
- (dummy): Redirect stderr from compilation of dummy.c.
-
- Sat Apr 9 14:59:28 1994 Christian Kranz (kranz@sent5.uni-duisburg.de)
-
- * config.guess: Distinguish between NeXTStep 2.1 and 3.x.
-
-Fri Aug 26 13:42:20 1994 Ken Raeburn (raeburn@kr-laptop.cygnus.com)
-
- * configure: Accept and ignore --cache*, for compatibility with
- new autoconf.
-
-Fri Aug 26 13:05:27 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess: Merge from FSF:
-
- Thu Aug 25 20:28:51 1994 Richard Stallman <rms@mole.gnu.ai.mit.edu>
-
- * config.guess (Pyramid*:OSx*:*:*): New case.
- (PATH): Add /.attbin at end for finding uname.
- (dummy.c): Handle i860-alliant-bsd. Follow whitespace conventions.
-
- Wed Aug 17 18:21:02 1994 Tor Egge (tegge@pvv.unit.no)
-
- * config.guess (M88*:DolphinOS:*:*): New case.
-
- Thu Aug 11 17:00:13 1994 Stan Cox (coxs@dg-rtp.dg.com)
-
- * config.guess (AViiON:dgux:*:*): Use TARGET_BINARY_INTERFACE
- to select whether to use ELF or COFF.
-
- Sun Jul 24 16:20:53 1994 Richard Stallman <rms@mole.gnu.ai.mit.edu>
-
- * config.guess: Recognize i860-stardent-sysv and i860-unknown-sysv.
-
- Sun May 1 10:23:10 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu)
-
- * config.guess: Guess the OS version for HPUX.
-
- Tue Mar 1 21:53:03 1994 Karl Heuer (kwzh@hal.gnu.ai.mit.edu)
-
- * config.guess (UNAME_VERSION): Recognize aix3.2.4 and aix3.2.5.
-
-Fri Aug 26 11:19:08 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * configure.in: Recognize --with-headers, --with-libs, and
- --without-newlib.
- * Makefile.in (all-xiberty): Depend upon all-ld.
-
-Wed Aug 24 12:36:50 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * configure.in: Change i[34]86 to i[345]86.
-
-Mon Aug 22 10:58:33 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * configure (version): A few more tweaks to help message.
-
-Fri Aug 19 12:40:25 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * Makefile.in: Remove (for now) librx as a host library,
- now that we're building it for target.
-
-Fri Aug 19 10:49:17 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * configure: Fix up help message; from karl@owl.hq.ileaf.com
- (Karl Berry).
-
-Tue Aug 16 16:11:08 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * configure.in: Also configure librx.
-
-Mon Aug 15 16:51:45 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * Makefile.in: Update various rules to reflect that librx
- is now needed for libg++.
-
-Fri Aug 12 18:07:21 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * config.sub: Accept mips64orion and mips64orionel as a CPU name.
-
-Mon Aug 8 11:36:17 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * configure.in: Configure the examples directory.
-
-Thu Aug 4 16:12:36 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * configure: Simplify Jun 2 1994 change.
-
-Wed Aug 3 04:58:16 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
-
- * change CC to /usr/latest/bin/gcc for lynx host builds, since
- /bin/gcc isn't good enough to build gcc.
-
-Wed Jul 27 09:07:14 1994 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (GDB_SUPPORT_FILES): Remove
- (setup-dirs-gdb, gdb.tar.gz, make-gdb.tar.gz): Remove old rules.
- (gdb.tar.gz): Add new rule to use standard distribution building
- mechanism.
-
-Mon Jul 25 11:10:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure.in: Warn about use of /usr/ucb/cc on Solaris. From
- Bill Cox <bill@cygnus.com>.
-
-Sat Jul 23 12:19:46 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess: Recognize ISC. Patch from kwzh@gnu.ai.mit.edu.
-
-Fri Jul 22 17:53:59 1994 Stu Grossman (grossman@cygnus.com)
-
- * configure: Search current dir first in .gdbinit.
-
-Fri Jul 22 11:28:30 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.sub: Recognize freebsd (merged from gcc config.sub).
-
-Thu Jul 21 14:10:52 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.sub: Refer to NeXT's operating system as nextstep.
-
- * config.sub (case $basic_machine): Re-order the cases, to match
- the order in the FSF version (which is mostly alphabethical).
- Merge in some additions and changes from the FSF.
-
-Sat Jul 16 12:03:08 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * config.guess: Recognize m68k-atari-sysv4 and m88k-harris-csux7.
- * config.sub: Recognize cxux7.
- * configure.in: Use mh-cxux for m88k-harris-cxux*.
-
-Mon Jul 11 14:37:39 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.sub: Fix typo powerpc -> powerpc-*.
-
-Sat Jul 9 13:03:43 1994 Michael Tiemann (tiemann@blues.cygnus.com)
-
- * Makefile.in: `all-emacs19' depends on `all-byacc'.
-
- * Makefile.in: Add all-emacs19 and install-emacs19 rules (in
- parallel with all-emacs and install-emacs). Top-level command
- `make all-emacs19 CC=gcc' now behaves as `make all-emacs CC=gcc'.
-
-Thu Jun 30 16:53:42 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * test-build.mk ($(host)-stamp-stage2-installed): Remove
- $(relbindir)/make before doing ``make install'', and use
- $(GNU_MAKE) while doing it. Avoids problem on SunOS with
- installing over running make binary.
- ($(host)-stamp-stage3-installed): Likewise.
-
-Tue Jun 28 13:43:25 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: Recognize Mach.
-
-Mon Jun 27 16:41:14 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * configure: Check ${exec_prefixoption}, not ${exec_prefix}, to
- see whether --exec-prefix was used.
-
-Sun Jun 26 21:15:54 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * README: Explicitly mention libg++/README. (Zoo's idea.)
-
-Tue Jun 21 12:45:55 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in: Add all-librx target similar to all-libproc.
-
-Wed Jun 8 23:11:55 1994 Stu Grossman (grossman@cygnus.com)
-
- * config.guess: Rearrange tests for Alpha-OSF1 to properly deal
- with post 1.2 uname bogosity.
-
-Thu Jun 9 00:27:59 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure: Remove temporary files on receipt of a signal.
-
-Tue Jun 7 12:06:24 1994 Ian Lance Taylor (ian@cygnus.com)
-
- * configure: If there is a package_makefile_frag, remove
- ${subdir}/Makefile.tem after copying it in.
-
-Mon Jun 6 21:35:02 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
-
- * build_all.mk: support rs6000 lynx identifies itself as
- rs6000-lynx-lynxos2.2.2. Also, use /usr/cygnus/progressive/bin/gcc
- since /bin/gcc is too feeble to compile a modern gcc.
-
-Mon Jun 6 16:06:34 1994 Karen Christiansen (karen@cirdan.cygnus.com)
-
- * brought devo/test-build.mk update-to-date with progressive/
- test-build.mk. Add lynx targets and hppa flag info.
-
-Sat Jun 4 17:23:54 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * configure.in: Use mh-ncrsvr43. Patch from
- Tom McConnell <tmcconne@sedona.intel.com>.
-
-Fri Jun 3 17:47:24 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess (i386-unknown-bsdi): No longer need to
- check #if defined(__bsdi__) && defined(__i386__).
-
-Thu Jun 2 18:56:46 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure: Set program_transform_nameoption correctly.
-
-Thu Jun 2 10:57:06 1994 Karen Christiansen (karen@cirdan.cygnus.com)
-
- * brought build-all.mk update-to-date with progressive build-all.mk,
- added new targets and hppa info.
-
-Thu Jun 2 00:12:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure: If config.guess result is a prefix of the user
- specified target, assume a native build and use the user specified
- target as the host alias. Remove SunOS patch suffix removal hack.
- * configure.in: Remove SunOS patch suffix removal hack.
-
- * Makefile.in (CROSS_CHECK_MODULES): Remove check-flex, since it's
- in NATIVE_CHECK_MODULES.
-
-Wed Jun 1 10:49:41 1994 Bill Cox (bill@rtl.cygnus.com)
-
- * Makefile.in: Rename HOST_ONLY to NATIVE.
- * configure: Delete SunOs patch suffix from host_canonical
- and build_canonical variables that are prepended to Makefiles.
- * configure.in: Add comments for easier maintenance.
-
-Tue May 31 19:39:47 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in: Add all-libproc target similar to all-gui.
-
-Tue May 31 17:16:33 1994 Tom Lord (lord@cygnus.com)
-
- * Makefile.in (CHECK_MODULES): split into
- HOST_ONLY_CHECK_MODULES and CROSS_CHECK_MODULES.
-
-Tue May 31 16:36:36 1994 Paul Eggert (eggert@twinsun.com)
-
- * config.guess (i386-unknown-bsdi): New system to guess.
-
-Wed May 25 16:47:10 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in: Add all-gui target (but not yet build by "all").
-
-Thu May 26 08:53:19 1994 Bill Cox (bill@rtl.cygnus.com)
-
- * config.sub: Move deletion of patch suffix from here...
- * configure.in: To here, at Ian's suggestion. The top-
- level scripts might need to know of a patch level.
-
-Wed May 25 09:15:54 1994 Bill Cox (bill@rtl.cygnus.com)
-
- * config.sub: Strip off patch suffix so rtl is recognized
- as a sunos4.1.3 machine, even though it's been patched.
-
-Fri May 20 08:25:49 1994 Steve Chamberlain (sac@deneb.cygnus.com)
-
- * Makefile.in (INSTALL_LAST): Delete.
- (INSTALL_DOSREL): New.
-
-Thu May 19 17:12:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure.in: Use ld for i[34]86-*-sysv4* and sparc-*-solaris2*.
- Don't set use_gnu_ld to no for *-*-sysv4; that only controls
- whether we pass down --with-gnu-ld anyhow.
-
-Thu May 19 09:29:12 1994 Steve Chamberlain (sac@cygnus.com)
-
- * Makefile.in (INSTALL_LAST): Change operation so it works
- on more flavors of make.
- * configure.in (go32): Don't build libg++ or libio.
-
-Fri May 13 13:28:34 1994 Steve Chamberlain (sac@cygnus.com)
-
- * Makefile.in (Move HOST_PREFIX_1 and friends up so
- they can be overriden by templates.
-
-Sat May 7 16:46:44 1994 Steve Chamberlain (sac@cygnus.com)
-
- * configure.in (target==go32): Don't build gdb.
- * dosrel: New directory.
-
-Fri May 6 14:19:25 1994 Steve Chamberlain (sac@cygnus.com)
-
- * configure.in (host==go32): Configure dosrel too.
- * Makefile.in (INTALL_TARGET): Call INSTALL_LAST last.
- (HOST_CC, HOST_PREFIX, HOST_PREFIX_1): Undefine, they should
- be set by incoming names or templates.
- (INSTALL_LAST): New rule.
- * config/mh-go32: New fragment.
-
-Thu May 5 17:35:05 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * config.sub (sparclitefrw, sparclitefrwcompat): Don't set the os.
-
-Thu May 5 20:06:45 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * config/mh-lynxrs6k: Renamed from mh-lynxosrs6k, to make it
- unique in 8.3 naming schemes.
- * configure.in (appdirs): New variable. Currently empty, but will
- be used in gas distribution. If nonempty, lists a set of
- directories at least one of which must get configured, or top
- level configuration is considered to have failed.
- (rs6000-*-lynxos*): Use new file name.
-
-Thu May 5 13:38:36 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- Eliminate XTRAFLAGS.
- * Makefile.in (CC_FOR_TARGET): If newlib exists, refer to the
- newlib include files using -idirafter, and also use -nostdinc.
- (CXX_FOR_TARGET): Likewise.
- (XTRAFLAGS): Removed.
- (BASE_FLAGS_TO_PASS): Remove XTRAFLAGS_FOR_TARGET.
- (EXTRA_HOST_FLAGS): Remove XTRAFLAGS.
- (EXTRA_TARGET_FLAGS, EXTRA_GCC_FLAGS): Likewise.
- ($(DO_X)): Don't pass down XTRAFLAGS.
-
-Thu May 5 00:16:36 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com)
-
- * configure.in (mips*-dec-bsd*): New target; do build linker.
- (mips*-*-bsd*): New target; don't build linker.
-
-Wed May 4 20:10:10 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
-
- * configure.in: support rs6000-*-lynxos* configuration.
- support sunos4 as a cross target.
-
- * config.sub: look for lynx*, not lynx since the OS version may
- legitimately be part of the name.
-
-Tue May 3 21:48:11 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * configure.in (i[34]86-*-sco*): Move to be with other i386
- targets.
- (romp-*-*): New target. Skip various binary utilities.
- (vax-*-*): New target. Don't build newlib.
- (vax-*-vms): Renamed from *-*-vms. Don't build opcodes or newlib.
-
-Thu Apr 28 15:03:05 1994 David J. Mackenzie (djm@rtl.cygnus.com)
-
- * configure.in: Only set host_makefile_frag if config
- directory exists.
-
-Wed Apr 27 12:14:30 1994 David J. Mackenzie (djm@rtl.cygnus.com)
-
- * install.sh: If $dstdir exists, don't check whether each
- component does.
-
-Tue Apr 26 18:11:33 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * test-build.mk (HOLES): Add sleep; used by rcs/src/conf.sh.
-
-Mon Apr 25 15:06:34 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * configure.in (*-*-lynxos*): Don't configure newlib for either
- native or cross Lynx.
-
-Sat Apr 16 11:58:16 1994 Doug Evans (dje@canuck.cygnus.com)
-
- * config.sub (sparc64-elf): Fix os.
- (z8k): Remove duplicate.
-
-Thu Apr 14 23:33:17 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * Makefile.in (gcc-no-fixedincludes): Touch gcc/include/fixed, not
- gcc/stmp-fixproto, to try to prevent fixproto from being run.
-
-Wed Apr 13 15:14:52 1994 Bill Cox (bill@cygnus.com)
-
- * configure: Make file links cleanly even if Lynx fails on
- an NFS symlink (at least fail cleanly).
-
-Mon Apr 11 10:58:56 1994 Jim Wilson (wilson@sphagnum.cygnus.com)
-
- * test-build.mk (CC): For mips-sgi-irix4, change -XNh1500 to
- -XNh2000.
-
-Sat Apr 9 15:10:45 1994 David J. Mackenzie (djm@rtl.cygnus.com)
-
- * configure: Unknown options are fatal again.
-
-Fri Apr 8 12:01:41 1994 David J. Mackenzie (djm@cygnus.com)
-
- * configure: Ignore --x-includes and --x-libraries, for Autoconf
- compatibility.
-
-Thu Apr 7 17:31:43 1994 Doug Evans (dje@canuck.cygnus.com)
-
- * build-all.mk: Add `clean' target.
-
-Wed Apr 6 20:44:56 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config.guess: Add SINIX support.
- * configure.in: Add mips-*-sysv4* support.
-
-Mon Apr 4 17:41:44 1994 Doug Evans (dje@canuck.cygnus.com)
-
- * build-all.mk: Document all useful targets.
- If canonhost is sparc-sun-solaris2.3, change it to sparc-sun-solaris2.
- If canonhost is mips-sgi-irix4.0.5H, change it to mips-sgi-irix4.
-
-Thu Mar 31 04:55:57 1994 David J. Mackenzie (djm@rtl.cygnus.com)
-
- * configure: Support --silent, --quiet.
-
-Wed Mar 30 21:37:38 1994 David J. Mackenzie (djm@rtl.cygnus.com)
-
- * configure: Support --disable-FEATURE.
-
-Tue Mar 29 19:15:05 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: Recognize NCR running SVR4.3.
-
-Mon Mar 28 14:55:15 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess: Make BSDI generate i386-unknown-bsd386.
- Patch from Paul Eggert <eggert@twinsun.com>.
-
-Mon Mar 28 12:54:52 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure.in (powerpc-*-aix*): Treat like rs6000-*-*.
-
-Sat Mar 26 11:25:48 1994 David J. Mackenzie (djm@rtl.cygnus.com)
-
- * configure: Make unrecognized options give nonfatal warnings
- instead of fatal errors, and pass them to any subdirectory
- configures in case they recognize them.
- Make --x equivalent to --with-x.
-
-Fri Mar 25 21:52:10 1994 David J. Mackenzie (djm@rtl.cygnus.com)
-
- * configure: Add --enable-* options. Clean up usage message and
- some comments.
-
-Thu Mar 24 09:12:53 1994 Doug Evans (dje@canuck.cygnus.com)
-
- * Makefile.in (NM_FOR_TARGET): Build tree version is now nm.new.
-
-Sun Mar 20 11:28:22 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * configure.in (hppa*-*-*): Enable binutils.
-
-Sat Mar 19 11:50:16 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.sub: Recognize cisco.
-
-Fri Mar 18 16:42:32 1994 Jason Merrill (jason@deneb.cygnus.com)
-
- * Makefile.in (CXXFLAGS): Add -fexternal-templates.
-
-Tue Mar 15 11:25:55 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: about target *-hitachi-hiuxwe2, don't print more
- than one configuration name. Add comment.
-
-Sun Mar 6 23:13:38 1994 Hisashi MINAMINO (minamino@sra.co.jp)
-
- * config.guess: about target *-hitachi-hiuxwe2, fixed
- machine guessing order. [Hitachi's CPU_IS_HP_MC68K
- macro is incorrect.]
-
-Sun Mar 13 09:10:08 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (TAGS): Just build TAGS in each subdirectory, rather
- than the "make ls" stuff which used to be here.
-
-Fri Mar 11 12:52:39 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess: Recognize i[34]86-unknown-freebsd.
- From Shawn M Carey <smcarey@rodan.syr.edu>.
-
-Thu Mar 3 14:24:21 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * configure.in (noconfigdirs for alpha): Remove libg++ and libio.
-
-Wed Mar 2 13:28:48 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * config.guess: Check for ptx.
-
-Mon Feb 28 16:46:50 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * config.sub: Add os9k checking.
-
-Thu Feb 24 07:09:04 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * config.guess: Handle OSF1 running on HPPA processors
-
-Fri Feb 18 14:14:00 1994 Ken Raeburn (raeburn@rtl.cygnus.com)
-
- * configure: If subdir configure fails, print out a message with
- subdirectory name, in case subdir's configure code didn't identify
- itself.
-
-Fri Feb 18 12:50:15 1994 Doug Evans (dje@cygnus.com)
-
- * configure.in: Remove embedded newlines from configdirs.
- Avoid mismatches of substrings. Fix matching strings at end
- of configdirs.
-
-Fri Feb 11 15:33:33 1994 Stu Grossman (grossman at cygnus.com)
-
- * config.guess: Add Lynx/rs6000 config support.
-
-Tue Feb 8 13:41:09 1994 Ken Raeburn (raeburn@rtl.cygnus.com)
-
- * configure.in (alpha-dec-osf1*, alpha*-*-*): Build gas.
-
-Mon Feb 7 15:42:36 1994 Jeffrey A. Law (law@cygnus.com)
-
- * configure.in (hppa*-*-osf*): Treat this just like most other
- PA configurations (eg no binutils or ld).
- (hppa*-*-*elf*): These configurations have binutils and ld.
-
-Sun Feb 6 16:35:07 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * config.sub (hiux): Fix typo. From m-kasahr@sramhc.sra.co.JP.
-
-Sat Feb 5 01:00:33 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure.in (rs6000-*-*): Build gas.
-
-Wed Feb 2 13:57:57 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * Makefile.in: Avoid bug in losing hpux sed.
-
-Wed Feb 2 14:53:05 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in, test-build.mk: Remove MUNCH_NM; it was only needed
- for GDB and GDB has been fixed to not need it.
-
-Mon Jan 31 18:40:55 1994 Stu Grossman (grossman at cygnus.com)
-
- * config/mh-lynxosrs6k: Account for lack of ranlib!
-
-Sun Jan 30 17:58:06 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * config.guess: Recognize vax hosts.
-
-Fri Jan 28 15:29:38 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * configure (while loop): Don't use "break 2" inside case
- statement -- the case statement isn't an enclosing loop.
-
-Mon Jan 24 18:40:06 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess: Clean up NeXT support, to allow nextstep
- on Intel machines. Make OS be nextstep.
-
-Sun Jan 23 18:47:22 1994 Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
-
- * config.guess: Add alternate forms for Convex.
-
-Thu Jan 20 16:13:41 1994 Stu Grossman (grossman at cygnus.com)
-
- * configure: Completely rewrite option processing. Take
- advantage of pattern-matching to avoid invoking test frequently.
- Also clean up host and target defaulting logic.
-
-Mon Jan 17 15:06:56 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * Makefile.in: Replace all occurrances of "rootme" with "r" and
- "$${rootme}" with "$$r", to increase the likelihood that the do-*
- commands (plus user environment) will fit SCO limits.
-
-Thu Jan 6 11:20:57 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure.in: Don't issue warnings about directories which are
- not being configured if -norecursion is set. Correct test for
- --with-gnu-as and --with-gnu-ld to not get confused by substring
- matches.
-
- * configure.in: Don't build gas for alpha-dec-osf1*.
-
-Tue Jan 4 17:10:19 1994 Stu Grossman (grossman at cygnus.com)
-
- * configure: Back out Per's change of 12/19/1993. It changes the
- behavior of configure in unexpected and confusing ways.
-
- Also, use different delim char when calculating
- program_transform_name so that the name can contain slashes.
-
-Sat Jan 1 13:45:31 1994 Rob Savoye (rob@darkstar.cygnus.com)
-
- * configure.in, config.sub: Add support for VSTa micro-kernel.
-
-Sat Dec 25 20:00:47 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * configure.in: Nuke hacks which were used to get a special
- version of GAS for HPPA configurations.
-
-Sun Dec 19 20:40:44 1993 Per Bothner (bothner@kalessin.cygnus.com)
-
- * configure: If only ${target_alias} is given, use that
- as the default for ${host_alias}.
- * configure: Add missing back-slashes before nested quotes.
-
-Wed Dec 15 18:07:18 1993 david d `zoo' zuhn (zoo@andros.cygnus.com)
-
- * Makefile.in (BASE_FLAGS_TO_PASS): add YACC=$(BISON)
-
-Tue Dec 14 21:25:33 1993 Per Bothner (bothner@cygnus.com)
-
- * config.guess: Recognize some Tektronix configurations.
- From Kaveh R. Ghazi <ghazi@noc.rutgers.edu>.
-
-Sat Dec 11 11:18:00 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * config.sub: Match any flavor of SH.
-
-Thu Dec 2 17:16:58 1993 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * configure.in: Don't try to configure newlib for Alpha.
-
-Thu Dec 2 14:35:54 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure.in: Don't build ld for Irix 5. Don't build gas,
- libg++ or libio for any Alpha target.
-
- * configure.in (mips*-sgi-irix5*): New target; use mh-irix5.
- * config/mh-irix5. New file for Irix 5.
-
-Wed Dec 1 17:00:33 1993 Jason Merrill (jason@deneb.cygnus.com)
-
- * Makefile.in (GZIPPROG): Renamed from GZIP, which gzip uses for
- default arguments -- so it tried to compress itself.
-
-Tue Nov 30 13:45:15 1993 david d `zoo' zuhn (zoo@andros.cygnus.com)
-
- * configure.in (notsupp): ensure that a space is always at the end
- of the configdirs list, since the grep checks for an explicit space
-
-Tue Nov 16 15:04:27 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure.in (target i386-sysv4.2): don't build ld, since static
- versions of many libraries are not available.
-
-Tue Nov 16 14:28:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: Recognize Apollos (using environment variables).
- * configure.in: Don't configure ld, binutils, or gprof for Apollo.
-
-Thu Nov 11 12:03:50 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: Recognize Sony news mips running newsos.
-
-Wed Nov 10 16:57:00 1993 Mark Eichin (eichin@cygnus.com)
-
- * Makefile.in (all-cygnus, build-cygnus): "fi else" needs to be
- "fi ; else" for bash.
-
-Tue Nov 9 15:54:01 1993 Mark Eichin (eichin@cygnus.com)
-
- * Makefile.in (BASE_FLAGS_TO_PASS): pass SHELL.
-
-Fri Nov 5 08:07:27 1993 D. V. Henkel-Wallace (gumby@blues.cygnus.com)
-
- * config.sub: accept unixware as an alias for svr4.2.
- Fix some inconsistancies with the gcc version.
-
-Fri Nov 5 15:14:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (DISTDOCDIRS): Add gdb.
-
-Fri Nov 5 11:59:42 1993 Per Bothner (bothner@kalessin.cygnus.com)
-
- * Makefile.in (DISTDOCDIRS): Add libg++ and libio.
-
-Fri Nov 5 10:35:05 1993 Ken Raeburn (raeburn@rover.cygnus.com)
-
- * Makefile.in (taz): Only build "info" in DISTDOCDIRS.
- (DISTDOCDIRS): Don't assume libg++ and gdb folks necessarily want
- this now.
-
-Thu Nov 4 18:58:23 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.sub: Accept hiux* as an OS name.
-
- * Makefile.in: Change RUNTEST_FLAGS back to RUNTESTFLAGS per
- etc/make-stds.texi. The underscore came from gcc, and dje now
- agrees that RUNTESTFLAGS is the correct name.
-
-Thu Nov 4 10:49:01 1993 Per Bothner (bothner@kalessin.cygnus.com)
-
- * install.sh: Remove 'set -e'. It makes any conditionals
- in the script useless.
-
- * config.guess: Automatically recognize arm-acorn-riscix
- Patch from Richard Earnshaw (rwe11@cl.cam.ac.uk).
-
-Thu Nov 04 08:08:04 1993 Jeffrey Wheat (cassidy@cygnus.com)
-
- * Makefile.in: Change RUNTESTFLAGS to RUNTEST_FLAGS
-
-Wed Nov 3 22:09:46 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
-
- * Makefile.in (DISTDOCDIRS): New variable.
- (taz): Edit local Makefile.in sooner, instead of proto-toplev
- Makefile.in later. Build "info" and "dvi" in DISTDOCDIRS.
-
-Wed Nov 3 21:31:52 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure.in (hppa target): check the source directory for the
- pagas sub-directory
-
-Wed Nov 3 11:12:22 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * config.sub: Allow -aout* and -elf*.
-
-Wed Nov 3 11:08:33 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
-
- * configure.in: Don't build ld on i386-solaris2, same as for
- sparc-solaris2.
-
-Tue Nov 2 14:21:25 1993 Per Bothner (bothner@kalessin.cygnus.com)
-
- * Makefile.in (taz): Add texinfo/lgpl.texinfo (for libg++).
-
-Tue Nov 2 13:38:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * configure.in: Configure gdb for alpha.
-
-Mon Nov 1 10:42:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (CXXFLAGS): Add -O.
-
-Wed Oct 27 10:45:06 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * config.guess: added support for DG Aviion
-
-Tue Oct 26 14:37:37 1993 Ken Raeburn (raeburn@rover.cygnus.com)
-
- * configure.in: Produce warning message for subdirectories not
- configurable for this host/target combination. Don't try to
- configure gdb for vms.
-
-Mon Oct 25 11:22:15 1993 Ken Raeburn (raeburn@rover.cygnus.com)
-
- * Makefile.in (taz): Replace "byacc" with "bison -y" in the
- appropriate files before making "diststuff".
- (DISTBISONFILES): New var: list of files to be edited.
- (DISTSTUFFDIRS): Add binutils.
-
-Fri Oct 22 20:32:15 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * config.sub: also handle mipsel and mips64el (for little endian mips)
-
-Fri Oct 22 07:59:20 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in: Add * to end of all OS names.
-
-Thu Oct 21 11:38:28 1993 Stan Shebs (shebs@rtl.cygnus.com)
-
- * configure.in: Build newlib for LynxOS native.
-
-Wed Oct 20 09:56:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: Add support for delta 88k running SVR3.
-
- * configure.in: Add comment about HP compiler vs. emacs.
-
-Tue Oct 19 16:02:22 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure.in: don't build ld on solaris2 (not a viable option
- due to bugs in getpwnam & getpwuid)
-
-Tue Oct 19 15:13:56 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
-
- * configure.in: Accept alpha-dec-osf1*, not just -osf1, since
- config.guess will produce a full version number.
-
-Tue Oct 19 15:58:01 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure.in: Build linker and binutils for alpha-dec-osf1.
-
-Tue Oct 19 11:41:55 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in: Remove -O from CXXFLAGS for consistency with CFLAGS,
- and gdb/testsuite/Makefile.in.
-
-Sat Oct 9 18:39:07 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure.in: recognize mips*- instead of mips-
-
-Fri Oct 8 14:15:39 1993 Ken Raeburn (raeburn@cygnus.com)
-
- * config.sub: Accept linux*coff and linux*elf as operating
- systems.
-
-Tue Oct 7 14:24:41 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * ltmain.sh: Handle symlinks in generated script.
-
-Thu Oct 7 12:57:19 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * config.sub: Recognize mips64, and mips3 as an alias for it.
-
-Wed Oct 6 13:54:21 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * configure.in: Remove alpha-dec-osf*, no longer necessary now that
- gdb knows how to handle OSF/1 shared libraries.
-
-Tue Oct 5 11:55:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in: Recognize hppa*-*-hiux* (currently synonym for hpux).
- * config.guess: Recognize Hitachi's HIUX.
- * config.sub: Recognize h3050r* and hppahitachi.
- Remove redundant cases for hp9k[23]*.
-
-Mon Oct 4 16:15:09 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure.in: default to '--with-gnu-as' and '--with-gnu-ld'
- if gas and ld are in the source tree and are in ${configdirs}.
- If ${use_gnu_as} or ${use_gnu_ld} are 'no', then don't set the
- --with options (but still pass them down on the command line,
- if they were explicitly specified).
-
-Wed Oct 1 13:11:27 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * configure: Handle autoconf style directory options: --bindir,
- --datadir, --includedir, --infodir, --libdir, --libexecdir,
- --mandir, --oldincludedir, --sbindir, --sharedstatedir,
- --sysconfdir.
- * Makefile.in (sbindir, libexecdir, sysconfdir): New variables.
- (sharedstatedir, localstatedir, oldincludedir): New variables.
- (BASE_FLAGS_TO_PASS): Pass down bindir, datadir, includedir,
- infodir, libdir, libexecdir, localstatedir, mandir, oldincludedir,
- sbindir, sharedstatedir, and sysconfdir.
-
-Fri Sep 24 19:11:13 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure: substitute SHELL value in Makefile.in with
- ${CONFIG_SHELL}
-
-Wed Sep 24 15:18:32 1997 Ian Lance Taylor <ian@cygnus.com>
-
- * ltmain.sh: Tweak shell pattern to avoid bug in NetBSD /bin/sh.
-
-Thu Sep 23 18:05:13 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure.in: Build gas, ld, and binutils for *-*-sysv4* and
- *-*-solaris2* targets.
-
-Sun Sep 19 17:01:41 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * Makefile.in: define M4, and pass it down to sub-makes;
- all-autoconf now depends on all-m4
-
-Sat Sep 18 00:38:23 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * Makefile.in ({AR,RANLIB}_FOR_TARGET): make contingent on
- presence of {ar,ranlib} instead of a configured directory
-
-Wed Sep 15 08:41:44 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
-
- * config.guess: Accept 34?? as well as 33?? for NCR.
-
-Mon Sep 13 12:28:43 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure.in: grab mt-hppa for HPPA targets; use 'gas ' instead
- of 'gas' in sed commands, since 'gash' is now in the tree as well.
-
-Fri Sep 10 11:23:52 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure: grab values for $(CC) and $(CXX) from the
- environment, so that someone can do "CC=gcc configure; make" and
- have it work right (matching the way that autoconf works now)
-
- * configure.in, Makefile.in: add support for gash, the tcl
- interface to Galaxy
-
- * config.guess: add NetBSD variants (hp300, x86)
-
-Thu Sep 9 16:48:52 1993 Jason Merrill (jason@deneb.cygnus.com)
-
- * install.sh: Support -d option (in the manner of SunOS 4 install,
- as it is more deterministic than that of GNU install)
- (chmodcmd): Set file to mode 755 by default (should also do default
- chgrp and chown, but I don't feel like dealing with that now)
-
-Tue Sep 7 11:59:39 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * config.sub: Remove h8300hhms alias.
-
-Tue Aug 31 11:00:09 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in: Match *-*-solaris2* not *-sun-solaris2*.
-
-Mon Aug 30 18:29:10 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * Makefile.in (gcc-no-fixedincludes): touch stmp-fixproto as well
- as stmp-fixinc
-
-Wed Aug 25 16:35:59 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * config.sub: recognize m88110-bug-coff.
-
-Tue Aug 24 10:23:24 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * Makefile.in (all-libio): all dependencies on the toolchain used
- to build this (gcc, gas, ld, etc)
-
-Fri Aug 20 17:24:24 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: Deal with OSF/1 1.3 on alpha.
-
-Thu Aug 19 11:43:04 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * install.sh: add some 'else true' clauses for portability
-
- * configure.in: don't build libio for h8[35]00-*-* targets
-
-Tue Aug 17 19:02:31 1993 Per Bothner (bothner@kalessin.cygnus.com)
-
- * Makefile.in: Add support for new libio.
-
-Sun Aug 15 20:48:55 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * install.sh: If one command fails, don't try the rest. Don't try
- to remove $dsttmp (via trap) unless we have already created it.
- If $src doesn't exist, detect it and exit with an error.
-
- * config.guess: Recognize BSD on hp300.
-
-Wed Aug 11 18:35:13 1993 Per Bothner (bothner@kalessin.cygnus.com)
-
- * config.guess: Map (9000/[34]??:HP-UX:*:*) to m68k-hp-hpux.
- Bug report from "Hamish (H.I.) Macdonald" <hamish@bnr.ca>.
-
-Wed Aug 11 15:37:51 1993 Jason Merrill (jason@deneb.cygnus.com)
-
- * Makefile.in (all-send-pr): depends on all-prms
-
-Wed Aug 11 16:56:03 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: Fix typo (9000/8??:4.3bsd -> 9000/7??:4.3bsd).
-
-Fri Aug 6 14:45:02 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * config.guess: From michael@mercury.cs.mun.ca (Michael Rendell):
- Added test for mips-mips-riscos5.
-
-Thu Aug 5 15:45:08 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure.in: use mh-hp300 for 68k HP hosts
-
-Mon Aug 2 11:56:53 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure: add support for CONFIG_SHELL, so that you can use
- some alternate shell for evaluating configure scripts
-
-Sun Aug 1 11:36:27 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * Makefile.in (make-gdb.tar.gz): Sed bug reporting address
- in configure script to bug-gdb@prep.ai.mit.edu when building
- distribution archive.
- * Makefile.in (COMPRESS): Remove def.
- * Makefile.in (gdb.tar.gz, make-gdb.tar.gz): Renamed from
- gdb.tar.Z and make-gdb.tar.Z respectively.
- * Makefile.in (make-gdb.tar.gz): Now only build gzip'd archive.
- * Makefile.in (make-gdb.tar.gz): Minor changes to move closer
- to convergence with 'taz' target in Makefile.in.
-
-Fri Jul 30 12:34:57 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * install.sh (dsttmp): use trap to ensure that tmp files go
- away on error conditions
-
-Wed Jul 28 11:57:36 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * Makefile.in (BASE_FLAGS_TO_PASS): remove LOADLIBES
-
-Tue Jul 27 12:43:40 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (install-dirs): Deal with a prefix like /gnu;
- its parent is '/' not ''.
-
- * Makefile.in (DEVO_SUPPORT): Add comments about ChangeLog.
-
-Fri Jul 23 09:53:37 1993 Jason Merrill (jason@wahini.cygnus.com)
-
- * configure: if ${newsrcdir}/configure doesn't exist, don't assume
- that ${newsrcdir}/configure.in does.
-
-Tue Jul 20 11:28:50 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * test-build.mk: support for CONFIG_SHELL
-
-Mon Jul 19 21:54:46 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * config.sub (netware): Add as a basic system type.
-
-Wed Jul 14 12:03:11 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * Makefile.in (Makefile): depend on configure.in. Also drop the
- $(srcdir)/ from the dependency on Makefile.in.
-
-Tue Jul 13 20:10:58 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * config.sub: Recognize h8300hhms as h8300h-hitachi-hms.
- (h8300hhms is temporary until multi-libraries are implemented).
- * configure.in: Handle h8300h too.
-
-Sun Jul 11 17:35:27 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: Recognize dpx/2 as m68k-bull-sysv3.
-
-Thu Jul 8 18:26:12 1993 John Gilmore (gnu@cygnus.com)
-
- * configure: Remove extraneous output when guessing host type.
- * config.guess: Remove extraneous output when guessing using C
- compiler rather than uname, or when guessing fails.
-
-Wed Jul 7 17:58:14 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com)
-
- * Makefile.in: remove all.cross and install.cross targets
-
- * configure: remove CROSS=-DCROSS_COMPILE and ALL=all.cross
- definitions
-
-Tue Jul 6 10:39:44 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
-
- * configure.in (target sh): Build gprof.
-
-Thu Jul 1 16:52:56 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config.sub: change -solaris to -solaris2
-
-Thu Jul 1 15:46:16 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in: Use config/mh-riscos for mips-*-sysv*.
-
-Wed Jun 30 09:31:58 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * configure: Correct error message for missing Makefile.in to
- print correct directory.
-
-Tue Jun 29 13:52:16 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * install.sh: kludge around 386BSD shell bug
-
-Tue Jun 29 13:06:49 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * config.guess: Recognize NeXT.
- * config.guess: Recognize i486-ncr-sysv4.
- * Makefile.in (taz): rm $(TOOL)-$$VER before linking.
-
-Tue Jun 29 12:50:57 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (MAKEINFOFLAGS): New variable.
- (FLAGS_TO_PASS): Pass MAKEINFO as MAKEINFO MAKEINFOFLAGS.
- * build-all.mk, test-build.mk: Pass down --no-split as
- MAKEINFOFLAGS when hosted on DOS. Compile DOS hosted without -g.
-
-Thu Jun 24 13:39:11 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * Makefile.in (DEVO_SUPPORT): Add COPYING COPYING.LIB install.sh.
-
-Wed Jun 23 12:59:21 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * Makefile.in (libg++.tar.z): New rule.
- * Makefile.in (taz): Replace 'configure -rm' by 'make distclean'.
- * Makefile.in (taz): Only do a single chmod.
-
-Fri Jun 18 12:03:10 1993 david d `zoo' zuhn (zoo at majipoor.cygnus.com)
-
- * install.sh: don't use dirname anymore (replaced with sed usage)
-
-Thu Jun 17 18:43:42 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in: Change extension for gzip'd files from '.z' to
- '.gz' per new FSF standard usage.
-
-Thu Jun 17 16:58:50 1993 david d `zoo' zuhn (zoo at majipoor.cygnus.com)
-
- * configure: put quotes around the final value of program_transform_name
-
-Tue Jun 15 16:48:51 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: new install.sh support; update install-info rules
-
-Wed Jun 9 12:31:34 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * configure.in: Build diff for crosses, but not for go32 host.
-
- * configure.in: Build gprof only for native, and don't build it
- for mips-*-*, rs6000-*-*, or i[34]86-*-sco*.
-
-Mon Jun 7 13:12:11 1993 david d `zoo' zuhn (zoo at deneb.cygnus.com)
-
- * configure.in: don't build gas,ld,binutils on for *-*-sysv4
-
-Mon Jun 7 11:40:11 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
-
- * configure.in (host_tools): Add prms.
-
-Fri Jun 4 13:30:42 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: install gcc, do installation of $(INSTALL_MODULES)
- with $(FLAGS_TO_PASS) on the command line
-
- * config.sub: Recognize lynx and lynxos
-
-Fri Jun 4 10:59:56 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * config.sub: Accept -ecoff*, not just -ecoff.
-
-Thu Jun 3 17:38:54 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (taz): Use .gz suffix instead of .z.
- (binutils.tar.gz, gas+binutils.tar.gz, gas.tar.gz): Fixed target
- names.
-
-Thu Jun 3 00:27:06 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in (vault-install): add an 'else true' (for Ultrix)
-
-Wed Jun 2 18:19:16 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in (install-no-fixedincludes): install gcc last, so
- that rebuilds that might happen during 'make install' don't get
- bogus gcc include files
-
-Wed Jun 2 16:14:10 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- Change from Utah for HPPA support:
- * config.guess: Recognize hppa1.x-hp-bsd.
-
-Wed Jun 2 11:53:33 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * config.guess: Add support for Motorola Delta 68k, up to r3v7.
- Patch from pot@fly.cnuce.cnr.it (Francesco Potorti`).
-
-Tue Jun 1 17:48:42 1993 Rob Savoye (rob at darkstar.cygnus.com)
-
- * config.sub: Add support for rom68k and bug boot monitors.
-
-Mon May 31 09:36:37 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * Makefile.in: Make all-opcodes depend on all-bfd.
-
-Thu May 27 08:05:31 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * config.guess: Added special check for i[34]86-univel-sysv4*.
-
-Wed May 26 16:33:40 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * config.guess: For i[34]86-unknown-sysv4 use UNAME_MACHINE for
- the processor rather than assuming i486.
-
-Wed May 26 09:40:18 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config.guess: Recognize SunOS6 as Solaris3.
-
-Tue May 25 23:03:11 1993 Per Bothner (bothner@cygnus.com)
-
- * config.guess: Fix typo. Avoid #elif (not in K&R 1).
- Recognize SunOS 5.* only (and not [6-9].*) as being Solaris2.
-
-Tue May 25 12:44:18 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * build-all.mk (all-cross): New target for Canadian Cross.
- Added Q2 go32 targets.
- * test-build.mk: Configure go32 cross sparclite-aout and
- mips-idt-ecoff -with-gnu-ld. Moved build binary directory from
- PARTIAL_HOLE_DIRS to BUILD_HOLES_DIRS.
-
-Mon May 24 15:30:06 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: fix Alpha GDB typo; also, don't build DejaGnu for
- GO32 hosted toolchains
-
-Mon May 24 14:18:41 1993 Rob Savoye (rob at darkstar.cygnus.com)
-
- * configure: change so "-exec-prefix" gets passed down rather
- than "-exec_prefix" so autoconf generated Makefiles get the
- exec_prefix set right.
-
-Fri May 21 10:42:25 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config.guess: get the Solaris2 minor version number
-
- * Makefile.in: add standards.texi and make-stds.texi to ETC_SUPPORT
-
-Fri May 21 06:20:52 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
-
- * config.guess: Recognize some Sequent platforms.
-
-Thu May 20 14:33:48 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: added the vault-install target
-
- * configure.in: actually use the Sun3 makefile fragment that's in
- config, also added the release dir to configdirs
-
-Thu May 20 14:19:18 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (taz): Fix modes on stuff in $(TOOL) dir also.
-
-Tue May 18 20:26:41 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: remove some program from Alpha targetted toolchains
-
-Tue May 18 15:23:19 1993 Ken Raeburn (raeburn@cygnus.com)
-
- * Makefile.in (DISTSTUFFDIRS): Renamed from PROTODIRS. Add ld and
- gprof.
- (taz): Run "make diststuff" in those directories instead of "make
- proto-dir". Look for "VERSION=" only at start of line in subdir
- Makefile. Use "gzip -9" for compression.
- (TEXINFO_SUPPORT, DIST_SUPPORT, BINUTILS_SUPPORT_DIRS): New vars.
- (binutils.tar.z): New target.
-
-Mon May 17 17:01:15 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
-
- * Makefile.in (taz): Include gpl.texinfo.
-
-Fri May 14 06:48:38 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
-
- * Makefile.in (setup-dirs): Merged into "taz" target.
- (taz): Only do `proto-dir' stuff if a directory is actually needed
- for this target.
-
-Wed May 12 13:09:44 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (MUNCH_NM): New variable, defined to be $(NM).
- (FLAGS_TO_PASS): Pass down MUNCH_NM.
- (HOST_CC, HOST_PREFIX, HOST_PREFIX_1): New variables.
- (EXTRA_GCC_FLAGS): Pass down HOST_* variables.
- (gcc-no-fixedincludes): Correct for current gcc Makefile.
-
-Tue May 11 10:14:25 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (make-gdb.tar.Z): Add configure, config.guess,
- config.sub, and move-if-change to gdb testsuite distribution
- archive, so the testsuite can be extracted, configured, and
- run separately from the gdb distribution. Blow away the Chill
- tests that require a Chill compiled executable, since GNU Chill
- is not yet publically available.
-
-Mon May 10 17:22:26 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * test-build.mk: set environment variables in a single command,
- instead of a list of assignments and exports
-
- * config.guess: recognize Alpha/OSF1 systems
-
-Mon May 10 14:55:51 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * configure: Change help message to prefer --options rather than
- -options.
-
-Mon May 10 05:58:35 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
-
- * config.sub: Convergent Tech. "miniframe" uses m68010, sez
- zippy@ecst.csuchico.edu.
- * config.guess: Recognize miniframe.
-
-Sun May 9 17:47:57 1993 Rob Savoye (rob at darkstar.cygnus.com)
-
- * Makefile.in: Use srcroot to find runtest rather than rootme.
- Pass RUNTESTFLAGS and EXPECT down in BASE_FLAGS_TO_PASS.
-
-Fri May 7 14:55:59 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * test-build.mk: Extensive additions to support building on a
- machine other than the host.
-
-Wed May 5 08:35:04 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
-
- * configure (tooldir): Fix for i386-aix again.
-
-Mon May 3 19:00:27 1993 Per Bothner (bothner@cygnus.com)
-
- * configure, Makefile.in: Change definition of $(tooldir)
- to match the FSF.
-
-Fri Apr 30 15:55:21 1993 Fred Fish (fnf@cygnus.com)
-
- * config.guess: Recognize i[34]86/SVR4.
-
-Fri Apr 30 15:52:46 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * Makefile.in (all-gdb): gdb depends on sim.
-
-Thu Apr 29 23:30:48 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (gdb.tar.Z): Make prototype gdb testsuite directory
- at the same time we make the prototype gdb directory.
- * Makefile.in (make-gdb.tar.Z): Make the testsuite distribution
- files at the same time as the gdb base release distribution.
-
-Thu Apr 29 12:50:37 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (check): Use individual check targets rather than
- DO_X rule.
- (check-gcc): Added.
-
-Thu Apr 29 09:50:07 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * config.sub: Use sysv3.2 not sysv32 for canonical OS
- for System V release 3.2.
-
-Thu Apr 29 10:33:22 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * config.sub: Recognize hppaosf.
- * configure.in: Do configure ld/binutils/gas for it.
-
-Tue Apr 27 06:25:34 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
-
- * configure (tooldir): Alter syntax used to set this, for systems
- where "\$" isn't handled right, like i386-aix.
-
-Thu Apr 22 08:17:35 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * configure: Pass program-transform-name, not
- program_transform_name, to recursive configures.
-
-Thu Apr 22 02:58:21 1993 Ken Raeburn (raeburn@cygnus.com)
-
- * Makefile.in (gas+binutils.tar.z): New rule for building snapshots
- of gas+ld+binutils.
-
-Mon Apr 19 17:41:30 1993 Per Bothner (bothner@cygnus.com)
-
- * config.guess: Recognize AIX3.2 as distinct from 3.1.
-
-Sat Apr 17 17:19:50 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: rename m88k-motorola-m88kbcs to m88k-motorola-sysv
-
- * config/mh-delta88: remove extraneous GCC references
-
-Tue Apr 13 16:52:16 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
-
- * Makefile.in (PRMS): Set back to all-prms.
-
-Sat Apr 10 12:04:07 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * test-build.mk: Pass -with-gnu-as for known MIPS native and MIPS
- targets, rather than for MIPS hosts.
-
-Fri Apr 9 13:51:06 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: add comment for --with-x default values
-
- * config.guess: handle Motorola Delta88 box for SVR3 and SVR4.
-
- * Makefile.in: add check-* targets for each of the directories in
- the tree. Add a definition of RUNTEST that will use the one we
- just built, if it exists. Pass this down via FLAGS_TO_PASS.
-
-Thu Apr 8 09:21:30 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * configure.in: Removed obsolete references to bfd_target and
- target_makefile_frag.
-
- * build-all.mk: Set assorted targets for Q2.
- * config.sub: Recognize z8k-sim and h8300-hms.
- * test-build.mk: Really don't pass host to configure.
- (HOLES): Added uname.
-
-Wed Apr 7 15:48:19 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * configure: Handle an empty program-prefix, program-suffix or
- program-transform-name correctly.
-
-Tue Apr 6 13:48:41 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * build-all.mk: -G 8 no longer required for MIPS targets.
- * test-build.mk: Don't pass host argument to configure; make it
- guess.
-
-Tue Apr 6 10:36:53 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (gdb.tar.Z): Fix for building gzip'd distribution.
- * Makefile.in (COMPRESS): New macro, like GZIP.
-
-Fri Apr 2 09:02:31 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * test-build.mk: Use -with-gnu-as for mips-sgi-irix4 as well.
-
- * build-all.mk: Set GCC to gcc -O -G 8 for MIPS targets, since gcc
- with gas currently defaults to -G 0.
-
-Thu Apr 1 08:25:42 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (all-flex): flex depends on byacc.
-
- * build-all.mk: If host not specified, use config.guess. Pass TAG
- to test-build.mk as RELEASE_TAG.
- * test-build.mk (configargs): New variable containing arguments to
- pass to configure. Set to -with-gnu-as on mips-dec-ultrix.
- (FLAGS_TO_PASS): Pass down RELEASE_TAG.
-
- * config.guess: Use /bin/uname when checking -X argument on SCO,
- to avoid invoking GNU uname which doesn't understand -X.
-
- * test-build.mk: Don't use /usr/unsupported/bin/as on AIX.
-
- * configure.in: Build gas for mips-*-*.
-
-Wed Mar 31 21:20:58 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in (all.normal): insert missing backslash.
-
-Wed Mar 31 12:31:56 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * build-all.mk, config/mh-irix4: Bump -XNh value to 1500 to match
- gcc requirements.
-
- * Makefile.in: Complete overhaul to merge many almost identical
- targets.
-
-Tue Mar 30 20:17:01 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (setup-dirs-gdb): Renamed from setup-dirs.
- (gdb.tar.Z): Adjusted.
-
- * Makefile.in (setup-dirs, taz): New targets; should be general
- enough to adapt for gdb sometime. Build only .z file.
- (gas.tar.z): New target.
-
-Tue Mar 30 10:03:09 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * build-all.mk: Use CC=cc -Xs on Solaris.
-
-Mon Mar 29 19:59:26 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config/mh-sun3: cc needs -J to compile cp-parse.c correctly
-
- * config/mh-solaris: SunPRO C needs -Xs to be able to get a
- working xmakefile for Emacs.
-
-Thu Mar 25 15:14:30 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in: Incorporate changes suggested by wilson@cygnus.com
- for handling BISON for FSF releases.
-
-Thu Mar 25 06:19:48 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
-
- * configure: Actually implement the change zoo just documented.
-
-Wed Mar 24 13:02:44 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
-
- * configure: when using config.guess, only set target_alias when
- it's not already been set (ie, on the command line)
-
-Mon Mar 22 23:07:39 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: add installcheck target, set PRMS to install-prms
-
-Sun Mar 21 16:46:12 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure: add support for package_makefile_fragment, handle the
- case where a directory has a configure.in file but no Makefile.in
- more gracefully (with an actual understandable error message, even);
- add support for --without (and add this to the usage message); also
- explicitly add a --host=${host_alias} to the command line when
- config.guess is used
-
-Sun Mar 21 12:11:58 1993 Jim Wilson (wilson@sphagnum.cygnus.com)
-
- * configure: Must use both --host and --target in recursive calls.
-
-Thu Mar 18 12:31:35 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in: Change deja-gnu to dejagnu.
-
-Mon Mar 15 15:44:35 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * configure.in (h8300-*-*, h8500-*-*): Don't build libg++.
-
-Fri Mar 12 18:30:14 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: canonicalize all instances to *-*-solaris2*,
- also strip out a number of tools to not build for go32 host
-
-Wed Mar 10 12:08:27 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * config.guess: add GPL.
-
- * Makefile.in, config.guess, config.sub, configure: bump
- copyrights to 93.
-
-Wed Mar 10 07:12:48 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (do-info): Removed obsolete check for existence of
- localenv file.
-
- * Makefile.in (MAKEOVERRIDES): Define to be empty.
-
-Wed Mar 10 03:11:56 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: a couple of 'else true' for decstation,
- support for TclX
-
- * configure.in: configure tclX too; don't remove Tk on RS/6000 anymore
-
-Tue Mar 9 16:06:12 1993 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in (setup-dirs): change invocation of make to $(MAKE).
-
-Mon Mar 8 14:52:11 1993 Ken Raeburn (raeburn@cambridge)
-
- * config.guess: Recognize i386-ibm-aix (PS/2).
- * configure.in: Use config/mh-aix386 file for it.
-
-Mon Mar 8 11:12:43 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (GCC_FOR_TARGET): Eliminated definition; use
- CC_FOR_TARGET instead.
- (BASE_FLAGS_TO_PASS): Pass GCC_FOR_TARGET=$(CC_FOR_TARGET).
-
-Wed Mar 3 16:00:28 1993 Steve Chamberlain (sac@ok.cygnus.com)
-
- * Makefile.in: Add sim to list of directories sent with gdb
-
-Wed Mar 3 11:42:39 1993 Ken Raeburn (raeburn@cygnus.com)
-
- * configure.in: Put back mips-dec-bsd* case.
-
-Tue Mar 2 21:15:58 1993 Fred Fish (fnf@cygnus.com)
-
- (Ultrix 2.2 support from Michael Rendell <michael@mercury.cs.mun.ca>)
- * configure.in (vax-*-ultrix2*): Add Ultrix 2.2 triplet.
- * config.guess: Change 'VAX*:ULTRIX:*:*' to 'VAX*:ULTRIX*:*:*'.
- * config/mh-vaxult2: New file.
-
-Tue Mar 2 18:11:03 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: remove no-op mips-dec-bsd* in "case $target"
-
- * Makefile.in (dir.info): only run gen-info-dir if it exists,
- (install-info): install dir.info only if it exists,
- (all-expect, install-expect): pass along X11_FLAGS_TO_PASS
-
-Tue Mar 2 09:01:30 1993 Ken Raeburn (raeburn@cygnus.com)
-
- * configure.in: For vms target, skip bfd, ld, binutils. Do build
- gas for mips-dec-bsd.
-
-Tue Mar 2 08:35:24 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * configure (makesrcdir): If ${srcdir} is relative and not ".",
- and ${subdir} is not ".", set makesrcdir based on ${invsubdir}.
-
-Tue Feb 23 14:18:28 1993 Mike Werner (mtw@poseidon.cygnus.com)
-
- * configure.in: Added "dejagnu" to hosttools list.
-
-Mon Feb 22 23:28:38 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * config.sub, configure.in, config.guess: Add support
- for Bosx, an AIX variant from Bull.
- Patches from F.Pierresteguy@frcl.bull.fr.
-
-Sun Feb 21 11:15:22 1993 Mike Werner (mtw@poseidon.cygnus.com)
-
- * devo/dejagnu: Initial creation of devo/dejagnu.
- Migrated dejagnu testcases and support files for testing software
- tools to reside as subdirectories, currently called "testsuite",
- within the directory of the software tool. Migrated all programs,
- support libraries, etc. beloging to dejagnu proper from
- devo/deja-gnu to devo/dejagnu. These files were moved "as is"
- with no modifications. The changes to these files which will
- allow them to configure, build, and execute properly will be made
- in a future update.
-
-Fri Feb 19 20:19:39 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
-
- * Makefile.in: Change send_pr to send-pr.
- * configure.in: Likewise.
- * send_pr: Renamed directory to send-pr.
-
-Fri Feb 19 19:00:13 1993 Per Bothner (bothner@cygnus.com)
-
- * Makefile.in: Add some extra semi-colons (needed if SHELL=bash).
-
-Fri Feb 19 00:59:33 1993 John Gilmore (gnu@cygnus.com)
-
- * README: Update for gdb-4.8 release.
- * Makefile.in (gdb.tar.Z): Add texinfo/tex3patch. Build
- gdb-xxx.tar.z (gzip'd) file also.
-
-Thu Feb 18 09:16:17 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: make all-diff depend on all-libiberty
-
-Tue Feb 16 16:06:31 1993 K. Richard Pixley (rich@cygnus.com)
-
- * config.guess: add vax-ultrix in the spirit of mips-ultrix.
-
-Tue Feb 16 05:57:15 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in, Makefile.in: add hello, tar, gzip, recode, indent
-
-Tue Feb 16 00:58:20 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (DEVO_SUPPORT): Remove etc directory
- (ETC_SUPPORT): Only add the files GDB wants from etc/.
- (gdb.tar.Z): Use ETC_SUPPORT. Use byacc when building the file.
-
-Thu Feb 11 20:14:28 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: makeinfo binary is in a new location
-
-Tue Feb 9 12:42:27 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * config.sub: Accept -ecoff as an OS.
-
- * Makefile.in: Various changes to eliminate a level of make
- recursion and reduce the required command line length.
- (BASE_FLAGS_TO_PASS): New variable holding flags passed to all
- sub-makes.
- (EXTRA_HOST_FLAGS, EXTRA_TARGET_FLAGS, EXTRA_GCC_FLAGS): New
- variables holding settings for specific sub-makes.
- (FLAGS_TO_PASS, TARGET_FLAGS_TO_PASS, GCC_FLAGS_TO_PASS): Rewrote
- in terms of BASE_FLAGS_TO_PASS.
- (TARGET_LIBS): New variable listing directories which use
- TARGET_FLAGS_TO_PASS.
- (subdir_do): Eliminated.
- (do-*): New set of targets to replace subdir_do.
- (various): All targets which used subdir_do now depend on do-*.
- (local-clean): Renamed from do_clean.
- (local-distclean): New target, dependency of distclean and
- realclean.
- (install-info): Don't create directories. Depend on dir.info
- rather than calling make recursively.
- (install-dir.info): Eliminated.
- (install-info-dirs): Create all info directories here.
- (dir.info): Depend upon do-install-info.
-
- * test-build.mk (HOLES): Added false.
-
-Sat Feb 6 14:05:09 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * config.guess: Recognize BSDI and BSDJ (Jolitz 386bsd).
-
-Thu Feb 4 20:49:18 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in (info): remove dependency on all-texinfo. The
- problem was really in texinfo/C, not at this level.
-
-Thu Feb 4 13:38:41 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (info): Added dependency on all-texinfo (PR 2112).
-
-Thu Feb 4 01:50:53 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (make-gdb.tar.Z): Change BISON to 'bison -y' for
- GDB releases.
-
-Wed Feb 3 17:22:16 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * configure: Include srcdir in message about target of link not
- being found. Don't convert `-' to `_' in `with' options being
- passed to subdirs.
-
-Tue Feb 2 18:57:59 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: add uudecode to host_tools
-
- * Makefile.in: added {all,install}-uudecode targets, added them to
- the appropriate lists
-
-Tue Feb 2 11:45:53 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (all-gcc): Added dependency on all-gas.
-
- * configure.in (mips-*-*): Build ld and binutils.
-
-Mon Feb 1 12:35:41 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * configure: check return code from mkdir, print error message and
- exit on failure.
-
-Sat Jan 30 16:40:28 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (make-gdb.tar.Z): New location for texinfo.tex.
-
-Thu Jan 28 15:09:59 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * test-build.mk (HOLES): Added tar, cpio and uudecode.
-
-Wed Jan 27 16:50:32 1993 Jim Wilson (wilson@sphagnum.cygnus.com)
-
- * config.sub (h8500): Recognize this as a cpu type.
-
-Sat Jan 23 20:32:01 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure: source directory missing is no longer a warning
-
- * configure.in: recognize irix[34]* instead of irix[34]
-
- * Makefile.in: define and pass down X11_LIB
-
- * config/mh-sco: define X11_LIB to the mess that SCO ODT requires
-
-Sat Jan 23 13:49:40 1993 Per Bothner (bothner@cygnus.com)
-
- * guess-systype: Renamed to ...
- * config.guess: ... by popular request.
- * configure.in, Makefile.in: Update accordingly.
-
-Thu Jan 21 12:20:55 1993 Per Bothner (bothner@cygnus.com)
-
- * guess-systype: Patches from John Eaton <jwe@che.utexas.edu>:
- + Add Convex, Cray/Unicos, and Encore/Multimax support.
- + Execute ./dummy instead of assuming . is in PATH.
-
-Tue Jan 19 17:18:06 1993 Per Bothner (bothner@cygnus.com)
-
- * guess-systype: New shell script. Attempts to guess the
- canonical host name of the executing host.
- Only a few hosts are supported so far.
- * configure: Call guess-systype if no host is specified.
-
-Tue Jan 19 08:26:07 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (gcc-no-fixedincludes): Made to work with current
- gcc Makefile.
-
-
-Fri Jan 15 10:27:02 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (GCC_FLAGS_TO_PASS): New variable.
- (all-gcc, install-gcc, subdir_do): Use it.
-
-Wed Jan 13 17:06:45 1993 Jim Wilson (wilson@sphagnum.cygnus.com)
-
- * Makefile.in: Rename uninstalled gcc driver from gcc to xgcc.
-
-Wed Jan 6 20:29:16 1993 Mike Werner (mtw@rtl.cygnus.com)
-
- * Makefile.in: Removed explicit setting of SUBDIRS. SUBDIRS is now
- set exclusively by configure, using configure.in .
-
-Wed Jan 6 13:44:11 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * test-build.mk: set $PATH for all builds
-
- * Makefile.in: pass TARGET_FLAGS_TO_PASS for xiberty and libm
-
-Wed Jan 6 11:02:10 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (GCC_FOR_TARGET): Supply a default that matches
- the one used in gcc/Makefile.in, so that a null expansion doesn't
- override the one needed to build gcc with a native cc.
-
-
-Tue Jan 5 07:55:12 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * configure: Accept -with arguments.
-
-Sun Jan 3 15:15:09 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * Makefile.in: added h8300sim
-
-Tue Dec 29 15:06:00 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * config/mh-sco: Don't override BISON definition.
-
- * build-all.mk: If canonhost is i386-unknown-sco3.2v4, change it
- to i386-sco3.2v4. Set TARGETS and CFLAGS for i386-sco3.2v4.
- (all-cygnus, native, build-cygnus): Make
- $(canonhost)-stamp-3stage-done, not $(host)....
- * test-build.mk (stamp-3stage-compared): Use tail +10c for
- i386-sco3.2v4. Added else true to if command.
-
-Mon Dec 28 12:08:56 1992 Ken Raeburn (raeburn@cygnus.com)
-
- * config.sub: (from FSF) Sequent uses a BSD-like OS.
-
-Mon Dec 28 08:32:06 1992 Minh Tran-Le (mtranle@paris.intellicorp.com)
-
- * configure.in (i[34]86-*-isc*): added; uses mh-sysv.
-
-Thu Dec 24 17:26:24 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: don't remove binutils from Solaris builds
-
-Thu Dec 24 14:08:38 1992 david d`zoo' zuhn (zoo@cygnus.com)
-
- * Makefile.in: get rid of earlier definitions for *clean,
- also handle the recursive info rule better
-
-Thu Dec 24 12:40:21 1992 Per Bothner (bothner@rtl.cygnus.com)
-
- * Makefile.in (mostlyclean, distclean, realclean): Fix to
- do more-or-less the right thing.
-
-Wed Dec 16 10:25:31 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in: Add lines defining CC and CXX, and use CXX rather
- than gcc in definitions of CXX_FOR_BUILD and CXX_FOR_TARGET.
-
-Tue Dec 15 00:34:32 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: change all $(host_cpu)-$(host_vendor)-$(host_os) to
- $(host_canonical).
-
- * configure.in: split the configdirs list into 4 categories (native
- v. cross, library v. tool) and handle the cross-only and native-
- only in more reasonable (and correct!) way.
-
-Mon Dec 14 17:04:22 1992 Stu Grossman (grossman at cygnus.com)
-
- * configure.in (hppa*-*-*): Don't remove bfd and gdb from
- configdirs anymore.
-
-Sun Dec 13 00:37:26 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: extensive cleanup:: removed all of the explicit
- clean-* targets, collapsed many wrappers around subdir_do into
- one, added additional targets to satisfy standards.texi, deleted
- some old targets, some changes for consistency
-
-Fri Dec 11 20:18:02 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: handle some programs as cross-only, and others as
- native only
-
- * test-build.mk: handle partial holes in a more generic manner
-
- * Makefile.in: m4 depends on libiberty
-
-Mon Dec 7 06:43:27 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config/mh-sco: don't default $(CC) to gcc
-
-Thu Dec 3 21:52:11 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: add m4, textutils, fileutils, sed, shellutils,
- time, wdiff, and find to configdirs
-
- * Makefile.in: all, clean, and install rules for the new programs
- added to configure.in
-
-Mon Nov 30 14:54:34 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: use mh-sun for all *-sun-* hosts
-
- * config/mh-solaris: rework standard X location to use
- $OPENWINHOME, if defined.
-
- * config/mh-sun: handle X11 include locations
-
- * config/mh-decstation: define NeedFunctionPrototypes to 0, to
- work around dain-bramaged DECwindows include files
-
-Fri Nov 27 18:35:54 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: define flags for X11 include files and library file
- locations, pass them down to the programs that need this info
-
- * build-all.mk: added a 'native' target, to 3stage the native toolchain
-
- * config/{mh-hpux,mh-solaris}: define the "standard" locations for
- the vendor supplied X11 headers and libraries
-
-Sun Nov 22 18:59:13 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: start building libg++ for HP-UX targets
-
-Wed Nov 18 19:33:11 1992 John Gilmore (gnu@cygnus.com)
-
- * README: Update references to files moved into etc/.
-
-Sun Nov 15 09:36:08 1992 Fred Fish (fnf@cygnus.com)
-
- * config.sub (i386sol2, i486sol2): i[34]86-unknown-solaris2.
- * configure.in (i[34]86-*-solaris2*): Use config/mh-sysv4.
-
-Thu Nov 12 08:50:42 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * configure: accept dash as well as underscore in long option
- names for FSF compatibility.
-
-Wed Nov 11 08:04:37 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * config.sub: added -sco3.2v4 support from FSF.
-
-Sun Nov 8 21:14:30 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: expand the section that adds or removes
- directories from the list of programs to build, to handle native
- vs. cross in addition to host v. native
-
-Sat Nov 7 18:52:27 1992 Per Bothner (bothner@rtl.cygnus.com)
-
- * Makefile.in: Replace C++ in macro names with CXX.
- This is less likely to break ...
-
-Sat Nov 7 15:16:58 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * test-build.mk: add -w to GNU_MAKE
-
-Fri Nov 6 23:10:37 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config.sub: remove 'sparc'-->'sparc-sun' default transformation,
- add 'sparc' to list of recognized cpus. This needed to make
- 'sparc-aout' expand to 'sparc-unknown-aout' instead of 'sparc-sun-aout'.
- Delete some redundant ose68 variants. Recognize -wrs as an os,
- then changes that into $CPU-wrs-vxworks.
-
- * configure.in: remove most references to gdbtest, regularize
- target based program removal
-
- * test-build.mk: import from p3 tree (many fixes and changes)
-
-Fri Nov 6 20:59:00 1992 david d `zoo' zuhn (zoo@cygnus.com)
-
- * Makefile.in: added rules to handle tcl, tk, and expect
-
- * configure.in: handle those directories if they exist
-
-Thu Nov 5 14:35:41 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config.sub: removed bogus hppabsd and hppahpux names, since
- "hppa" is not a valid cpu (hppa1.1 or hppa1.0 are, though)
-
-Thu Oct 29 00:12:41 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: all-gcc now depends on all-binutils. all-libg++
- depends upon all-xiberty
-
- * Makefile.in: changes from p3, including:
-
- Thu Oct 8 15:00:17 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (XTRAFLAGS): include newlib directories if
- newlib/Makefile exists, rather than if host != target.
-
- Fri Sep 25 13:41:52 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in: added -nostdinc to XTRAFLAGS if we are using gcc
- from the same source tree and not building a cross-compiler. This
- matters for the libg++ configuration if reconfiguring a tree that
- has already been installed.
-
- Thu Sep 10 10:35:51 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in: added -I for newlib/targ-include to XTRAFLAGS, to
- pick up the machine and system specific header files.
-
- * Makefile.in: added AS_FOR_TARGET, passed down in
- TARGET_FLAGS_TO_PASS. Added CC_FOR_BUILD, which is intended to be
- the C compiler to use to create programs which are run in the
- build environment, set it to default to $(CC), and passed it down
- in FLAGS_TO_PASS and TARGET_FLAGS_TO_PASS.
-
- Mon Sep 7 22:34:42 1992 Ian Lance Taylor (ian@cirdan.cygnus.com)
-
- * Makefile.in: add $(host) = $(target) tests back to *_FOR_TARGET.
- We need them for unusual native builds, like systems without
- ranlib.
-
- * configure: also define $(host_canonical) and
- $(target_canonical), which are the full, canonical names for the
- given host and target
-
-Sun Nov 1 16:38:17 1992 Per Bothner (bothner@cygnus.com)
-
- * Makefile.in: Added separate definitions for C++.
-
-Fri Oct 30 11:37:52 1992 Fred Fish (fnf@cygnus.com)
-
- * configure.in (configdirs): Add deja-gnu.
-
-Fri Oct 23 00:39:18 1992 John Gilmore (gnu@cygnus.com)
-
- * README: Update for configure.texi and gdb-4.7 release.
-
-Wed Oct 21 21:54:27 1992 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in: Move "all" target to top of file.
- Previously, first target was ".PHONY" which caused BSD4.4 make
- to build .PHONY when make was run without arguments.
-
-Mon Oct 19 01:17:54 1992 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in: Add COPYING.LIB to GDB releases, now that there's
- Library-copylefted code in libiberty.
-
-Tue Oct 13 01:22:32 1992 John Gilmore (gnu@cygnus.com)
-
- * config.sub: Replace m68kmote with plain old m68k.
-
-Fri Oct 9 03:14:24 1992 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in: Remove space from blank line, avoid Make complaints.
-
-Thu Oct 8 18:41:45 1992 Ken Raeburn (raeburn@cygnus.com)
-
- * config.sub: Complain if no argument is given. Added support for
- 386bsd as OS and target alias.
-
-Thu Oct 8 15:07:22 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (XTRAFLAGS): include newlib directories if
- newlib/Makefile exists, rather than if host != target.
-
-Mon Oct 5 03:00:09 1992 Mark Eichin (eichin at tweedledumber.cygnus.com)
-
- * config.sub: recognize sparclite-wrs-vxworks.
-
- * Makefile.in (install-xiberty): added *-xiberty make rules (from
- p3.) Added clean-xiberty to clean.
-
-Thu Oct 1 17:59:19 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: use *-*-* instead of nested cases for host and target
-
-Tue Sep 29 14:11:18 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in: added -nostdinc to XTRAFLAGS if we are using gcc
- from the same source tree and not building a cross-compiler. This
- matters for the libg++ configuration if reconfiguring a tree that
- has already been installed.
-
-Sep 20 08:53:10 1992 Fred Fish (fnf@cygnus.com)
-
- * config.sub (i486v/i486v4): Merge in from FSF version.
-
-Fri Sep 18 00:32:00 1992 Mark Eichin (eichin@cygnus.com)
-
- * configure: only set PWD if it is already set.
-
-Thu Sep 17 23:05:53 1992 Mark Eichin (eichin@cygnus.com)
-
- * configure: just set PWD=`pwd` at the top, since Ultrix sh
- doesn't have unset and all success paths (and most error paths)
- out set it anyway. (Note: should change all uses of ${PWD=`pwd`}
- to just ${PWD} to avoid confusion.)
-
-Tue Sep 15 16:00:54 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * configure: always set $(tooldir) to $(libdir)/$(target_alias),
- even for a native compilation.
-
-Tue Sep 15 02:22:56 1992 John Gilmore (gnu@cygnus.com)
-
- Changes to make the gdb.tar.Z rule work better.
-
- * Makefile.in (GDB_SUPPORT_DIRS): Add opcodes.
- (DEVO_SUPPORT): Add configure.texi.
- (bfd-ilrt.tar.Z): Remove ancient rule.
-
-Thu Sep 10 10:43:19 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in: added -I for newlib/targ-include to XTRAFLAGS, to
- pick up the machine and system specific header files.
-
- * configure.in, config.sub: added new target m68010-adobe-scout,
- with alias of adobe68k. Changed configure.in to check for
- -scout before -sco* to avoid a false match.
-
- * Makefile.in: added AS_FOR_TARGET, passed down in
- TARGET_FLAGS_TO_PASS. Added CC_FOR_BUILD, which is intended to be
- the C compiler to use to create programs which are run in the
- build environment, set it to default to $(CC), and passed it down
- in FLAGS_TO_PASS and TARGET_FLAGS_TO_PASS.
-
-Wed Sep 9 12:21:42 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in: added TARGET_FLAGS_TO_PASS, CC_FOR_TARGET,
- AR_FOR_TARGET, RANLIB_FOR_TARGET, NM_FOR_TARGET. Pass
- TARGET_FLAGS_TO_PASS, which defines CC, AR, RANLIB and NM as the
- FOR_TARGET variants, to newlib and libg++.
-
-Tue Sep 8 17:28:30 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (all-gas, all-gdb): Require all-opcodes to be built
- first.
-
-Wed Sep 2 02:50:05 1992 John Gilmore (gnu@cygnus.com)
-
- * config.sub: Accept `elf' as an environment.
-
-Tue Sep 1 15:48:30 1992 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * Makefile.in (all-opcodes): cd into the right directory
-
-Sun Aug 30 21:12:11 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * configure: added -program_transform_name option, used as
- argument to sed when installing programs.
- configure.texi: added documentation for -program_prefix,
- -program_suffix and -program_transform_name.
-
-Thu Aug 27 21:59:44 1992 John Gilmore (gnu@cygnus.com)
-
- * config.sub: Accept i486 where i386 ok.
-
-Thu Aug 27 13:04:42 1992 Brendan Kehoe (brendan@rtl.cygnus.com)
-
- * config.sub: accept we32k
-
-Mon Aug 24 14:05:14 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * config.sub, configure.in: accept OSE68000 and OSE68k.
-
- * Makefile.in: don't create all directories for ``make install'';
- let the subdirectories create the ones they need.
-
-Tue Aug 11 23:13:17 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * COPYING: new file, GPL v2
-
-Tue Aug 4 01:12:43 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: use the new gen-info-dir, which needs a template
- argument (which also lives in texinfo)
-
- * configure.texi, standards.texi: fix INFO-DIR-ENTRY
-
-Mon Aug 3 15:41:28 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config/mh-solaris: removed the -xs from CFLAGS (let the people
- with Sun's C compiler deal with it themselved)
-
-Mon Aug 3 00:34:17 1992 Fred Fish (fnf@cygnus.com)
-
- * config.sub (ncr3000): Change i386 to i486.
-
-Thu Jul 23 00:12:17 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: add install-rcs, install-grep to
- install-no-fixedincludes, removed install-bison and install-libgcc
-
-Tue Jul 21 01:01:50 1992 david d `zoo' zuhn (zoo@cygnus.com)
-
- * configure.in: grab the HPUX makefile fragment if on HPUX
-
-Mon Jul 20 11:02:09 1992 D. V. Henkel-Wallace (gumby@cygnus.com)
-
- * Makefile.in: eradicate bison spoor (ditto libgcc).
- configure.in: recognise m68{k,000}-ericsson-OSE.
- es1800 is alias for m68k-ericsson-OSE
-
-Sun Jul 19 17:49:02 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: rearrange the parts that remove programs from
- configdirs, based now on HOST==TARGET or by canonical triple.
-
-Fri Jul 17 22:52:49 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * test-build.mk: recurse explicitly with -f test-build.mk when
- appropriate. predicate stage3 and comparison on the existence
- of gcc. That is, if gcc isn't around, we aren't three-staging.
- On very clean, also remove ...stamp-co. Build in-place before
- doing other builds.
-
-Thu Jul 16 18:33:09 1992 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * Makefile.in, configure.in: add tgas
-
-Thu Jul 16 16:05:28 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in: a number of changes merged in from progressive.
-
- * configure.in: add libm.
-
- * .cvsignore: ignore some stuff that comes from test-build.mk.
-
-Wed Jul 8 00:01:30 1992 Stu Grossman (grossman at cygnus.com)
-
- * config/mh-solaris: Use -xs when compiling so that Sun-C puts
- a symbol-table into the executable.
-
-Tue Jul 7 00:24:52 1992 Fred Fish (fnf@cygnus.com)
-
- * config.sub: Add es1800 (m68k-ericsson-es1800).
-
-Tue Jun 30 20:24:41 1992 D. V. Henkel-Wallace (gumby@cygnus.com)
-
- * configure: Add program_suffix (parallel to program_prefix)
- * Makefile.in: adjust directory-creating script for losing decstation
-
-Mon Jun 22 23:43:48 1992 Per Bothner (bothner@cygnus.com)
-
- * configure: Minor $subdir-related fixes.
-
-Mon Jun 22 18:30:26 1992 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * configure: fix various problems with propogating
- makefile_target_frag in subdirs.
- * configure.in: config libgcc if its there
-
-Fri Jun 19 15:19:40 1992 Stu Grossman (grossman at cygnus.com)
-
- * config.sub: HPPA merge.
-
-Mon Jun 15 12:31:52 1992 Fred Fish (fnf@cygnus.com)
-
- * config/mh-ncr3000 (INSTALL): Don't use /usr/ucb/install,
- it is broken on ncr 3000's.
-
-Sun Jun 14 10:29:19 1992 John Gilmore (gnu at cygnus.com)
-
- * Makefile.in: Replace all-bison with all-byacc in all
- dependency lines for other tools (which now use byacc).
-
-Fri Jun 12 22:21:57 1992 John Gilmore (gnu at cygnus.com)
-
- * config.sub: Add sun4sol2 => sparc-sun-solaris2.
-
-Tue Jun 9 17:18:11 1992 Fred Fish (fnf at cygnus.com)
-
- * config/{mh-ncr3000, mh-sysv4}: Add INSTALL.
-
-Thu Jun 4 12:07:32 1992 Mark Eichin (eichin@cygnus.com)
-
- * Makefile.in: make gprof rules similar to byacc rules (instead of
- vestigal $(unsubdir) that didn't work...)
-
-Thu Jun 4 00:37:05 1992 Per Bothner (bothner@rtl.cygnus.com)
-
- * config.sub: Add support for Linux.
- * Makefile.in: Use $(FLAGS_TO_PASS) more consistently
- (at least for libg++).
-
-Tue Jun 02 20:03:00 1992 david d `zoo' zuhn (zoo@cygnus.com)
-
- * configure.texi: fix doc for the -nfp option to configure
-
-Tue Jun 2 17:20:52 1992 Michael Tiemann (tiemann@cygnus.com)
-
- * Makefile.in (all-binutils): ar needs flex, so depend on all-flex.
-
-Sun May 31 15:04:08 1992 Mark Eichin (eichin at cygnus.com)
-
- * config.sub: changed [^-]+ to [^-][^-]* so that it works under
- Sun sed. (BSD 4.3 sed doesn't handle [^-]+ either.)
- * configure.in: added solaris* host_makefile_frag hook.
-
-Sun May 31 01:10:34 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config.sub: changed recognition of m68000 so that various
- m68k types can be specified via m680[01234]0
-
-Sat May 30 21:01:06 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config.sub (basic_machine): fix sed so that '-foo' isn't
- completely substituted out while .+'-foo' loses the '-foo'
-
-Wed May 27 23:18:52 1992 Michael Tiemann (tiemann@rtl.cygnus.com)
-
- * config.sub ($os): Add -aout.
-
-Fri May 22 14:00:02 1992 Per Bothner (bothner@cygnus.com)
-
- * configure: If host_makefile_frag is absolute, don't
- prefix ${invsubdir} (relevant to libg++ auto-configure).
-
-Thu May 21 18:00:09 1992 Michael Tiemann (tiemann@rtl.cygnus.com)
-
- * Makefile.in (tooldir): Define it.
- (all-ld): Depend on all-flex.
-
-Sun May 10 21:45:59 1992 Per Bothner (bothner@rtl.cygnus.com)
-
- * Makefile.in (check): Fix libg++ special case.
-
-Fri May 8 08:31:41 1992 K. Richard Pixley (rich@cygnus.com)
-
- * configure: do not bury `pwd` into config.status, thus do fewer
- pwd's.
-
- * configure: print the "Building in" message only when building in
- other than "." AND verbose.
-
- * configure: remove -s, rework -v to better accomodate guested
- configures.
-
- * standards.texi: updated to 3 may, fixed librid <-> libdir typo.
-
-Fri May 1 18:00:50 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in: macroize flags passed on recursion. remove
- fileutils.
-
-Thu Apr 30 08:56:20 1992 K. Richard Pixley (rich@cygnus.com)
-
- * configure: get makesrcdir right for subdirs deeper than 1.
-
- * Makefile.in: pass INSTALL, INSTALL_DATA, INSTALL_PROGRAM on
- install.
-
-Fri Apr 24 15:51:51 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in: don't print subdir_do or recursion lines.
-
-Fri Apr 24 15:22:04 1992 K. Richard Pixley (rich@cygnus.com)
-
- * standards.texi: added menu item.
-
- * Makefile.in: build and install standards.info.
-
- * standards.texi: new file.
-
-Wed Apr 22 18:06:55 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * configure: test for and move config.status pieces from
- ${subdir}/.
-
-Wed Apr 22 14:38:34 1992 Fred Fish (fnf@cygnus.com)
-
- * config/mh-delta88, config/mh-ncr3000: Replace MINUS_G with
- CFLAGS per new configuration strategy.
- * configure: Test for existance of files before trying to mv
- them, to avoid numerous non-existance messages.
-
-Tue Apr 21 12:31:33 1992 K. Richard Pixley (rich@cygnus.com)
-
- * configure: correct final line of config.status.
-
- * configure: patch from eggert. Avoids a protection problem if
- the original Makefile.in is read only.
-
- * configure: use move-if-change from gcc to create config.status.
- Some makefiles depend on config.status to tell if a directory
- has been reconfigured for a different host. This change
- prevents those directories from remaking everything in the case
- where the reconfig was only intended to rebuild a Makefile.
-
- * configure: test for config.sub with "config.sub sun4" rather
- than "config.sub ${host_alias}". Otherwise we can't tell a bad
- host alias from a missing config.sub.
-
-Mon Apr 20 18:16:36 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in: explicitly pass CFLAGS on recursion. no longer pass
- MINUS_G (this can be done with CFLAGS). Default CFLAGS to -g.
-
-Fri Apr 17 18:27:51 1992 Per Bothner (bothner@cygnus.com)
-
- * configure: mkdir ${subdir} as needed.
-
-Wed Apr 15 17:37:22 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in,configure.in: added autoconf.
-
-Wed Apr 15 17:27:34 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in: no longer pass against on recursion.
-
- * Makefile.in: added .NOEXPORT: so that stray makefile_frag
- definitions are not inherited.
-
- * configure: correct makesrcdir when subdir is .
-
-Tue Apr 14 11:56:09 1992 Per Bothner (bothner@cygnus.com)
-
- * configure: Add support for 'subdirs' variable, which is
- like 'configdirs', except that configure doesn't re-invoke
- itself for subdirs, it just creates a Makefile for each subdir.
- * configure.texi: Document subdirs.
-
-Mon Apr 13 18:50:16 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: added flex to configdirs
-
-Mon Apr 13 18:43:55 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in: remove clean-stamps from clean.
-
-Sat Apr 11 03:52:03 1992 John Gilmore (gnu at cygnus.com)
-
- * configure.in: Add gdbtest to configdirs.
-
-Fri Apr 10 23:11:49 1992 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (MINUS_G): Add macro, default to -g, pass on
- to recursive makes.
- * configure.in: Recognize new ncr3000 config.
-
-Wed Apr 8 23:08:12 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in, configure.in: removed references to gdbm.
-
-Tue Apr 7 16:48:20 1992 Per Bothner (bothner@cygnus.com)
-
- * config.sub: Don't canonicalize os value
- newsos* to bsd (readline needs to check for newsos).
- (This fix was earlier made Jan 31, but got re-broken.)
-
-Mon Apr 6 14:34:08 1992 Stu Grossman (grossman at cygnus.com)
-
- * configure.in: sco is an os, not a vendor!
-
- * configure: Quote $( better. Keep various shells happy.
-
-Tue Mar 31 16:32:57 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in: eliminate stamp-files.
-
-Mon Mar 30 22:20:23 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in: add send_pr. remove "force" from .stmp-gprof rule.
- Supress echoing of all the "if [ -d ... $(MAKE)" lines.
-
-Wed Mar 25 15:20:04 1992 Stu Grossman (grossman@cygnus.com)
-
- * config.sub: fix iris/iris3.
-
-Wed Mar 25 10:34:19 1992 K. Richard Pixley (rich@cygnus.com)
-
- * configure: re-add -rm.
-
-Tue Mar 24 23:50:16 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Maskefile.in: add .stmp-rcs to all.
-
- * configure.in: remove gas from rs6000 build, use aix host fragment.
-
-Mon Mar 23 19:43:35 1992 K. Richard Pixley (rich@cygnus.com)
-
- * configure: pass down site_option during recursion.
-
-Thu Mar 19 16:49:36 1992 Stu Grossman (grossman at cygnus.com)
-
- * Makefile.in (all.cross): Add .stmp-bfd .stmp-readline.
-
-Wed Mar 18 15:29:33 1992 Mike Stump (mrs@cygnus.com)
-
- * configure: Change exec_prefix so that it really defaults to prefix.
-
-Sat Mar 14 17:20:38 1992 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in, configure.in: Add support for mmalloc library.
-
-Fri Mar 13 18:44:18 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in: add stmp dependencies for a few more things.
-
-Thu Mar 12 04:56:24 1992 K. Richard Pixley (rich@cygnus.com)
-
- * configure: adjusted error message on objdir/srcdir configure
- collision, per john's suggestion.
-
- * Makefile.in: add libiberty stmp to all and all.cross.
-
-Wed Mar 11 02:07:52 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in: remove force dependencies, add grep to all.
-
-Tue Mar 10 21:49:18 1992 K. Richard Pixley (rich@mars.cygnus.com)
-
- * Makefile.in: drop flex. make stamp files work.
-
- * configure: added test for conflicting configuration in srcdir,
- remove trailing slashes from srcdir. Otherwise emacs gdb mode
- gets cranky. use relative paths for configure and srcdir
- whenever possible. Send some error messages to stderr that were
- going to stdout.
-
-Tue Mar 10 18:01:55 1992 Per Bothner (bothner@cygnus.com)
-
- * Makefile.in: Fix libg++ rule to check for gcc directory
- before using gcc/gcc. Also pass XTRAFLAGS.
-
-Thu Mar 5 21:45:07 1992 K. Richard Pixley (rich@sendai)
-
- * Makefile.in: added stmp-files so that directories aren't polled
- when they are already built.
-
- * configure.texi: fixed a node pointer problem.
-
-Thu Mar 5 12:05:58 1992 Stu Grossman (grossman at cygnus.com)
-
- * config.sub configure.in config/mh-irix4 gdb/configure.in
- gdb/mips-tdep.c gdb/mipsread.c gdb/procfs.c gdb/signame.h
- gdb/tm-irix3.h gdb/tm-mips.h gdb/xm-irix4.h gdb/config/mt-irix3
- gdb/config/mh-irix4 texinfo/configure.in: Port to SGI Irix-4.x.
-
-Wed Mar 4 02:57:46 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * configure: -recurring becomes -silent. corrected help message
- for -site= option.
-
- * Makefile.in: mkdir $(exec_prefix) and $(tooldir).
-
-Tue Mar 3 14:51:21 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * configure: when building Makefile for crosses, replace
- tooldir and program_prefix. default srcdir from location of
- config.sub. remove "for host in hosts" and "for target in
- targets" loops.
-
-Wed Feb 26 19:48:25 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in: Do not pass bindir or mandir to cvs.
-
-Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in, configure.in: removed traces of namesubdir,
- -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced
- copyrights to '92, changed some from Cygnus to FSF.
-
- * configure.texi: remove most references to multiple hosts,
- multiple targets, subdirs, etc.
-
- * configure.man: removed rcsid. reference config.sub not
- config.subr.
-
- * Makefile.in: mkdir $(infodir) on install-info.
-
-Wed Feb 19 15:41:13 1992 John Gilmore (gnu at cygnus.com)
-
- * configure.texi: Explain better about .gdbinit and about
- the environment that configure.in sections run in.
-
-Fri Feb 7 07:55:00 1992 John Gilmore (gnu at cygnus.com)
-
- * configure.in: Ultrix is only a decstation if it's a MIPS.
-
-Fri Jan 31 21:54:51 1992 John Gilmore (gnu at cygnus.com)
-
- * README: DOC.configure => cfg-paper.texi.
-
-Fri Jan 31 21:48:18 1992 Stu Grossman (grossman at cygnus.com)
-
- * config.sub (near case $os): Don't convert newsos* to bsd!
-
-Fri Jan 31 02:27:32 1992 John Gilmore (gnu at cygnus.com)
-
- * Makefile.in: Reinstall change from gdb-4.3 that reduces
- the number of copies of COPYING that go into the GDB tar file.
-
-Thu Jan 30 16:17:30 1992 Stu Grossman (grossman at cygnus.com)
-
- * bfd/configure.in, config/mh-sco, gdb/config/mh-i386sco,
- gdb/config/mt-i386v32, gdb/configure.in, readline/configure.in:
- Fix SCO configuration stuff.
-
-Tue Jan 28 23:51:07 1992 Per Bothner (bothner at cygnus.com)
-
- * Makefile.in: For libg++, make sure the -I pointing
- to the gcc directory goes *after* all the libg++-local -I flags.
- Also, move just-gcc dependency from just-libg++ to all-libg++.
-
-Tue Jan 28 12:56:24 1992 Stu Grossman (grossman at cygnus.com)
-
- * configure: Change -x to -f to keep Ultrix /bin/test happy.
-
-Sat Jan 18 17:45:11 1992 Stu Grossman (grossman at cygnus.com)
-
- * Makefile.in (make-gdb.tar.Z): Remove texinfo targets.
-
-Sat Jan 18 17:03:21 1992 Fred Fish (fnf at cygnus.com)
-
- * config.sub: Add stratus configuration frags. Also
- submitted to FSF.
-
-Sat Jan 18 15:35:29 1992 Stu Grossman (grossman at cygnus.com)
-
- * Makefile.in (DEV_SUPPORT): add configure.man.
-
- * config.sub(Decode manufacturer-specific): add -none*.
-
-Fri Jan 17 17:58:05 1992 Stu Grossman (grossman at cygnus.com)
-
- * Makefile.in: remove form feeds to make Sun's make happy.
- (DEVO_SUPPORT): DOC.configure => cfg-paper.texi.
-
-Sat Jan 4 16:11:44 1992 John Gilmore (gnu at cygnus.com)
-
- * Makefile.in (AR_FLAGS): Make quieter.
-
-Thu Jan 2 22:57:12 1992 John Gilmore (gnu at cygnus.com)
-
- * configure.in: Add libg++.
- * configure: When verbose, don't output the command line at each
- level; it will be unremarkably the same as the previous version,
- which will be the same as what the user typed.
-
-Fri Dec 27 16:26:47 1991 K. Richard Pixley (rich at cygnus.com)
-
- * configure.in, Makefile.in: fix clean-info, add flex. add
- fileutils.
-
- * configure: be less sensitive to spaces in Makefile.in. Do not
- look for sources in "..". Doing so breaks subdirectories that
- might have their own configure. If a subdir has it's own
- configure script, use it.
-
-Thu Dec 26 16:30:26 1991 K. Richard Pixley (rich at cygnus.com)
-
- * cfg-paper.texi: some changes suggested by rms.
-
-Thu Dec 26 10:13:36 1991 Fred Fish (fnf at cygnus.com)
-
- * config.sub: Merge in some small additions from the FSF version,
- taken from the gcc distribution, to bring the Cygnus and FSF
- versions into closer sync.
-
-Fri Dec 20 11:34:18 1991 Fred Fish (fnf at cygnus.com)
-
- * configure.in: Changed svr4 references to sysv4.
-
-Thu Dec 19 15:54:29 1991 K. Richard Pixley (rich at cygnus.com)
-
- * configure: added -V for version number option.
-
-Wed Dec 18 15:39:34 1991 K. Richard Pixley (rich at cygnus.com)
-
- * DOC.configure, cfg-paper.texi: revised, updated, and texinfo'd.
- renamed from DOC.configure to cfg-paper.texi.
-
-Mon Dec 16 23:05:19 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * configure, config.subr, config.sub: config.subr is now
- config.sub again.
-
-Fri Dec 13 01:17:06 1991 K. Richard Pixley (rich at cygnus.com)
-
- * configure.texi: new file, in progress.
-
- * Makefile.in: build info file and install the man page for
- configure.
-
- * configure.man: new file, first cut.
-
- * configure: find config.subr again now that configuration "none"
- has gone. removed all traces of the -ansi option. removed all
- traces of the -languages option.
-
- * config.subr: resync from rms.
-
-1991-12-11 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * configure, config.sub, config.subr: merge config.sub into
- config.subr, call the result config.subr, remove config.sub, use
- config.subr.
-
- * Makefile.in: revised install for dir.info.
-
-1991-12-10 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * configure.in: add decstation host makefile frag.
-
- * Makefile.in: BISON now bison -y again. also install-gcc on
- install. clean-gdbm on clean. infodir belongs in datadir.
- Make directories for info install. Build dir.info here then
- install it.
-
-1991-12-09 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Makefile.in: fix for bad directory tests.
-
-1991-12-07 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * configure: \{1,2\} appears to be a sysv'ism. Use a different
- regexp. -srcdir relative was being handled incorrectly.
-
- * Makefile.in: unwrapped some for loops so that parallel makes
- work again and so one can focus one's attention on a particular
- package.
-
-1991-12-06 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * configure: added PWD as a stand in for `pwd` (for speed). use
- elif wherever possible. make -srcdir work without -objdir.
- -objdir= commented out.
-
-1991-12-05 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * configure: +options become --options. -subdirs commented out.
- added -host, -datadir. Renamed -destdir to -prefix. Comment in
- Makefile now at top of generated Makefile. Removed cvs log
- entries. added -srcdir. create .gdbinit only if there is one
- in ${srcdir}.
-
- * Makefile.in: idestdir and ddestdir go away. Added copyrights
- and shift gpl to v2. Added ChangeLog if it didn't exist. docdir
- and mandir now keyed off datadir by default.
-
-1991-11-22 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Freshly created ChangeLog.
-
-
-Local Variables:
-mode: change-log
-left-margin: 8
-fill-column: 76
-version-control: never
-End:
diff --git a/contrib/gdb/MAINTAINERS b/contrib/gdb/MAINTAINERS
deleted file mode 100644
index 75f324053140..000000000000
--- a/contrib/gdb/MAINTAINERS
+++ /dev/null
@@ -1,114 +0,0 @@
-Please feel free to add, edit, delete this file.
-Please do not make ChangeLog entries.
-
-COPYING, COPYING.LIB, README
- http://gnu.org.
-
-Makefile.in; configure; configure.in
- Please notify the following of any committed patches.
- binutils@sources.redhat.com
- gdb-patches@sources.redhat.com
-
-bfd/; binutils/; gas/; gprof/; ld/; opcodes/; BFD's part of include/
- binutils: http://sources.redhat.com/binutils/
- Patches to binutils@sources.redhat.com.
- Please notify the following of any interface changes:
- gdb-patches@sources.redhat.com
-
-cgen/; cgen parts of opcodes/, sim/ & include/
- cgen: http://sources.redhat.com/cgen/
- Patches to cgen@sources.redhat.com
- May need separate opcodes/ or sim/ approval for
- commits of regenerated files there.
-
-config.guess; config.sub; dejagnu/config.guess;
-readline/support/config.sub; readline/support/config.guess
- config: http://savannah.gnu.org/projects/config
- Patches to config-patches@gnu.org.
- Changes need to be done in tandem with the official CONFIG
- sources or submitted to the master file maintainer and brought
- in via a merge.
- Please notify the following of any committed patches:
- binutils@sources.redhat.com
- gdb-patches@sources.redhat.com
-
-dejagnu/
- Notify http://dejagnu.sourceforge.net/ of generic changes.
- Generic patches to gdb-patches@sources.redhat.com;
- Other dependents of dejagnu include sid@, binutils@, gcc@, etc.
-
-gdb/; mmalloc/; readline/; sim/; GDB's part of include/ & dejagnu/
- gdb: http://sources.redhat.com/gdb/
- Patches to gdb-patches@sources.redhat.com.
- See also gdb/MAINTAINERS, sim/MAINTAINERS, mmalloc/MAINTAINERS.
-
-include/
- See binutils/, gdb/, sid/, gcc/, libiberty/ etc.
-
-libiberty/; libiberty's part of include/
- gcc: http://gcc.gnu.org
- Changes need to be done in tandem with the official GCC
- sources or submitted to the master file maintainer and brought
- in via a merge. Note: approved patches in gcc's libiberty
- are automatically approved in this libiberty also; feel free
- to merge them yourself if needed sooner than the next merge.
- Otherwise, changes are automatically merged, usually within
- a day.
-
-ltconfig; ltmain.sh
- libtool: http://gnu.org
- Changes need to be done in tandem with the official LIBTOOL
- sources or submitted to the master file maintainer and brought
- in via a merge.
-
-mkinstalldirs; move-if-change
- autoconf: http://gnu.org
- Patches to autoconf-patches@gnu.org.
- Changes need to be done in tandem with the official AUTOCONF
- sources or submitted to the master file maintainer and brought
- in via a merge.
-
-symlink-tree
- gcc: http://gcc.gnu.org
- See libiberty.
-
-newlib/; libgloss/
- http://sources.redhat.com/newlib/
- Patches to newlib@sources.redhat.com.
-
-sid/; SID's part of cgen/ & dejagnu/
- sid: http://sources.redhat.com/sid/
- Patches to sid@sources.redhat.com
-
-texinfo/texinfo.tex
- texinfo: http://ftp.gnu.org.
- Latest version can be found on ftp://ftp.gnu.org and can be
- imported at any (reasonable) time.
- Please not use GCC's texinfo. Please do not import texinfo.
-
-tcl/; tix/; itcl/; tk/; libgui/
- insight: http://sources.redhat.com/insight/
- Contact insight@sources.redhat.com.
-
-winsup/
- cygwin: http://sources.redhat.com/cygwin
- Patches to cygwin-patches@sources.redhat.com.
- General discussion cygwin@sources.redhat.com.
- See also winsup/MAINTAINERS.
-
-expect/; config-ml.in; mpw-README; mpw-build.in; mpw-config.in;
-mpw-configure; mpw-install; setup.com; missing; makefile.vms; utils/;
-config/; config.if; makefile.vms; missing; ylwrap; mkdep; etc/;
-install-sh; intl/
- Ask DJ Delorie <dj@redhat.com> after reading the libiberty entry.
-
-modules file
- Obviously changes to this file should not go through
- overseers@sources.redhat.com. If you understand the file
- format (or can cut-and-paste existing entries), modify it. If
- it scares you, get someone who does understand it to help you.
- Be prepared to fix it if you do break it.
-
-/* Local variables: */
-/* change-log-default-name: "/dev/null" */
-/* End: */
diff --git a/contrib/gdb/bfd/COPYING b/contrib/gdb/bfd/COPYING
deleted file mode 100644
index a43ea2126fb6..000000000000
--- a/contrib/gdb/bfd/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/gdb/bfd/Makefile.in b/contrib/gdb/bfd/Makefile.in
deleted file mode 100644
index e531cf85dc58..000000000000
--- a/contrib/gdb/bfd/Makefile.in
+++ /dev/null
@@ -1,1090 +0,0 @@
-# Makefile template for Configure for the BFD library.
-# 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.
-
-VPATH = @srcdir@
-srcdir = @srcdir@
-
-prefix = @prefix@
-
-program_transform_name = @program_transform_name@
-exec_prefix = @exec_prefix@
-bindir = $(exec_prefix)/bin
-libdir = $(exec_prefix)/lib
-
-datadir = $(prefix)/lib
-mandir = $(prefix)/man
-man1dir = $(mandir)/man1
-man2dir = $(mandir)/man2
-man3dir = $(mandir)/man3
-man4dir = $(mandir)/man4
-man5dir = $(mandir)/man5
-man6dir = $(mandir)/man6
-man7dir = $(mandir)/man7
-man8dir = $(mandir)/man8
-man9dir = $(mandir)/man9
-infodir = $(prefix)/info
-includedir = $(prefix)/include
-oldincludedir =
-docdir = doc
-
-SHELL = /bin/sh
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-
-AR = @AR@
-AR_FLAGS = rc
-CC = @CC@
-CFLAGS = @CFLAGS@
-MAKEINFO = makeinfo
-RANLIB = @RANLIB@
-
-ALLLIBS = @ALLLIBS@
-
-PICFLAG = @PICFLAG@
-SHLIB = @SHLIB@
-SHLIB_CC = @SHLIB_CC@
-SHLIB_CFLAGS = @SHLIB_CFLAGS@
-COMMON_SHLIB = @COMMON_SHLIB@
-SHLINK = @SHLINK@
-
-SONAME = lib`echo $(SHLIB) | sed -e 's/^lib//' | sed '$(program_transform_name)'`
-
-CC_FOR_BUILD = @CC_FOR_BUILD@
-
-INCDIR = $(srcdir)/../include
-CSEARCH = -I. -I$(srcdir) -I$(INCDIR)
-DEP = mkdep
-
-SUBDIRS = doc
-
-TARGETLIB = libbfd.a
-
-# bfd.h goes here, for now
-BFD_H = bfd.h
-
-# Some of these files should be in BFD*_BACKENDS below, but some programs
-# won't link without them. So, in order for some of the minimal-bfd
-# hacks to work, they're also included here for now.
-# gdb: elf.o
-# objdump: elf.o
-#
-# Also, Jim Kingdon notes:
-# Writing S-records should be included in all (or at least most)
-# *-*-coff, *-*-aout, etc., configurations, because people will want to
-# be able to use objcopy to create S-records. (S-records are not useful
-# for the debugger, so if you are downloading things as S-records you
-# need two copies of the executable, one to download and one for the
-# debugger).
-BFD_LIBS = \
- archive.o archures.o bfd.o cache.o coffgen.o corefile.o \
- format.o init.o libbfd.o opncls.o reloc.o \
- section.o syms.o targets.o hash.o linker.o \
- elf.o srec.o binary.o tekhex.o ihex.o stab-syms.o
-
-BFD_LIBS_CFILES = \
- archive.c archures.c bfd.c cache.c coffgen.c corefile.c \
- format.c init.c libbfd.c opncls.c reloc.c \
- section.c syms.c targets.c hash.c linker.c \
- elf.c srec.c binary.c tekhex.c ihex.c stab-syms.c
-
-# This list is alphabetized to make it easier to keep in sync
-# with the decls and initializer in archures.c.
-ALL_MACHINES = \
- cpu-a29k.o \
- cpu-alpha.o \
- cpu-arm.o \
- cpu-h8300.o \
- cpu-h8500.o \
- cpu-hppa.o \
- cpu-i386.o \
- cpu-i860.o \
- cpu-i960.o \
- cpu-m68k.o \
- cpu-m88k.o \
- cpu-mips.o \
- cpu-ns32k.o \
- cpu-powerpc.o \
- cpu-rs6000.o \
- cpu-sh.o \
- cpu-sparc.o \
- cpu-vax.o \
- cpu-we32k.o \
- cpu-w65.o \
- cpu-z8k.o
-
-ALL_MACHINES_CFILES = \
- cpu-a29k.c \
- cpu-alpha.c \
- cpu-arm.c \
- cpu-h8300.c \
- cpu-h8500.c \
- cpu-hppa.c \
- cpu-i386.c \
- cpu-i860.c \
- cpu-i960.c \
- cpu-m68k.c \
- cpu-m88k.c \
- cpu-mips.c \
- cpu-ns32k.c \
- cpu-powerpc.c \
- cpu-rs6000.c \
- cpu-sh.c \
- cpu-sparc.c \
- cpu-vax.c \
- cpu-we32k.c \
- cpu-w65.c \
- cpu-z8k.c
-
-# The .o files needed by all of the 32 bit vectors that are configured into
-# target_vector in targets.c if configured with --enable-targets=all.
-BFD32_BACKENDS = \
- aout-adobe.o \
- aout-ns32k.o \
- aout0.o \
- aout32.o \
- bout.o \
- cf-i386lynx.o \
- cf-m68klynx.o \
- cf-sparclynx.o \
- coff-a29k.o \
- coff-apollo.o \
- coff-arm.o \
- coff-aux.o \
- coff-h8300.o \
- coff-h8500.o \
- coff-i386.o \
- coff-go32.o \
- coff-i860.o \
- coff-i960.o \
- coff-m68k.o \
- coff-m88k.o \
- coff-mips.o \
- coff-pmac.o \
- coff-rs6000.o \
- coff-sh.o \
- coff-sparc.o \
- coff-u68k.o \
- coff-we32k.o \
- coff-w65.o \
- coff-z8k.o \
- cofflink.o \
- ecoff.o \
- ecofflink.o \
- elf32-gen.o \
- elf32-hppa.o \
- elf32-i386.o \
- elf32-i860.o \
- elf32-m68k.o \
- elf32-m88k.o \
- elf32-mips.o \
- elf32-ppc.o \
- elf32-sparc.o \
- elf32.o \
- elflink.o \
- hp300hpux.o \
- som.o \
- i386aout.o \
- i386bsd.o \
- i386freebsd.o \
- i386linux.o \
- i386lynx.o \
- i386msdos.o \
- i386netbsd.o \
- i386mach3.o \
- i386os9k.o \
- ieee.o \
- m68klinux.o \
- m68klynx.o \
- m68knetbsd.o \
- m88kmach3.o \
- mipsbsd.o \
- newsos3.o \
- nlm.o \
- nlm32-i386.o \
- nlm32-sparc.o \
- nlm32-ppc.o \
- nlm32.o \
- ns32knetbsd.o \
- oasys.o \
- pc532-mach.o \
- pe-arm.o \
- pei-arm.o \
- pe-i386.o \
- pei-i386.o \
- pe-ppc.o \
- pei-ppc.o \
- reloc16.o \
- sparclynx.o \
- sparcnetbsd.o \
- sunos.o \
- tekhex.o \
- versados.o \
- xcofflink.o
-
-BFD32_BACKENDS_CFILES = \
- aout-adobe.c \
- aout-ns32k.c \
- aout0.c \
- aout32.c \
- bout.c \
- cf-i386lynx.c \
- cf-m68klynx.c \
- cf-sparclynx.c \
- coff-a29k.c \
- coff-apollo.c \
- coff-arm.c \
- coff-aux.c \
- coff-h8300.c \
- coff-h8500.c \
- coff-i386.c \
- coff-i860.c \
- coff-go32.c \
- coff-i960.c \
- coff-m68k.c \
- coff-m88k.c \
- coff-mips.c \
- coff-pmac.c \
- coff-rs6000.c \
- coff-sh.c \
- coff-sparc.c \
- coff-u68k.c \
- coff-we32k.c \
- coff-w65.c \
- coff-z8k.c \
- cofflink.c \
- ecoff.c \
- ecofflink.c \
- elf32-gen.c \
- elf32-hppa.c \
- elf32-i386.c \
- elf32-i860.c \
- elf32-m68k.c \
- elf32-m88k.c \
- elf32-mips.c \
- elf32-ppc.c \
- elf32-sparc.c \
- elf32.c \
- elflink.c \
- hp300hpux.c \
- som.c \
- i386aout.c \
- i386bsd.c \
- i386freebsd.c \
- i386linux.c \
- i386lynx.c \
- i386msdos.c \
- i386netbsd.c \
- i386mach3.c \
- i386os9k.c \
- ieee.c \
- m68klinux.c \
- m68klynx.c \
- m68knetbsd.c \
- m88kmach3.c \
- mipsbsd.c \
- newsos3.c \
- nlm.c \
- nlm32-i386.c \
- nlm32-sparc.c \
- nlm32-ppc.c \
- nlm32.c \
- ns32knetbsd.c \
- oasys.c \
- pc532-mach.c \
- pe-arm.c \
- pei-arm.c \
- pe-i386.c \
- pei-i386.c \
- pe-ppc.c \
- pei-ppc.c \
- reloc16.c \
- sparclynx.c \
- sparcnetbsd.c \
- sunos.c \
- tekhex.c \
- versados.c \
- xcofflink.c
-
-# The .o files needed by all of the 64 bit vectors that are configured into
-# target_vector in targets.c if configured with --enable-targets=all
-# and --enable-64-bit-bfd.
-BFD64_BACKENDS = \
- aout64.o \
- coff-alpha.o \
- demo64.o \
- elf64-gen.o \
- elf64-sparc.o \
- elf64.o \
- nlm32-alpha.o \
- nlm64.o
-
-BFD64_BACKENDS_CFILES = \
- aout64.c \
- coff-alpha.c \
- demo64.c \
- elf64-gen.c \
- elf64-sparc.c \
- elf64.c \
- nlm32-alpha.c \
- nlm64.c
-
-OPTIONAL_BACKENDS = \
- aix386-core.o \
- hpux-core.o \
- irix-core.o \
- lynx-core.o \
- osf-core.o \
- trad-core.o \
- cisco-core.o
-
-OPTIONAL_BACKENDS_CFILES = \
- aix386-core.c \
- hpux-core.c \
- irix-core.c \
- lynx-core.c \
- osf-core.c \
- trad-core.c \
- cisco-core.c
-
-# These are defined by configure.in:
-WORDSIZE = @wordsize@
-ALL_BACKENDS = @all_backends@
-BFD_BACKENDS = @bfd_backends@
-BFD_MACHINES = @bfd_machines@
-TDEFAULTS = @tdefaults@
-
-all:
-
-FLAGS_TO_PASS = \
- "prefix=$(prefix)" \
- "exec_prefix=$(exec_prefix)" \
- "against=$(against)" \
- "AR=$(AR)" \
- "AR_FLAGS=$(AR_FLAGS)" \
- "CC=$(CC)" \
- "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
- "CFLAGS=$(CFLAGS)" \
- "RANLIB=$(RANLIB)" \
- "MAKEINFO=$(MAKEINFO)" \
- "INSTALL=$(INSTALL)" \
- "INSTALL_DATA=$(INSTALL_DATA)" \
- "INSTALL_PROGRAM=$(INSTALL_PROGRAM)"
-
-ALL_CFLAGS=@HDEFINES@ @COREFLAG@ @TDEFINES@ $(CSEARCH) $(CSWITCHES) $(CFLAGS)
-.c.o:
- if [ -n "$(PICFLAG)" ]; then \
- $(CC) -c $(PICFLAG) $(ALL_CFLAGS) $< -o pic/$@; \
- else true; fi
- $(CC) -c $(ALL_CFLAGS) $<
-
-bfd_libs_here =
-all_machines_here =
-bfd32_backends_here =
-core_files_here =
-configs_not_included_in_all_targets_option_here =
-
-# C source files that correspond to .o's.
-CFILES = \
- $(BFD_LIBS_CFILES) \
- $(ALL_MACHINES_CFILES) \
- $(BFD32_BACKENDS_CFILES) \
- $(BFD64_BACKENDS_CFILES) \
- $(OPTIONAL_BACKENDS_CFILES) \
- i386dynix.c hp300bsd.c
-
-HFILES = aout-target.h aoutf1.h aoutx.h coffcode.h \
- coffswap.h ecoffswap.h elf32-hppa.h elf32-target.h elf64-target.h \
- elfcode.h hppa_stubs.h libaout.h libbfd.h \
- libcoff.h libecoff.h elf-bfd.h libhppa.h libieee.h libnlm.h \
- liboasys.h nlm-target.h nlmcode.h som.h genlink.h netbsd.h
-
-all: Makefile $(ALLLIBS) @PICLIST@
- @$(MAKE) subdir_do DO=all "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-
-.NOEXPORT:
-MAKEOVERRIDES=
-
-.PHONY: check installcheck
-check:
- @echo No testsuites exist for the BFD library. Nothing to check.
-
-installcheck:
- @echo No testsuites exist for the BFD library. Nothing to check.
-
-info dvi : force
- @$(MAKE) subdir_do DO=$@ "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-
-clean-info:
- @$(MAKE) subdir_do DO=clean-info "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-
-install-info: force
- @$(MAKE) subdir_do DO=install-info "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-
-diststuff: info
-
-# Various kinds of .o files to put in libbfd.a:
-# BFD_LIBS Generic routines, always needed.
-# BFD_BACKENDS Routines the configured targets need.
-# BFD_MACHINES Architecture-specific routines the configured targets need.
-# COREFILE Core file routines for a native configuration
-OFILES = $(BFD_LIBS) $(BFD_BACKENDS) $(BFD_MACHINES) @COREFILE@
-
-stamp-ofiles: Makefile
- rm -f tofiles
- f=""; \
- for i in $(OFILES) ; do \
- case " $$f " in \
- *" $$i "*) ;; \
- *) f="$$f $$i" ;; \
- esac ; \
- done ; \
- echo $$f > tofiles
- $(srcdir)/../move-if-change tofiles ofiles
- touch stamp-ofiles
-
-ofiles: stamp-ofiles ; @true
-
-$(TARGETLIB): $(OFILES) ofiles
- rm -f $(TARGETLIB)
- @echo ofiles = `cat ofiles`
- $(AR) $(AR_FLAGS) $(TARGETLIB) `cat ofiles`
- $(RANLIB) $(TARGETLIB)
-
-stamp-piclist: ofiles
- rm -f tpiclist
- if [ -n "$(PICFLAG)" ]; then \
- sed -e 's,\([^ ][^ ]*\),pic/\1,g' ofiles > tpiclist; \
- else \
- cp ofiles tpiclist; \
- fi
- $(srcdir)/../move-if-change tpiclist piclist
- touch stamp-piclist
-
-piclist: stamp-piclist ; @true
-
-$(SHLIB): stamp-picdir $(OFILES) piclist
- rm -f $(SHLIB)
- $(SHLIB_CC) $(SHLIB_CFLAGS) -o $(SHLIB) `cat piclist`
-
-# We make a link from libbfd.so to libbfd.so.VERSION for linking, and
-# also a link from libTARGET-bfd.so.VERSION for running.
-$(SHLINK): $(SHLIB)
- ts=lib`echo $(SHLIB) | sed -e 's/^lib//' | sed -e '$(program_transform_name)'`; \
- if [ "$$ts" != "$(SHLIB)" ]; then \
- rm -f $$ts; \
- ln -sf $(SHLIB) $$ts; \
- else true; fi
- rm -f $(SHLINK)
- ln -sf $(SHLIB) $(SHLINK)
-
-# This target creates libTARGET-bfd.so.VERSION as a symlink to
-# libbfd.so.VERSION. It is used on SunOS, which does not have SONAME.
-stamp-tshlink: $(SHLIB)
- tf=lib`echo $(SHLIB) | sed -e 's/^lib//' | sed '$(program_transform_name)'`; \
- if [ "$$tf" != "$(SHLIB)" ]; then \
- rm -f $$tf; \
- ln -sf $(SHLIB) $$tf; \
- else true; fi
- touch stamp-tshlink
-
-# When compiling archures.c and targets.c, supply the default target
-# info from configure.
-
-targets.o: targets.c Makefile
- if [ -n "$(PICFLAG)" ]; then \
- $(CC) -c $(PICFLAG) $(TDEFAULTS) $(ALL_CFLAGS) $(srcdir)/targets.c -o pic/targets.o; \
- else true; fi
- $(CC) -c $(TDEFAULTS) $(ALL_CFLAGS) $(srcdir)/targets.c
-
-archures.o: archures.c Makefile
- if [ -n "$(PICFLAG)" ]; then \
- $(CC) -c $(PICFLAG) $(TDEFAULTS) $(ALL_CFLAGS) $(srcdir)/archures.c -o pic/archures.o; \
- else true; fi
- $(CC) -c $(TDEFAULTS) $(ALL_CFLAGS) $(srcdir)/archures.c
-
-elf32-target.h : elfxx-target.h
- rm -f elf32-target.h
- sed -e s/NN/32/g < $(srcdir)/elfxx-target.h > elf32-target.new
- mv -f elf32-target.new elf32-target.h
-
-elf64-target.h : elfxx-target.h
- rm -f elf64-target.h
- sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new
- mv -f elf64-target.new elf64-target.h
-
-subdir_do: force
- @for i in $(DODIRS); do \
- if [ -d ./$$i ] ; then \
- if (cd ./$$i; \
- $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
- else exit 1 ; fi ; \
- else true ; fi ; \
- done
-
-tags etags: TAGS
-
-TAGS: force
- etags $(INCDIR)/*.h $(srcdir)/*.h $(srcdir)/*.c
-
-do_mostlyclean:
- rm -f *.o *~ core *.E *.p *.ip aout-params.h gen-aout config.log \
- pic/*.o
-do_clean: do_mostlyclean
- rm -f libbfd.a TAGS bfd.h stmp-bfd.h ofiles stamp-ofiles \
- elf32-target.h elf64-target.h $(SHLIB) $(SHLINK) \
- piclist stamp-piclist
-do_distclean: do_clean
- rm -f Makefile config.status config.cache config.h stamp-h
- rm -rf pic stamp-picdir
-do_maintainer_clean: do_distclean
- rm -f $(srcdir)/bfd-in2.h $(srcdir)/libbfd.h $(srcdir)/libcoff.h
-
-mostlyclean: do_mostlyclean
- $(MAKE) subdir_do DO=mostlyclean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-clean: do_clean
- $(MAKE) subdir_do DO=clean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-distclean:
- $(MAKE) subdir_do DO=distclean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
- $(MAKE) do_distclean
-clobber maintainer-clean realclean:
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may require special tools to rebuild."
- $(MAKE) subdir_do DO=maintainer-clean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
- $(MAKE) do_maintainer_clean
-
-BFD_H_DEPS= $(INCDIR)/ansidecl.h $(INCDIR)/obstack.h
-LOCAL_H_DEPS= libbfd.h sysdep.h config.h
-$(BFD_LIBS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
-$(BFD_MACHINES): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
-$(BFD_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
-$(OPTIONAL_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
-
-# Get around a Sun Make bug in SunOS 4.1.1 with VPATH
-cpu-i386.o:cpu-i386.c
-cpu-z8k.o: cpu-z8k.c
-cpu-h8500.o: cpu-h8500.c
-cpu-we32k.o: cpu-we32k.c
-
-saber:
- #suppress 65 on bfd_map_over_sections
- #suppress 66 on bfd_map_over_sections
- #suppress 67 on bfd_map_over_sections
- #suppress 68 on bfd_map_over_sections
- #suppress 69 on bfd_map_over_sections
- #suppress 70 on bfd_map_over_sections
- #suppress 110 in bfd_map_over_sections
- #suppress 112 in bfd_map_over_sections
- #suppress 530
- #suppress 590 in swap_exec_header
- #suppress 590 in _bfd_dummy_core_file_matches_executable_p
- #suppress 590 in bfd_dont_truncate_arname
- #suppress 590 on ignore
- #suppress 590 on abfd
- #setopt load_flags $(CFLAGS)
- #load $(CFILES)
-
-
-#-----------------------------------------------------------------------------
-# 'STANDARD' GNU/960 TARGETS BELOW THIS POINT
-#
-# 'VERSION' file must be present and contain a string of the form "x.y"
-#-----------------------------------------------------------------------------
-
-ver960.c: FORCE
- rm -f ver960.c
- echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c
-
-
-# This target should be invoked before building a new release.
-# 'VERSION' file must be present and contain a string of the form "x.y"
-#
-roll:
- @V=`cat VERSION` ; \
- MAJ=`sed 's/\..*//' VERSION` ; \
- MIN=`sed 's/.*\.//' VERSION` ; \
- V=$$MAJ.`expr $$MIN + 1` ; \
- rm -f VERSION ; \
- echo $$V >VERSION ; \
- echo Version $$V
-
-# Dummy target to force execution of dependent targets.
-#
-force:
-
-install: $(ALLLIBS)
- for f in $(ALLLIBS); do \
- if [ "$$f" = "stamp-tshlink" ]; then \
- continue; \
- fi; \
- tf=lib`echo $$f | sed -e 's/^lib//' | sed '$(program_transform_name)'`; \
- rm -f $(libdir)/$$tf; \
- if [ "$$f" = "$(SHLINK)" ]; then \
- ts=lib`echo $(SHLIB) | sed -e 's/^lib//' | sed '$(program_transform_name)'`; \
- ln -sf $$ts $(libdir)/$$tf; \
- elif [ "$$f" = "$(SHLIB)" ]; then \
- $(INSTALL_PROGRAM) $$f $(libdir)/$$tf; \
- else \
- $(INSTALL_DATA) $$f $(libdir)/$$tf; \
- $(RANLIB) $(libdir)/$$tf; \
- chmod a-x $(libdir)/$$tf; \
- fi; \
- done
-# Install BFD include file, and others that it needs. Install them
-# both in GCC's include directory, and in the system include dir
-# if configured as $(oldincludedir) -- which it usually isnt.
- $(INSTALL_DATA) $(BFD_H) $(includedir)/bfd.h
- $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(includedir)/ansidecl.h
- $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(includedir)/bfdlink.h
- $(INSTALL_DATA) $(INCDIR)/obstack.h $(includedir)/obstack.h
- -if test -z "$(oldincludedir)"; then true; else \
- test -d $(oldincludedir) || mkdir $(oldincludedir); \
- $(INSTALL_DATA) $(BFD_H) $(oldincludedir)/bfd.h; \
- $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(oldincludedir)/ansidecl.h; \
- $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(oldincludedir)/bfdlink.h; \
- $(INSTALL_DATA) $(INCDIR)/obstack.h $(oldincludedir)/obstack.h; \
- $(MAKE) subdir_do DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS); \
- fi
-
-Makefile: Makefile.in config.status
- CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
-
-config.h: stamp-h ; @true
-stamp-h: config.in config.status
- CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
-
-config.status: configure configure.host config.bfd
- $(SHELL) config.status --recheck
-
-# Have to get rid of .dep1 here so that "$?" later includes all of $(CFILES).
-.dep: dep.sed $(CFILES) $(HFILES) bfd.h
- rm -f .dep1
- $(MAKE) DEP=$(DEP) .dep1
- sed -f dep.sed <.dep1 >.dep
-
-# This rule really wants a mkdep that runs "gcc -MM".
-# The NetBSD mkdep overwrites any existing file contents, and doesn't insert
-# the "DO NOT DELETE" line.
-# Other mkdep versions require a file that already exists, and do insert it.
-# Hence the weirdness....
-.dep1: $(CFILES)
- rm -f .dep2 .dep2a
- echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep2
- echo > .dep2a
- $(DEP) -f .dep2a $(ALL_CFLAGS) $?
- sed -e '/DO NOT DELETE/d' -e '/^$$/d' < .dep2a >> .dep2
- rm -f .dep2a
- $(srcdir)/../move-if-change .dep2 .dep1
-
-dep.sed: dep-in.sed config.status
- sed <$(srcdir)/dep-in.sed >dep.sed \
- -e 's!@BFD_H@!$(BFD_H)!' \
- -e 's!@INCDIR@!$(INCDIR)!' \
- -e 's!@SRCDIR@!$(srcdir)!'
-
-dep: .dep
- sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
- cat .dep >> tmp-Makefile
- $(srcdir)/../move-if-change tmp-Makefile Makefile
-
-dep-in: .dep
- sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in
- cat .dep >> tmp-Makefile.in
- $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in
-
-host-aout.o: Makefile
-
-# The following program can be used to generate a simple config file
-# which can be folded into an h-XXX file for a new host, with some editing.
-aout-params.h: gen-aout
- ./gen-aout host > aout-params.h
-gen-aout: $(srcdir)/gen-aout.c Makefile
- $(CC) -o gen-aout $(CFLAGS) $(LFLAGS) $(srcdir)/gen-aout.c
-
-BFDIN_H= $(srcdir)/bfd-in2.h
-
-$(BFD_H): stmp-bfd.h ; @true
-
-stmp-bfd.h : $(srcdir)/bfd-in2.h Makefile
- rm -f bfd.h-new
- sed -e 's/@WORDSIZE@/$(WORDSIZE)/' \
- -e "s/@VERSION@/`cat $(srcdir)/VERSION`/" \
- -e 's/@BFD_HOST_64BIT_LONG@/@HOST_64BIT_LONG@/' \
- < $(srcdir)/bfd-in2.h \
- > bfd.h-new
- $(srcdir)/../move-if-change bfd.h-new $(BFD_H)
- touch stmp-bfd.h
-
-# Could really use a "copy-if-change"...
-headers:
- (cd $(docdir); $(MAKE) protos $(FLAGS_TO_PASS))
- cp $(docdir)/bfd.h bfd-in2.h-new
- $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
- cp $(docdir)/libbfd.h libbfd.h-new
- $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
- cp $(docdir)/libcoff.h libcoff.h-new
- $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
-
-# The rules for the generated header files are here so that people can
-# type `make bfd-in2.h' if they remove it. They are not run by default.
-$(srcdir)/bfd-in2.h:
- (cd $(docdir); $(MAKE) bfd.h $(FLAGS_TO_PASS))
- cp $(docdir)/bfd.h bfd-in2.h-new
- $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
-$(srcdir)/libbfd.h:
- (cd $(docdir); $(MAKE) libbfd.h $(FLAGS_TO_PASS))
- cp $(docdir)/libbfd.h libbfd.h-new
- $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
-$(srcdir)/libcoff.h:
- (cd $(docdir); $(MAKE) libcoff.h $(FLAGS_TO_PASS))
- cp $(docdir)/libcoff.h libcoff.h-new
- $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
-
-bfd.info:
- (cd $(docdir); $(MAKE) bfd.info $(FLAGS_TO_PASS))
-
-bfd.dvi:
- (cd $(docdir); $(MAKE) bfd.dvi $(FLAGS_TO_PASS))
-
-bfd.ps:
- (cd $(docdir); $(MAKE) bfd.ps $(FLAGS_TO_PASS))
-
-
-$(OFILES): stamp-picdir
-
-stamp-picdir:
- if [ -n "$(PICFLAG)" ] && [ ! -d pic ]; then \
- mkdir pic; \
- else true; fi
- touch stamp-picdir
-
-# What appears below is generated by a hacked mkdep using gcc -MM.
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
-archive.o: archive.c $(INCDIR)/aout/ar.h $(INCDIR)/aout/ranlib.h
-archures.o: archures.c
-bfd.o: bfd.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/sym.h libcoff.h libecoff.h $(INCDIR)/coff/ecoff.h \
- elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
- $(INCDIR)/elf/external.h
-cache.o: cache.c
-coffgen.o: coffgen.c $(INCDIR)/coff/internal.h libcoff.h \
- $(INCDIR)/bfdlink.h
-corefile.o: corefile.c
-format.o: format.c
-init.o: init.c
-libbfd.o: libbfd.c
-opncls.o: opncls.c
-reloc.o: reloc.c $(INCDIR)/bfdlink.h
-section.o: section.c
-syms.o: syms.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def
-targets.o: targets.c
-hash.o: hash.c
-linker.o: linker.c $(INCDIR)/bfdlink.h genlink.h
-elf.o: elf.c $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
-srec.o: srec.c $(INCDIR)/libiberty.h
-binary.o: binary.c
-tekhex.o: tekhex.c $(INCDIR)/libiberty.h
-ihex.o: ihex.c $(INCDIR)/libiberty.h
-stab-syms.o: stab-syms.c libaout.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab.def
-cpu-a29k.o: cpu-a29k.c
-cpu-alpha.o: cpu-alpha.c
-cpu-arm.o: cpu-arm.c
-cpu-h8300.o: cpu-h8300.c
-cpu-h8500.o: cpu-h8500.c
-cpu-hppa.o: cpu-hppa.c
-cpu-i386.o: cpu-i386.c
-cpu-i860.o: cpu-i860.c
-cpu-i960.o: cpu-i960.c
-cpu-m68k.o: cpu-m68k.c
-cpu-m88k.o: cpu-m88k.c
-cpu-mips.o: cpu-mips.c
-cpu-ns32k.o: cpu-ns32k.c
-cpu-powerpc.o: cpu-powerpc.c
-cpu-rs6000.o: cpu-rs6000.c
-cpu-sh.o: cpu-sh.c
-cpu-sparc.o: cpu-sparc.c
-cpu-vax.o: cpu-vax.c
-cpu-we32k.o: cpu-we32k.c
-cpu-w65.o: cpu-w65.c
-cpu-z8k.o: cpu-z8k.c
-aout-adobe.o: aout-adobe.c $(INCDIR)/aout/adobe.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def libaout.h $(INCDIR)/bfdlink.h
-aout-ns32k.o: aout-ns32k.c $(INCDIR)/aout/aout64.h \
- libaout.h $(INCDIR)/bfdlink.h
-aout0.o: aout0.c aoutf1.h $(INCDIR)/aout/sun4.h libaout.h \
- $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-aout32.o: aout32.c aoutx.h $(INCDIR)/bfdlink.h libaout.h \
- $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
- $(INCDIR)/aout/ar.h
-bout.o: bout.c $(INCDIR)/bfdlink.h genlink.h $(INCDIR)/bout.h \
- $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def libaout.h
-cf-i386lynx.o: cf-i386lynx.c coff-i386.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-cf-m68klynx.o: cf-m68klynx.c coff-m68k.c $(INCDIR)/coff/m68k.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-cf-sparclynx.o: cf-sparclynx.c coff-sparc.c $(INCDIR)/coff/sparc.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-a29k.o: coff-a29k.c $(INCDIR)/coff/a29k.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-apollo.o: coff-apollo.c $(INCDIR)/coff/apollo.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-arm.o: coff-arm.c $(INCDIR)/coff/arm.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-aux.o: coff-aux.c $(INCDIR)/coff/aux-coff.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/m68k.h coff-m68k.c libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-h8300.o: coff-h8300.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/h8300.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-coff-h8500.o: coff-h8500.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/h8500.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-coff-i386.o: coff-i386.c $(INCDIR)/coff/i386.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-i860.o: coff-i860.c $(INCDIR)/coff/i860.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-go32.o: coff-go32.c coff-i386.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-i960.o: coff-i960.c $(INCDIR)/coff/i960.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-m68k.o: coff-m68k.c $(INCDIR)/coff/m68k.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-m88k.o: coff-m88k.c $(INCDIR)/coff/m88k.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-mips.o: coff-mips.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
- $(INCDIR)/coff/mips.h libcoff.h libecoff.h coffswap.h \
- ecoffswap.h
-coff-pmac.o: coff-pmac.c coff-rs6000.c $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/rs6000.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-rs6000.o: coff-rs6000.c $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/rs6000.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-sh.o: coff-sh.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/sh.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-coff-sparc.o: coff-sparc.c $(INCDIR)/coff/sparc.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-u68k.o: coff-u68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-we32k.o: coff-we32k.c $(INCDIR)/coff/we32k.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-w65.o: coff-w65.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/w65.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-coff-z8k.o: coff-z8k.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/z8k.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-cofflink.o: cofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- libcoff.h
-ecoff.o: ecoff.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/ar.h \
- $(INCDIR)/aout/ranlib.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
- libaout.h $(INCDIR)/aout/aout64.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
- libcoff.h libecoff.h
-ecofflink.o: ecofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h \
- $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h
-elf32-gen.o: elf32-gen.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- elf32-target.h
-elf32-hppa.o: elf32-hppa.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elf32-hppa.h libhppa.h $(INCDIR)/elf/hppa.h hppa_stubs.h \
- elf32-target.h
-elf32-i386.o: elf32-i386.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elf32-target.h
-elf32-i860.o: elf32-i860.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- elf32-target.h
-elf32-m68k.o: elf32-m68k.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elf32-target.h
-elf32-m88k.o: elf32-m88k.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- elf32-target.h
-elf32-mips.o: elf32-mips.c $(INCDIR)/bfdlink.h genlink.h \
- elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
- $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/coff/sym.h \
- $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h ecoffswap.h \
- elf32-target.h
-elf32-ppc.o: elf32-ppc.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- $(INCDIR)/elf/ppc.h elf32-target.h
-elf32-sparc.o: elf32-sparc.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- $(INCDIR)/elf/sparc.h elf32-target.h
-elf32.o: elf32.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elfcore.h elflink.h
-elflink.o: elflink.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
-hp300hpux.o: hp300hpux.c $(INCDIR)/aout/hp300hpux.h \
- aoutx.h $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
- $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
- aout-target.h
-som.o: som.c
-i386aout.o: i386aout.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386bsd.o: i386bsd.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386freebsd.o: i386freebsd.c freebsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386linux.o: i386linux.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
- $(INCDIR)/bfdlink.h aout-target.h
-i386lynx.o: i386lynx.c libaout.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386msdos.o: i386msdos.c libaout.h $(INCDIR)/bfdlink.h
-i386netbsd.o: i386netbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386mach3.o: i386mach3.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
- $(INCDIR)/bfdlink.h aout-target.h
-i386os9k.o: i386os9k.c $(INCDIR)/bfdlink.h libaout.h \
- $(INCDIR)/os9k.h
-ieee.o: ieee.c $(INCDIR)/ieee.h libieee.h
-m68klinux.o: m68klinux.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
- $(INCDIR)/bfdlink.h aout-target.h
-m68klynx.o: m68klynx.c libaout.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-m68knetbsd.o: m68knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-m88kmach3.o: m88kmach3.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-mipsbsd.o: mipsbsd.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-newsos3.o: newsos3.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
- $(INCDIR)/bfdlink.h aout-target.h
-nlm.o: nlm.c libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
- $(INCDIR)/nlm/external.h
-nlm32-i386.o: nlm32-i386.c $(INCDIR)/nlm/i386-ext.h \
- libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
- $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
-nlm32-sparc.o: nlm32-sparc.c $(INCDIR)/nlm/sparc32-ext.h \
- libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
- $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
-nlm32-ppc.o: nlm32-ppc.c $(INCDIR)/nlm/ppc-ext.h libnlm.h \
- $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h \
- nlmswap.h nlm-target.h
-nlm32.o: nlm32.c nlmcode.h libnlm.h $(INCDIR)/nlm/common.h \
- $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h
-ns32knetbsd.o: ns32knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-oasys.o: oasys.c $(INCDIR)/oasys.h liboasys.h
-pc532-mach.o: pc532-mach.c libaout.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-pe-arm.o: pe-arm.c coff-arm.c $(INCDIR)/coff/arm.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pei-arm.o: pei-arm.c coff-arm.c $(INCDIR)/coff/arm.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pe-i386.o: pe-i386.c coff-i386.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pei-i386.o: pei-i386.c coff-i386.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pe-ppc.o: pe-ppc.c coff-ppc.c $(INCDIR)/coff/powerpc.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pei-ppc.o: pei-ppc.c coff-ppc.c $(INCDIR)/coff/powerpc.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-reloc16.o: reloc16.c $(INCDIR)/bfdlink.h genlink.h \
- $(INCDIR)/coff/internal.h libcoff.h
-sparclynx.o: sparclynx.c $(INCDIR)/aout/sun4.h libaout.h \
- $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-sparcnetbsd.o: sparcnetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-sunos.o: sunos.c $(INCDIR)/bfdlink.h libaout.h aoutf1.h \
- $(INCDIR)/aout/sun4.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-versados.o: versados.c $(INCDIR)/libiberty.h
-xcofflink.o: xcofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- libcoff.h
-aout64.o: aout64.c aoutx.h $(INCDIR)/bfdlink.h libaout.h \
- $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
- $(INCDIR)/aout/ar.h
-coff-alpha.o: coff-alpha.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
- $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \
- libecoff.h coffswap.h ecoffswap.h
-demo64.o: demo64.c aoutf1.h $(INCDIR)/aout/sun4.h libaout.h \
- $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-elf64-gen.o: elf64-gen.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- elf64-target.h
-elf64-sparc.o: elf64-sparc.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/elf/sparc.h elf64-target.h
-elf64.o: elf64.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elfcore.h elflink.h
-nlm32-alpha.o: nlm32-alpha.c $(INCDIR)/nlm/alpha-ext.h \
- libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
- $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
-nlm64.o: nlm64.c nlmcode.h libnlm.h $(INCDIR)/nlm/common.h \
- $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h
-aix386-core.o: aix386-core.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h
-hpux-core.o: hpux-core.c
-irix-core.o: irix-core.c
-lynx-core.o: lynx-core.c
-osf-core.o: osf-core.c
-trad-core.o: trad-core.c libaout.h $(INCDIR)/bfdlink.h
-cisco-core.o: cisco-core.c
-i386dynix.o: i386dynix.c $(INCDIR)/aout/dynix3.h aoutx.h \
- $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
- $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
- aout-target.h
-hp300bsd.o: hp300bsd.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/contrib/gdb/bfd/PORTING b/contrib/gdb/bfd/PORTING
deleted file mode 100644
index c8bfd77b96ff..000000000000
--- a/contrib/gdb/bfd/PORTING
+++ /dev/null
@@ -1,83 +0,0 @@
- Preliminary Notes on Porting BFD
- --------------------------------
-
-The 'host' is the system a tool runs *on*.
-The 'target' is the system a tool runs *for*, i.e.
-a tool can read/write the binaries of the target.
-
-Porting to a new host
----------------------
-Pick a name for your host. Call that <host>.
-(<host> might be sun4, ...)
-Create a file hosts/<host>.mh.
-
-Porting to a new target
------------------------
-Pick a name for your target. Call that <target>.
-Call the name for your CPU architecture <cpu>.
-You need to create <target>.c and config/<target>.mt,
-and add a case for it to a case statements in bfd/configure.host and
-bfd/config.bfd, which associates each canonical host type with a BFD
-host type (used as the base of the makefile fragment names), and to the
-table in bfd/configure.in which associates each target vector with
-the .o files it uses.
-
-config/<target>.mt is a Makefile fragment.
-The following is usually enough:
-DEFAULT_VECTOR=<target>_vec
-SELECT_ARCHITECTURES=bfd_<cpu>_arch
-
-See the list of cpu types in archures.c, or "ls cpu-*.c".
-If your architecture is new, you need to add it to the tables
-in bfd/archures.c, opcodes/configure.in, and binutils/objdump.c.
-
-For more information about .mt and .mh files, see config/README.
-
-The file <target>.c is the hard part. It implements the
-bfd_target <target>_vec, which includes pointers to
-functions that do the actual <target>-specific methods.
-
-Porting to a <target> that uses the a.out binary format
--------------------------------------------------------
-
-In this case, the include file aout-target.h probaby does most
-of what you need. The program gen-aout generates <target>.c for
-you automatically for many a.out systems. Do:
- make gen-aout
- ./gen-aout <target> > <target>.c
-(This only works if you are building on the target ("native").
-If you must make a cross-port from scratch, copy the most
-similar existing file that includes aout-target.h, and fix what is wrong.)
-
-Check the parameters in <target>.c, and fix anything that is wrong.
-(Also let us know about it; perhaps we can improve gen-aout.c.)
-
-TARGET_IS_BIG_ENDIAN_P
- Should be defined if <target> is big-endian.
-
-N_HEADER_IN_TEXT(x)
- See discussion in ../include/aout/aout64.h.
-
-BYTES_IN_WORD
- Number of bytes per word. (Usually 4 but can be 8.)
-
-ARCH
- Number of bits per word. (Usually 32, but can be 64.)
-
-ENTRY_CAN_BE_ZERO
- Define if the extry point (start address of an
- executable program) can be 0x0.
-
-TEXT_START_ADDR
- The address of the start of the text segemnt in
- virtual memory. Normally, the same as the entry point.
-
-TARGET_PAGE_SIZE
-
-SEGMENT_SIZE
- Usually, the same as the TARGET_PAGE_SIZE.
- Alignment needed for the data segment.
-
-TARGETNAME
- The name of the target, for run-time lookups.
- Usually "a.out-<target>"
diff --git a/contrib/gdb/bfd/TODO b/contrib/gdb/bfd/TODO
deleted file mode 100644
index 08a3641b1ade..000000000000
--- a/contrib/gdb/bfd/TODO
+++ /dev/null
@@ -1,25 +0,0 @@
-Things that still need to be done: -*- Text -*-
-
- o - A source of space lossage is that all the target-dependent code
- is in a single bfd_target structure. Hence all the code for
- *writing* object files is still pulled into all the applications
- that only care about *reading* (gdb, nm, objdump), while gas has
- to carry along all the unneded baggage for reading objects. And
- so on. This would be a substantial change, and the payoff would
- not all that great (essentially none if bfd is used as a shared
- library).
-
- o - The storage needed by BFD data structures is also larger than strictly
- needed. This may be difficult to do much about.
-
- o - implement bfd_abort, which should close the bfd but not alter the
- filesystem.
-
- o - update the bfd doc; write a how-to-write-a-backend doc, take out
- the stupid quips and fill in all the blanks.
-
- o - upgrade the reloc handling as per Steve's suggestion.
-
-
-
-
diff --git a/contrib/gdb/bfd/VERSION b/contrib/gdb/bfd/VERSION
deleted file mode 100644
index 9ddf6b5ad1a6..000000000000
--- a/contrib/gdb/bfd/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-cygnus-2.6
diff --git a/contrib/gdb/bfd/acconfig.h b/contrib/gdb/bfd/acconfig.h
deleted file mode 100644
index 647798cbe9f0..000000000000
--- 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/aclocal.m4 b/contrib/gdb/bfd/aclocal.m4
deleted file mode 100644
index 1f5027e48589..000000000000
--- a/contrib/gdb/bfd/aclocal.m4
+++ /dev/null
@@ -1,43 +0,0 @@
-dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
-AC_DEFUN(BFD_BINARY_FOPEN,
-[AC_REQUIRE([AC_CANONICAL_SYSTEM])
-case "${host}" in
-changequote(,)dnl
-i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32)
-changequote([,])dnl
- AC_DEFINE(USE_BINARY_FOPEN) ;;
-esac])dnl
-
-dnl Get a default for CC_FOR_BUILD to put into Makefile.
-AC_DEFUN(BFD_CC_FOR_BUILD,
-[# Put a plausible default for CC_FOR_BUILD in Makefile.
-AC_REQUIRE([AC_C_CROSS])dnl
-if test -z "$CC_FOR_BUILD"; then
- if test "x$cross_compiling" = "xno"; then
- CC_FOR_BUILD='$(CC)'
- else
- CC_FOR_BUILD=gcc
- fi
-fi
-AC_SUBST(CC_FOR_BUILD)])dnl
-
-dnl See whether we need a declaration for a function.
-AC_DEFUN(BFD_NEED_DECLARATION,
-[AC_MSG_CHECKING([whether $1 must be declared])
-AC_CACHE_VAL(bfd_cv_decl_needed_$1,
-[AC_TRY_COMPILE([
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif],
-[char *(*pfn) = (char *(*)) $1],
-bfd_cv_decl_needed_$1=no, bfd_cv_decl_needed_$1=yes)])
-AC_MSG_RESULT($bfd_cv_decl_needed_$1)
-if test $bfd_cv_decl_needed_$1 = yes; then
- bfd_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- AC_DEFINE_UNQUOTED($bfd_tr_decl)
-fi
-])dnl
diff --git a/contrib/gdb/bfd/aix386-core.c b/contrib/gdb/bfd/aix386-core.c
deleted file mode 100644
index 21ec9a6d4313..000000000000
--- 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 36d230de9e8a..000000000000
--- 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 978664a48aaf..000000000000
--- 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 c25f9037dce0..000000000000
--- 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 269e053fe5ac..000000000000
--- 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/aout-target.h b/contrib/gdb/bfd/aout-target.h
deleted file mode 100644
index 6711a714a571..000000000000
--- a/contrib/gdb/bfd/aout-target.h
+++ /dev/null
@@ -1,607 +0,0 @@
-/* Define a target vector and some small routines for a variant of a.out.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
-
-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 "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-/*#include "libaout.h"*/
-
-extern reloc_howto_type * NAME(aout,reloc_type_lookup) ();
-
-/* Set parameters about this a.out file that are machine-dependent.
- This routine is called from some_aout_object_p just before it returns. */
-#ifndef MY_callback
-static const bfd_target *
-MY(callback) (abfd)
- bfd *abfd;
-{
- struct internal_exec *execp = exec_hdr (abfd);
- unsigned int arch_align_power;
- unsigned long arch_align;
-
- /* 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
-
- /* Now that we know the architecture, set the alignments of the
- sections. This is normally done by NAME(aout,new_section_hook),
- but when the initial sections were created the architecture had
- not yet been set. However, for backward compatibility, we don't
- set the alignment power any higher than as required by the size
- of the section. */
- arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
- arch_align = 1 << arch_align_power;
- if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align)
- == obj_textsec (abfd)->_raw_size)
- && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align)
- == obj_datasec (abfd)->_raw_size)
- && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align)
- == obj_bsssec (abfd)->_raw_size))
- {
- obj_textsec (abfd)->alignment_power = arch_align_power;
- obj_datasec (abfd)->alignment_power = arch_align_power;
- obj_bsssec (abfd)->alignment_power = arch_align_power;
- }
-
- /* Don't set sizes now -- can't be sure until we know arch & mach.
- Sizes get set in set_sizes callback, later. */
-#if 0
- adata(abfd).page_size = TARGET_PAGE_SIZE;
-#ifdef SEGMENT_SIZE
- adata(abfd).segment_size = SEGMENT_SIZE;
-#else
- adata(abfd).segment_size = TARGET_PAGE_SIZE;
-#endif
- adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
-#endif
-
- return abfd->xvec;
-}
-#endif
-
-#ifndef MY_object_p
-/* Finish up the reading of an a.out file header */
-
-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;
- }
-
-#ifdef SWAP_MAGIC
- exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
-#else
- exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
-#endif /* SWAP_MAGIC */
-
- 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);
-
-#ifdef SWAP_MAGIC
- /* swap_exec_header_in read in a_info with the wrong byte order */
- exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
-#endif /* SWAP_MAGIC */
-
- target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
-
-#ifdef ENTRY_CAN_BE_ZERO
- /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
- * means that it isn't obvious if EXEC_P should be set.
- * All of the following must be true for an executable:
- * There must be no relocations, the bfd can be neither an
- * archive nor an archive element, and the file must be executable. */
-
- if (exec.a_trsize + exec.a_drsize == 0
- && bfd_get_format(abfd) == bfd_object && abfd->my_archive == NULL)
- {
- struct stat buf;
-#ifndef S_IXUSR
-#define S_IXUSR 0100 /* Execute by owner. */
-#endif
- if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
- abfd->flags |= EXEC_P;
- }
-#endif /* ENTRY_CAN_BE_ZERO */
-
- return target;
-}
-#define MY_object_p MY(object_p)
-#endif
-
-
-#ifndef MY_mkobject
-static boolean
-MY(mkobject) (abfd)
- bfd *abfd;
-{
- if (NAME(aout,mkobject)(abfd) == false)
- return false;
-#if 0 /* Sizes get set in set_sizes callback, later, after we know
- the architecture and machine. */
- adata(abfd).page_size = TARGET_PAGE_SIZE;
-#ifdef SEGMENT_SIZE
- adata(abfd).segment_size = SEGMENT_SIZE;
-#else
- adata(abfd).segment_size = TARGET_PAGE_SIZE;
-#endif
- adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
-#endif
- return true;
-}
-#define MY_mkobject MY(mkobject)
-#endif
-
-#ifndef MY_bfd_copy_private_section_data
-
-/* Copy private section data. This actually does nothing with the
- sections. It copies the subformat field. We copy it here, because
- we need to know whether this is a QMAGIC file before we set the
- section contents, and copy_private_bfd_data is not called until
- after the section contents have been set. */
-
-/*ARGSUSED*/
-static boolean
-MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
- bfd *ibfd;
- asection *isec;
- bfd *obfd;
- asection *osec;
-{
- if (bfd_get_flavour (obfd) == bfd_target_aout_flavour)
- obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
- return true;
-}
-
-#endif
-
-/* Write an object file.
- Section contents have already been written. We write the
- file header, symbols, and relocation. */
-
-#ifndef MY_write_object_contents
-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
-
- WRITE_HEADERS(abfd, execp);
-
- return true;
-}
-#define MY_write_object_contents MY(write_object_contents)
-#endif
-
-#ifndef MY_set_sizes
-static boolean
-MY(set_sizes) (abfd)
- bfd *abfd;
-{
- adata(abfd).page_size = TARGET_PAGE_SIZE;
-
-#ifdef SEGMENT_SIZE
- adata(abfd).segment_size = SEGMENT_SIZE;
-#else
- adata(abfd).segment_size = TARGET_PAGE_SIZE;
-#endif
-
-#ifdef ZMAGIC_DISK_BLOCK_SIZE
- adata(abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
-#else
- adata(abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE;
-#endif
-
- adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
- return true;
-}
-#define MY_set_sizes MY(set_sizes)
-#endif
-
-#ifndef MY_exec_hdr_flags
-#define MY_exec_hdr_flags 0
-#endif
-
-#ifndef MY_backend_data
-
-#ifndef MY_zmagic_contiguous
-#define MY_zmagic_contiguous 0
-#endif
-#ifndef MY_text_includes_header
-#define MY_text_includes_header 0
-#endif
-#ifndef MY_exec_header_not_counted
-#define MY_exec_header_not_counted 0
-#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 MY(backend_data) = {
- MY_zmagic_contiguous,
- MY_text_includes_header,
- MY_exec_hdr_flags,
- 0, /* text vma? */
- MY_set_sizes,
- MY_exec_header_not_counted,
- 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_backend_data &MY(backend_data)
-#endif
-
-#ifndef MY_final_link_callback
-
-/* Callback for the final_link routine to set the section offsets. */
-
-static void MY_final_link_callback
- PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
-
-static void
-MY_final_link_callback (abfd, ptreloff, pdreloff, psymoff)
- bfd *abfd;
- file_ptr *ptreloff;
- file_ptr *pdreloff;
- file_ptr *psymoff;
-{
- struct internal_exec *execp = exec_hdr (abfd);
-
- *ptreloff = N_TRELOFF (*execp);
- *pdreloff = N_DRELOFF (*execp);
- *psymoff = N_SYMOFF (*execp);
-}
-
-#endif
-
-#ifndef MY_bfd_final_link
-
-/* Final link routine. We need to use a call back to get the correct
- offsets in the output file. */
-
-static boolean
-MY_bfd_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
-}
-
-#endif
-
-/* We assume BFD generic archive files. */
-#ifndef MY_openr_next_archived_file
-#define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
-#endif
-#ifndef MY_get_elt_at_index
-#define MY_get_elt_at_index _bfd_generic_get_elt_at_index
-#endif
-#ifndef MY_generic_stat_arch_elt
-#define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#endif
-#ifndef MY_slurp_armap
-#define MY_slurp_armap bfd_slurp_bsd_armap
-#endif
-#ifndef MY_slurp_extended_name_table
-#define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
-#endif
-#ifndef MY_construct_extended_name_table
-#define MY_construct_extended_name_table \
- _bfd_archive_bsd_construct_extended_name_table
-#endif
-#ifndef MY_write_armap
-#define MY_write_armap bsd_write_armap
-#endif
-#ifndef MY_read_ar_hdr
-#define MY_read_ar_hdr _bfd_generic_read_ar_hdr
-#endif
-#ifndef MY_truncate_arname
-#define MY_truncate_arname bfd_bsd_truncate_arname
-#endif
-#ifndef MY_update_armap_timestamp
-#define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
-#endif
-
-/* No core file defined here -- configure in trad-core.c separately. */
-#ifndef MY_core_file_failing_command
-#define MY_core_file_failing_command _bfd_nocore_core_file_failing_command
-#endif
-#ifndef MY_core_file_failing_signal
-#define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal
-#endif
-#ifndef MY_core_file_matches_executable_p
-#define MY_core_file_matches_executable_p \
- _bfd_nocore_core_file_matches_executable_p
-#endif
-#ifndef MY_core_file_p
-#define MY_core_file_p _bfd_dummy_target
-#endif
-
-#ifndef MY_bfd_debug_info_start
-#define MY_bfd_debug_info_start bfd_void
-#endif
-#ifndef MY_bfd_debug_info_end
-#define MY_bfd_debug_info_end bfd_void
-#endif
-#ifndef MY_bfd_debug_info_accumulate
-#define MY_bfd_debug_info_accumulate \
- (void (*) PARAMS ((bfd*, struct sec *))) bfd_void
-#endif
-
-#ifndef MY_core_file_failing_command
-#define MY_core_file_failing_command NAME(aout,core_file_failing_command)
-#endif
-#ifndef MY_core_file_failing_signal
-#define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
-#endif
-#ifndef MY_core_file_matches_executable_p
-#define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
-#endif
-#ifndef MY_set_section_contents
-#define MY_set_section_contents NAME(aout,set_section_contents)
-#endif
-#ifndef MY_get_section_contents
-#define MY_get_section_contents NAME(aout,get_section_contents)
-#endif
-#ifndef MY_get_section_contents_in_window
-#define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
-#endif
-#ifndef MY_new_section_hook
-#define MY_new_section_hook NAME(aout,new_section_hook)
-#endif
-#ifndef MY_get_symtab_upper_bound
-#define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
-#endif
-#ifndef MY_get_symtab
-#define MY_get_symtab NAME(aout,get_symtab)
-#endif
-#ifndef MY_get_reloc_upper_bound
-#define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
-#endif
-#ifndef MY_canonicalize_reloc
-#define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
-#endif
-#ifndef MY_make_empty_symbol
-#define MY_make_empty_symbol NAME(aout,make_empty_symbol)
-#endif
-#ifndef MY_print_symbol
-#define MY_print_symbol NAME(aout,print_symbol)
-#endif
-#ifndef MY_get_symbol_info
-#define MY_get_symbol_info NAME(aout,get_symbol_info)
-#endif
-#ifndef MY_get_lineno
-#define MY_get_lineno NAME(aout,get_lineno)
-#endif
-#ifndef MY_set_arch_mach
-#define MY_set_arch_mach NAME(aout,set_arch_mach)
-#endif
-#ifndef MY_find_nearest_line
-#define MY_find_nearest_line NAME(aout,find_nearest_line)
-#endif
-#ifndef MY_sizeof_headers
-#define MY_sizeof_headers NAME(aout,sizeof_headers)
-#endif
-#ifndef MY_bfd_get_relocated_section_contents
-#define MY_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#endif
-#ifndef MY_bfd_relax_section
-#define MY_bfd_relax_section bfd_generic_relax_section
-#endif
-#ifndef MY_bfd_reloc_type_lookup
-#define MY_bfd_reloc_type_lookup NAME(aout,reloc_type_lookup)
-#endif
-#ifndef MY_bfd_make_debug_symbol
-#define MY_bfd_make_debug_symbol 0
-#endif
-#ifndef MY_read_minisymbols
-#define MY_read_minisymbols NAME(aout,read_minisymbols)
-#endif
-#ifndef MY_minisymbol_to_symbol
-#define MY_minisymbol_to_symbol NAME(aout,minisymbol_to_symbol)
-#endif
-#ifndef MY_bfd_link_hash_table_create
-#define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
-#endif
-#ifndef MY_bfd_link_add_symbols
-#define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
-#endif
-#ifndef MY_bfd_link_split_section
-#define MY_bfd_link_split_section _bfd_generic_link_split_section
-#endif
-
-
-#ifndef MY_bfd_copy_private_bfd_data
-#define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
-#endif
-
-#ifndef MY_bfd_merge_private_bfd_data
-#define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
-#endif
-
-#ifndef MY_bfd_copy_private_symbol_data
-#define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
-#endif
-
-#ifndef MY_bfd_print_private_bfd_data
-#define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
-#endif
-
-#ifndef MY_bfd_set_private_flags
-#define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
-#endif
-
-#ifndef MY_bfd_is_local_label
-#define MY_bfd_is_local_label bfd_generic_is_local_label
-#endif
-
-#ifndef MY_bfd_free_cached_info
-#define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info)
-#endif
-
-#ifndef MY_close_and_cleanup
-#define MY_close_and_cleanup MY_bfd_free_cached_info
-#endif
-
-#ifndef MY_get_dynamic_symtab_upper_bound
-#define MY_get_dynamic_symtab_upper_bound \
- _bfd_nodynamic_get_dynamic_symtab_upper_bound
-#endif
-#ifndef MY_canonicalize_dynamic_symtab
-#define MY_canonicalize_dynamic_symtab \
- _bfd_nodynamic_canonicalize_dynamic_symtab
-#endif
-#ifndef MY_get_dynamic_reloc_upper_bound
-#define MY_get_dynamic_reloc_upper_bound \
- _bfd_nodynamic_get_dynamic_reloc_upper_bound
-#endif
-#ifndef MY_canonicalize_dynamic_reloc
-#define MY_canonicalize_dynamic_reloc \
- _bfd_nodynamic_canonicalize_dynamic_reloc
-#endif
-
-/* Aout symbols normally have leading underscores */
-#ifndef MY_symbol_leading_char
-#define MY_symbol_leading_char '_'
-#endif
-
-/* Aout archives normally use spaces for padding */
-#ifndef AR_PAD_CHAR
-#define AR_PAD_CHAR ' '
-#endif
-
-#ifndef MY_BFD_TARGET
-const bfd_target MY(vec) =
-{
- TARGETNAME, /* name */
- bfd_target_aout_flavour,
-#ifdef TARGET_IS_BIG_ENDIAN_P
- BFD_ENDIAN_BIG, /* target byte order (big) */
- BFD_ENDIAN_BIG, /* target headers byte order (big) */
-#else
- BFD_ENDIAN_LITTLE, /* target byte order (little) */
- BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
-#endif
- (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 */
-#ifdef TARGET_IS_BIG_ENDIAN_P
- 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 */
-#else
- 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 */
-#endif
- {_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,
-};
-#endif /* MY_BFD_TARGET */
diff --git a/contrib/gdb/bfd/aout0.c b/contrib/gdb/bfd/aout0.c
deleted file mode 100644
index 5bc7ae0f67f8..000000000000
--- 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/aout32.c b/contrib/gdb/bfd/aout32.c
deleted file mode 100644
index bfc40b46303b..000000000000
--- a/contrib/gdb/bfd/aout32.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* BFD back-end for 32-bit a.out files.
- 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 32
-
-#include "aoutx.h"
diff --git a/contrib/gdb/bfd/aout64.c b/contrib/gdb/bfd/aout64.c
deleted file mode 100644
index 84036c885a29..000000000000
--- 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 690d528b5c44..000000000000
--- 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/aoutx.h b/contrib/gdb/bfd/aoutx.h
deleted file mode 100644
index 4b04943e028b..000000000000
--- a/contrib/gdb/bfd/aoutx.h
+++ /dev/null
@@ -1,5525 +0,0 @@
-/* BFD semi-generic back-end for a.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. */
-
-/*
-SECTION
- a.out backends
-
-
-DESCRIPTION
-
- BFD supports a number of different flavours of a.out format,
- though the major differences are only the sizes of the
- structures on disk, and the shape of the relocation
- information.
-
- The support is split into a basic support file @file{aoutx.h}
- and other files which derive functions from the base. One
- derivation file is @file{aoutf1.h} (for a.out flavour 1), and
- adds to the basic a.out functions support for sun3, sun4, 386
- and 29k a.out files, to create a target jump vector for a
- specific target.
-
- This information is further split out into more specific files
- for each machine, including @file{sunos.c} for sun3 and sun4,
- @file{newsos3.c} for the Sony NEWS, and @file{demo64.c} for a
- demonstration of a 64 bit a.out format.
-
- The base file @file{aoutx.h} defines general mechanisms for
- reading and writing records to and from disk and various
- other methods which BFD requires. It is included by
- @file{aout32.c} and @file{aout64.c} to form the names
- <<aout_32_swap_exec_header_in>>, <<aout_64_swap_exec_header_in>>, etc.
-
- As an example, this is what goes on to make the back end for a
- sun4, from @file{aout32.c}:
-
-| #define ARCH_SIZE 32
-| #include "aoutx.h"
-
- Which exports names:
-
-| ...
-| aout_32_canonicalize_reloc
-| aout_32_find_nearest_line
-| aout_32_get_lineno
-| aout_32_get_reloc_upper_bound
-| ...
-
- from @file{sunos.c}:
-
-| #define TARGET_NAME "a.out-sunos-big"
-| #define VECNAME sunos_big_vec
-| #include "aoutf1.h"
-
- requires all the names from @file{aout32.c}, and produces the jump vector
-
-| sunos_big_vec
-
- The file @file{host-aout.c} is a special case. It is for a large set
- of hosts that use ``more or less standard'' a.out files, and
- for which cross-debugging is not interesting. It uses the
- standard 32-bit a.out support routines, but determines the
- file offsets and addresses of the text, data, and BSS
- sections, the machine architecture and machine type, and the
- entry point address, in a host-dependent manner. Once these
- values have been determined, generic code is used to handle
- the object file.
-
- When porting it to run on a new system, you must supply:
-
-| HOST_PAGE_SIZE
-| HOST_SEGMENT_SIZE
-| HOST_MACHINE_ARCH (optional)
-| HOST_MACHINE_MACHINE (optional)
-| HOST_TEXT_START_ADDR
-| HOST_STACK_END_ADDR
-
- in the file @file{../include/sys/h-@var{XXX}.h} (for your host). These
- values, plus the structures and macros defined in @file{a.out.h} on
- your host system, will produce a BFD target that will access
- ordinary a.out files on your host. To configure a new machine
- to use @file{host-aout.c}, specify:
-
-| TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec
-| TDEPFILES= host-aout.o trad-core.o
-
- in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in}
- to use the
- @file{@var{XXX}.mt} file (by setting "<<bfd_target=XXX>>") when your
- configuration is selected.
-
-*/
-
-/* Some assumptions:
- * Any BFD with D_PAGED set is ZMAGIC, and vice versa.
- Doesn't matter what the setting of WP_TEXT is on output, but it'll
- get set on input.
- * Any BFD with D_PAGED clear and WP_TEXT set is NMAGIC.
- * Any BFD with both flags clear is OMAGIC.
- (Just want to make these explicit, so the conditions tested in this
- file make sense if you're more familiar with a.out than with BFD.) */
-
-#define KEEPIT udata.i
-
-#include <string.h> /* For strchr and friends */
-#include <ctype.h>
-#include "bfd.h"
-#include <sysdep.h>
-#include "bfdlink.h"
-
-#include "libaout.h"
-#include "libbfd.h"
-#include "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-
-static boolean aout_get_external_symbols PARAMS ((bfd *));
-static boolean translate_from_native_sym_flags
- PARAMS ((bfd *, aout_symbol_type *));
-static boolean translate_to_native_sym_flags
- PARAMS ((bfd *, asymbol *, struct external_nlist *));
-
-/*
-SUBSECTION
- Relocations
-
-DESCRIPTION
- The file @file{aoutx.h} provides for both the @emph{standard}
- and @emph{extended} forms of a.out relocation records.
-
- The standard records contain only an
- address, a symbol index, and a type field. The extended records
- (used on 29ks and sparcs) also have a full integer for an
- addend.
-
-*/
-#ifndef CTOR_TABLE_RELOC_HOWTO
-#define CTOR_TABLE_RELOC_IDX 2
-#define CTOR_TABLE_RELOC_HOWTO(BFD) ((obj_reloc_entry_size(BFD) == RELOC_EXT_SIZE \
- ? howto_table_ext : howto_table_std) \
- + CTOR_TABLE_RELOC_IDX)
-#endif
-
-#ifndef MY_swap_std_reloc_in
-#define MY_swap_std_reloc_in NAME(aout,swap_std_reloc_in)
-#endif
-
-#ifndef MY_swap_std_reloc_out
-#define MY_swap_std_reloc_out NAME(aout,swap_std_reloc_out)
-#endif
-
-#ifndef MY_final_link_relocate
-#define MY_final_link_relocate _bfd_final_link_relocate
-#endif
-
-#ifndef MY_relocate_contents
-#define MY_relocate_contents _bfd_relocate_contents
-#endif
-
-#define howto_table_ext NAME(aout,ext_howto_table)
-#define howto_table_std NAME(aout,std_howto_table)
-
-reloc_howto_type howto_table_ext[] =
-{
- /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
- HOWTO(RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", false, 0,0x000000ff, false),
- HOWTO(RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", false, 0,0x0000ffff, false),
- HOWTO(RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", false, 0,0xffffffff, false),
- HOWTO(RELOC_DISP8, 0, 0, 8, true, 0, complain_overflow_signed,0,"DISP8", false, 0,0x000000ff, false),
- HOWTO(RELOC_DISP16, 0, 1, 16, true, 0, complain_overflow_signed,0,"DISP16", false, 0,0x0000ffff, false),
- HOWTO(RELOC_DISP32, 0, 2, 32, true, 0, complain_overflow_signed,0,"DISP32", false, 0,0xffffffff, false),
- HOWTO(RELOC_WDISP30,2, 2, 30, true, 0, complain_overflow_signed,0,"WDISP30", false, 0,0x3fffffff, false),
- HOWTO(RELOC_WDISP22,2, 2, 22, true, 0, complain_overflow_signed,0,"WDISP22", false, 0,0x003fffff, false),
- HOWTO(RELOC_HI22, 10, 2, 22, false, 0, complain_overflow_bitfield,0,"HI22", false, 0,0x003fffff, false),
- HOWTO(RELOC_22, 0, 2, 22, false, 0, complain_overflow_bitfield,0,"22", false, 0,0x003fffff, false),
- HOWTO(RELOC_13, 0, 2, 13, false, 0, complain_overflow_bitfield,0,"13", false, 0,0x00001fff, false),
- HOWTO(RELOC_LO10, 0, 2, 10, false, 0, complain_overflow_dont,0,"LO10", false, 0,0x000003ff, false),
- HOWTO(RELOC_SFA_BASE,0, 2, 32, false, 0, complain_overflow_bitfield,0,"SFA_BASE", false, 0,0xffffffff, false),
- HOWTO(RELOC_SFA_OFF13,0,2, 32, false, 0, complain_overflow_bitfield,0,"SFA_OFF13",false, 0,0xffffffff, false),
- HOWTO(RELOC_BASE10, 0, 2, 10, false, 0, complain_overflow_dont,0,"BASE10", false, 0,0x000003ff, false),
- HOWTO(RELOC_BASE13, 0, 2, 13, false, 0, complain_overflow_bitfield,0,"BASE13", false, 0,0x00001fff, false),
- HOWTO(RELOC_BASE22, 10, 2, 22, false, 0, complain_overflow_bitfield,0,"BASE22", false, 0,0x003fffff, false),
- HOWTO(RELOC_PC10, 0, 2, 10, true, 0, complain_overflow_dont,0,"PC10", false, 0,0x000003ff, true),
- HOWTO(RELOC_PC22, 10, 2, 22, true, 0, complain_overflow_signed,0,"PC22", false, 0,0x003fffff, true),
- HOWTO(RELOC_JMP_TBL,2, 2, 30, true, 0, complain_overflow_signed,0,"JMP_TBL", false, 0,0x3fffffff, false),
- HOWTO(RELOC_SEGOFF16,0, 2, 0, false, 0, complain_overflow_bitfield,0,"SEGOFF16", false, 0,0x00000000, false),
- HOWTO(RELOC_GLOB_DAT,0, 2, 0, false, 0, complain_overflow_bitfield,0,"GLOB_DAT", false, 0,0x00000000, false),
- HOWTO(RELOC_JMP_SLOT,0, 2, 0, false, 0, complain_overflow_bitfield,0,"JMP_SLOT", false, 0,0x00000000, false),
- HOWTO(RELOC_RELATIVE,0, 2, 0, false, 0, complain_overflow_bitfield,0,"RELATIVE", false, 0,0x00000000, false),
-};
-
-/* Convert standard reloc records to "arelent" format (incl byte swap). */
-
-reloc_howto_type howto_table_std[] = {
- /* 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, 0, 4, 64, false, 0, complain_overflow_bitfield,0,"64", true, 0xdeaddead,0xdeaddead, false),
-HOWTO( 4, 0, 0, 8, true, 0, complain_overflow_signed, 0,"DISP8", true, 0x000000ff,0x000000ff, false),
-HOWTO( 5, 0, 1, 16, true, 0, complain_overflow_signed, 0,"DISP16", true, 0x0000ffff,0x0000ffff, false),
-HOWTO( 6, 0, 2, 32, true, 0, complain_overflow_signed, 0,"DISP32", true, 0xffffffff,0xffffffff, false),
-HOWTO( 7, 0, 4, 64, true, 0, complain_overflow_signed, 0,"DISP64", true, 0xfeedface,0xfeedface, false),
-HOWTO( 8, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"GOT_REL", false, 0,0x00000000, false),
-HOWTO( 9, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"BASE16", false,0xffffffff,0xffffffff, false),
-HOWTO(10, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"BASE32", false,0xffffffff,0xffffffff, false),
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
- HOWTO(16, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"JMP_TABLE", false, 0,0x00000000, false),
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 },
- HOWTO(32, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"RELATIVE", false, 0,0x00000000, false),
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
- HOWTO(40, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"BASEREL", false, 0,0x00000000, false),
-};
-
-#define TABLE_SIZE(TABLE) (sizeof(TABLE)/sizeof(TABLE[0]))
-
-reloc_howto_type *
-NAME(aout,reloc_type_lookup) (abfd,code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
-#define EXT(i,j) case i: return &howto_table_ext[j]
-#define STD(i,j) case i: return &howto_table_std[j]
- int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
- if (code == BFD_RELOC_CTOR)
- switch (bfd_get_arch_info (abfd)->bits_per_address)
- {
- case 32:
- code = BFD_RELOC_32;
- break;
- case 64:
- code = BFD_RELOC_64;
- break;
- }
- if (ext)
- switch (code)
- {
- EXT (BFD_RELOC_32, 2);
- EXT (BFD_RELOC_HI22, 8);
- EXT (BFD_RELOC_LO10, 11);
- EXT (BFD_RELOC_32_PCREL_S2, 6);
- EXT (BFD_RELOC_SPARC_WDISP22, 7);
- EXT (BFD_RELOC_SPARC13, 10);
- EXT (BFD_RELOC_SPARC_GOT10, 14);
- EXT (BFD_RELOC_SPARC_BASE13, 15);
- EXT (BFD_RELOC_SPARC_GOT13, 15);
- EXT (BFD_RELOC_SPARC_GOT22, 16);
- EXT (BFD_RELOC_SPARC_PC10, 17);
- EXT (BFD_RELOC_SPARC_PC22, 18);
- EXT (BFD_RELOC_SPARC_WPLT30, 19);
- default: return (reloc_howto_type *) NULL;
- }
- else
- /* std relocs */
- switch (code)
- {
- STD (BFD_RELOC_16, 1);
- STD (BFD_RELOC_32, 2);
- STD (BFD_RELOC_8_PCREL, 4);
- STD (BFD_RELOC_16_PCREL, 5);
- STD (BFD_RELOC_32_PCREL, 6);
- STD (BFD_RELOC_16_BASEREL, 9);
- STD (BFD_RELOC_32_BASEREL, 10);
- default: return (reloc_howto_type *) NULL;
- }
-}
-
-/*
-SUBSECTION
- Internal entry points
-
-DESCRIPTION
- @file{aoutx.h} exports several routines for accessing the
- contents of an a.out file, which are gathered and exported in
- turn by various format specific files (eg sunos.c).
-
-*/
-
-/*
-FUNCTION
- aout_@var{size}_swap_exec_header_in
-
-SYNOPSIS
- void aout_@var{size}_swap_exec_header_in,
- (bfd *abfd,
- struct external_exec *raw_bytes,
- struct internal_exec *execp);
-
-DESCRIPTION
- Swap the information in an executable header @var{raw_bytes} taken
- from a raw byte stream memory image into the internal exec header
- structure @var{execp}.
-*/
-
-#ifndef NAME_swap_exec_header_in
-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 ((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);
-}
-#define NAME_swap_exec_header_in NAME(aout,swap_exec_header_in)
-#endif
-
-/*
-FUNCTION
- aout_@var{size}_swap_exec_header_out
-
-SYNOPSIS
- void aout_@var{size}_swap_exec_header_out
- (bfd *abfd,
- struct internal_exec *execp,
- struct external_exec *raw_bytes);
-
-DESCRIPTION
- Swap the information in an internal exec header structure
- @var{execp} into the buffer @var{raw_bytes} ready for writing to disk.
-*/
-void
-NAME(aout,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);
-}
-
-/* Make all the section for an a.out file. */
-
-boolean
-NAME(aout,make_sections) (abfd)
- bfd *abfd;
-{
- if (obj_textsec (abfd) == (asection *) NULL
- && bfd_make_section (abfd, ".text") == (asection *) NULL)
- return false;
- if (obj_datasec (abfd) == (asection *) NULL
- && bfd_make_section (abfd, ".data") == (asection *) NULL)
- return false;
- if (obj_bsssec (abfd) == (asection *) NULL
- && bfd_make_section (abfd, ".bss") == (asection *) NULL)
- return false;
- return true;
-}
-
-/*
-FUNCTION
- aout_@var{size}_some_aout_object_p
-
-SYNOPSIS
- const bfd_target *aout_@var{size}_some_aout_object_p
- (bfd *abfd,
- const bfd_target *(*callback_to_real_object_p)());
-
-DESCRIPTION
- Some a.out variant thinks that the file open in @var{abfd}
- checking is an a.out file. Do some more checking, and set up
- for access if it really is. Call back to the calling
- environment's "finish up" function just before returning, to
- handle any last-minute setup.
-*/
-
-const bfd_target *
-NAME(aout,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 (N_MAGIC (*execp) == ZMAGIC)
- {
- abfd->flags |= D_PAGED | WP_TEXT;
- adata (abfd).magic = z_magic;
- }
- else if (N_MAGIC (*execp) == QMAGIC)
- {
- abfd->flags |= D_PAGED | WP_TEXT;
- adata (abfd).magic = z_magic;
- adata (abfd).subformat = q_magic_format;
- }
- else if (N_MAGIC (*execp) == NMAGIC)
- {
- abfd->flags |= WP_TEXT;
- adata (abfd).magic = n_magic;
- }
- else if (N_MAGIC (*execp) == OMAGIC
- || N_MAGIC (*execp) == BMAGIC)
- 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;
-
-#ifdef USE_MMAP
- bfd_init_window (&obj_aout_sym_window (abfd));
- bfd_init_window (&obj_aout_string_window (abfd));
-#endif
- 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;
-
-#ifdef THIS_IS_ONLY_DOCUMENTATION
- /* The common code can't fill in these things because they depend
- on either the start address of the text segment, the rounding
- up of virtual addresses between segments, or the starting file
- position of the text segment -- all of which varies among different
- versions of a.out. */
-
- /* Call back to the format-dependent code to fill in the rest of the
- fields and do any further cleanup. Things that should be filled
- in by the callback: */
-
- struct exec *execp = exec_hdr (abfd);
-
- obj_textsec (abfd)->size = N_TXTSIZE(*execp);
- obj_textsec (abfd)->raw_size = N_TXTSIZE(*execp);
- /* data and bss are already filled in since they're so standard */
-
- /* 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);
-
- /* The file offsets of the sections */
- obj_textsec (abfd)->filepos = N_TXTOFF(*execp);
- obj_datasec (abfd)->filepos = N_DATOFF(*execp);
-
- /* The file offsets of the relocation info */
- obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
- obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
-
- /* The file offsets of the string table and symbol table. */
- obj_str_filepos (abfd) = N_STROFF (*execp);
- obj_sym_filepos (abfd) = N_SYMOFF (*execp);
-
- /* Determine the architecture and machine type of the object file. */
- switch (N_MACHTYPE (*exec_hdr (abfd))) {
- default:
- abfd->obj_arch = bfd_arch_obscure;
- break;
- }
-
- adata(abfd)->page_size = TARGET_PAGE_SIZE;
- adata(abfd)->segment_size = SEGMENT_SIZE;
- adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;
-
- return abfd->xvec;
-
- /* The architecture is encoded in various ways in various a.out variants,
- or is not encoded at all in some of them. The relocation size depends
- on the architecture and the a.out variant. Finally, the return value
- is the bfd_target vector in use. If an error occurs, return zero and
- set bfd_error to the appropriate error code.
-
- Formats such as b.out, which have additional fields in the a.out
- header, should cope with them in this callback as well. */
-#endif /* DOCUMENTATION */
-
- result = (*callback_to_real_object_p)(abfd);
-
- /* 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.). */
- if ((execp->a_entry >= obj_textsec(abfd)->vma) &&
- (execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))
- abfd->flags |= EXEC_P;
-#ifdef STAT_FOR_EXEC
- else
- {
- struct stat stat_buf;
-
- /* 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. */
- 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;
- }
-#endif /* STAT_FOR_EXEC */
-
- if (result)
- {
-#if 0 /* These should be set correctly anyways. */
- abfd->sections = obj_textsec (abfd);
- obj_textsec (abfd)->next = obj_datasec (abfd);
- obj_datasec (abfd)->next = obj_bsssec (abfd);
-#endif
- }
- else
- {
- free (rawptr);
- abfd->tdata.aout_data = oldrawptr;
- }
- return result;
-}
-
-/*
-FUNCTION
- aout_@var{size}_mkobject
-
-SYNOPSIS
- boolean aout_@var{size}_mkobject, (bfd *abfd);
-
-DESCRIPTION
- Initialize BFD @var{abfd} for use with a.out files.
-*/
-
-boolean
-NAME(aout,mkobject) (abfd)
- bfd *abfd;
-{
- struct aout_data_struct *rawptr;
-
- bfd_set_error (bfd_error_system_call);
-
- /* Use an intermediate variable for clarity */
- rawptr = (struct aout_data_struct *)bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
-
- if (rawptr == NULL)
- return false;
-
- abfd->tdata.aout_data = rawptr;
- exec_hdr (abfd) = &(rawptr->e);
-
- obj_textsec (abfd) = (asection *)NULL;
- obj_datasec (abfd) = (asection *)NULL;
- obj_bsssec (abfd) = (asection *)NULL;
-
- return true;
-}
-
-
-/*
-FUNCTION
- aout_@var{size}_machine_type
-
-SYNOPSIS
- enum machine_type aout_@var{size}_machine_type
- (enum bfd_architecture arch,
- unsigned long machine));
-
-DESCRIPTION
- Keep track of machine architecture and machine type for
- a.out's. Return the <<machine_type>> for a particular
- architecture and machine, or <<M_UNKNOWN>> if that exact architecture
- and machine can't be represented in a.out format.
-
- If the architecture is understood, machine type 0 (default)
- is always understood.
-*/
-
-enum machine_type
-NAME(aout,machine_type) (arch, machine, unknown)
- enum bfd_architecture arch;
- unsigned long machine;
- boolean *unknown;
-{
- enum machine_type arch_flags;
-
- arch_flags = M_UNKNOWN;
- *unknown = true;
-
- switch (arch) {
- case bfd_arch_sparc:
- if (machine == 0
- || machine == bfd_mach_sparc
- || machine == bfd_mach_sparc_v9)
- arch_flags = M_SPARC;
- break;
-
- case bfd_arch_m68k:
- switch (machine) {
- case 0: arch_flags = M_68010; break;
- case 68000: arch_flags = M_UNKNOWN; *unknown = false; break;
- case 68010: arch_flags = M_68010; break;
- case 68020: arch_flags = M_68020; break;
- default: arch_flags = M_UNKNOWN; break;
- }
- break;
-
- case bfd_arch_i386:
- if (machine == 0) arch_flags = M_386;
- break;
-
- case bfd_arch_a29k:
- if (machine == 0) arch_flags = M_29K;
- break;
-
- case bfd_arch_arm:
- if (machine == 0) arch_flags = M_ARM;
- break;
-
- case bfd_arch_mips:
- switch (machine) {
- case 0:
- case 2000:
- case 3000: arch_flags = M_MIPS1; break;
- case 4000: /* mips3 */
- case 4400:
- case 8000: /* mips4 */
- /* real mips2: */
- case 6000: arch_flags = M_MIPS2; break;
- default: arch_flags = M_UNKNOWN; break;
- }
- break;
-
- case bfd_arch_ns32k:
- switch (machine) {
- case 0: arch_flags = M_NS32532; break;
- case 32032: arch_flags = M_NS32032; break;
- case 32532: arch_flags = M_NS32532; break;
- default: arch_flags = M_UNKNOWN; break;
- }
- break;
-
- case bfd_arch_vax:
- *unknown = false;
- break;
-
-
- default:
- arch_flags = M_UNKNOWN;
- }
-
- if (arch_flags != M_UNKNOWN)
- *unknown = false;
-
- return arch_flags;
-}
-
-
-/*
-FUNCTION
- aout_@var{size}_set_arch_mach
-
-SYNOPSIS
- boolean aout_@var{size}_set_arch_mach,
- (bfd *,
- enum bfd_architecture arch,
- unsigned long machine));
-
-DESCRIPTION
- Set the architecture and the machine of the BFD @var{abfd} to the
- values @var{arch} and @var{machine}. Verify that @var{abfd}'s format
- can support the architecture required.
-*/
-
-boolean
-NAME(aout,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)
- {
- boolean unknown;
-
- NAME(aout,machine_type) (arch, machine, &unknown);
- if (unknown)
- return false;
- }
-
- /* Determine the size of a relocation entry */
- switch (arch) {
- 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;
- }
-
- return (*aout_backend_info(abfd)->set_sizes) (abfd);
-}
-
-static void
-adjust_o_magic (abfd, execp)
- bfd *abfd;
- struct internal_exec *execp;
-{
- file_ptr pos = adata (abfd).exec_bytes_size;
- bfd_vma vma = 0;
- int pad = 0;
-
- /* Text. */
- obj_textsec(abfd)->filepos = pos;
- if (!obj_textsec(abfd)->user_set_vma)
- obj_textsec(abfd)->vma = vma;
- else
- vma = obj_textsec(abfd)->vma;
-
- pos += obj_textsec(abfd)->_raw_size;
- vma += obj_textsec(abfd)->_raw_size;
-
- /* Data. */
- if (!obj_datasec(abfd)->user_set_vma)
- {
-#if 0 /* ?? Does alignment in the file image really matter? */
- pad = align_power (vma, obj_datasec(abfd)->alignment_power) - vma;
-#endif
- obj_textsec(abfd)->_raw_size += pad;
- pos += pad;
- vma += pad;
- obj_datasec(abfd)->vma = vma;
- }
- else
- vma = obj_datasec(abfd)->vma;
- obj_datasec(abfd)->filepos = pos;
- pos += obj_datasec(abfd)->_raw_size;
- vma += obj_datasec(abfd)->_raw_size;
-
- /* BSS. */
- if (!obj_bsssec(abfd)->user_set_vma)
- {
-#if 0
- pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma;
-#endif
- obj_datasec(abfd)->_raw_size += pad;
- pos += pad;
- vma += pad;
- obj_bsssec(abfd)->vma = vma;
- }
- else
- {
- /* The VMA of the .bss section is set by the the VMA of the
- .data section plus the size of the .data section. We may
- need to add padding bytes to make this true. */
- pad = obj_bsssec (abfd)->vma - vma;
- if (pad > 0)
- {
- obj_datasec (abfd)->_raw_size += pad;
- pos += pad;
- }
- }
- obj_bsssec(abfd)->filepos = pos;
-
- /* Fix up the exec header. */
- execp->a_text = obj_textsec(abfd)->_raw_size;
- execp->a_data = obj_datasec(abfd)->_raw_size;
- execp->a_bss = obj_bsssec(abfd)->_raw_size;
- N_SET_MAGIC (*execp, OMAGIC);
-}
-
-static void
-adjust_z_magic (abfd, execp)
- bfd *abfd;
- struct internal_exec *execp;
-{
- bfd_size_type data_pad, text_pad;
- file_ptr text_end;
- CONST struct aout_backend_data *abdp;
- int ztih; /* Nonzero if text includes exec header. */
-
- abdp = aout_backend_info (abfd);
-
- /* Text. */
- ztih = (abdp != NULL
- && (abdp->text_includes_header
- || obj_aout_subformat (abfd) == q_magic_format));
- obj_textsec(abfd)->filepos = (ztih
- ? adata(abfd).exec_bytes_size
- : adata(abfd).zmagic_disk_block_size);
- if (! obj_textsec(abfd)->user_set_vma)
- {
- /* ?? Do we really need to check for relocs here? */
- obj_textsec(abfd)->vma = ((abfd->flags & HAS_RELOC)
- ? 0
- : (ztih
- ? (abdp->default_text_vma
- + adata(abfd).exec_bytes_size)
- : abdp->default_text_vma));
- text_pad = 0;
- }
- else
- {
- /* The .text section is being loaded at an unusual address. We
- may need to pad it such that the .data section starts at a page
- boundary. */
- if (ztih)
- text_pad = ((obj_textsec (abfd)->filepos - obj_textsec (abfd)->vma)
- & (adata (abfd).page_size - 1));
- else
- text_pad = ((- obj_textsec (abfd)->vma)
- & (adata (abfd).page_size - 1));
- }
-
- /* Find start of data. */
- if (ztih)
- {
- text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->_raw_size;
- text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
- }
- else
- {
- /* Note that if page_size == zmagic_disk_block_size, then
- filepos == page_size, and this case is the same as the ztih
- case. */
- text_end = obj_textsec (abfd)->_raw_size;
- text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
- text_end += obj_textsec (abfd)->filepos;
- }
- obj_textsec(abfd)->_raw_size += text_pad;
- text_end += text_pad;
-
- /* Data. */
- if (!obj_datasec(abfd)->user_set_vma)
- {
- bfd_vma vma;
- vma = obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size;
- obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size);
- }
- if (abdp && abdp->zmagic_mapped_contiguous)
- {
- text_pad = (obj_datasec(abfd)->vma
- - obj_textsec(abfd)->vma
- - obj_textsec(abfd)->_raw_size);
- obj_textsec(abfd)->_raw_size += text_pad;
- }
- obj_datasec(abfd)->filepos = (obj_textsec(abfd)->filepos
- + obj_textsec(abfd)->_raw_size);
-
- /* Fix up exec header while we're at it. */
- execp->a_text = obj_textsec(abfd)->_raw_size;
- if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted)))
- execp->a_text += adata(abfd).exec_bytes_size;
- if (obj_aout_subformat (abfd) == q_magic_format)
- N_SET_MAGIC (*execp, QMAGIC);
- else
- N_SET_MAGIC (*execp, ZMAGIC);
-
- /* Spec says data section should be rounded up to page boundary. */
- obj_datasec(abfd)->_raw_size
- = align_power (obj_datasec(abfd)->_raw_size,
- obj_bsssec(abfd)->alignment_power);
- execp->a_data = BFD_ALIGN (obj_datasec(abfd)->_raw_size,
- adata(abfd).page_size);
- data_pad = execp->a_data - obj_datasec(abfd)->_raw_size;
-
- /* BSS. */
- if (!obj_bsssec(abfd)->user_set_vma)
- obj_bsssec(abfd)->vma = (obj_datasec(abfd)->vma
- + obj_datasec(abfd)->_raw_size);
- /* If the BSS immediately follows the data section and extra space
- in the page is left after the data section, fudge data
- in the header so that the bss section looks smaller by that
- amount. We'll start the bss section there, and lie to the OS.
- (Note that a linker script, as well as the above assignment,
- could have explicitly set the BSS vma to immediately follow
- the data section.) */
- if (align_power (obj_bsssec(abfd)->vma, obj_bsssec(abfd)->alignment_power)
- == obj_datasec(abfd)->vma + obj_datasec(abfd)->_raw_size)
- execp->a_bss = (data_pad > obj_bsssec(abfd)->_raw_size) ? 0 :
- obj_bsssec(abfd)->_raw_size - data_pad;
- else
- execp->a_bss = obj_bsssec(abfd)->_raw_size;
-}
-
-static void
-adjust_n_magic (abfd, execp)
- bfd *abfd;
- struct internal_exec *execp;
-{
- file_ptr pos = adata(abfd).exec_bytes_size;
- bfd_vma vma = 0;
- int pad;
-
- /* Text. */
- obj_textsec(abfd)->filepos = pos;
- if (!obj_textsec(abfd)->user_set_vma)
- obj_textsec(abfd)->vma = vma;
- else
- vma = obj_textsec(abfd)->vma;
- pos += obj_textsec(abfd)->_raw_size;
- vma += obj_textsec(abfd)->_raw_size;
-
- /* Data. */
- obj_datasec(abfd)->filepos = pos;
- if (!obj_datasec(abfd)->user_set_vma)
- obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size);
- vma = obj_datasec(abfd)->vma;
-
- /* Since BSS follows data immediately, see if it needs alignment. */
- vma += obj_datasec(abfd)->_raw_size;
- pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma;
- obj_datasec(abfd)->_raw_size += pad;
- pos += obj_datasec(abfd)->_raw_size;
-
- /* BSS. */
- if (!obj_bsssec(abfd)->user_set_vma)
- obj_bsssec(abfd)->vma = vma;
- else
- vma = obj_bsssec(abfd)->vma;
-
- /* Fix up exec header. */
- execp->a_text = obj_textsec(abfd)->_raw_size;
- execp->a_data = obj_datasec(abfd)->_raw_size;
- execp->a_bss = obj_bsssec(abfd)->_raw_size;
- N_SET_MAGIC (*execp, NMAGIC);
-}
-
-boolean
-NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
- bfd *abfd;
- bfd_size_type *text_size;
- file_ptr *text_end;
-{
- struct internal_exec *execp = exec_hdr (abfd);
-
- if (! NAME(aout,make_sections) (abfd))
- return false;
-
- if (adata(abfd).magic != undecided_magic)
- return true;
-
- obj_textsec(abfd)->_raw_size =
- align_power(obj_textsec(abfd)->_raw_size,
- obj_textsec(abfd)->alignment_power);
-
- *text_size = obj_textsec (abfd)->_raw_size;
- /* Rule (heuristic) for when to pad to a new page. Note that there
- are (at least) two ways demand-paged (ZMAGIC) files have been
- handled. Most Berkeley-based systems start the text segment at
- (TARGET_PAGE_SIZE). However, newer versions of SUNOS start the text
- segment right after the exec header; the latter is counted in the
- text segment size, and is paged in by the kernel with the rest of
- the text. */
-
- /* This perhaps isn't the right way to do this, but made it simpler for me
- to understand enough to implement it. Better would probably be to go
- right from BFD flags to alignment/positioning characteristics. But the
- old code was sloppy enough about handling the flags, and had enough
- other magic, that it was a little hard for me to understand. I think
- I understand it better now, but I haven't time to do the cleanup this
- minute. */
-
- if (abfd->flags & D_PAGED)
- /* Whether or not WP_TEXT is set -- let D_PAGED override. */
- adata(abfd).magic = z_magic;
- else if (abfd->flags & WP_TEXT)
- adata(abfd).magic = n_magic;
- else
- adata(abfd).magic = o_magic;
-
-#ifdef BFD_AOUT_DEBUG /* requires gcc2 */
-#if __GNUC__ >= 2
- fprintf (stderr, "%s text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x,%x>\n",
- ({ char *str;
- switch (adata(abfd).magic) {
- case n_magic: str = "NMAGIC"; break;
- case o_magic: str = "OMAGIC"; break;
- case z_magic: str = "ZMAGIC"; break;
- default: abort ();
- }
- str;
- }),
- obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
- obj_textsec(abfd)->alignment_power,
- obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
- obj_datasec(abfd)->alignment_power,
- obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size,
- obj_bsssec(abfd)->alignment_power);
-#endif
-#endif
-
- switch (adata(abfd).magic)
- {
- case o_magic:
- adjust_o_magic (abfd, execp);
- break;
- case z_magic:
- adjust_z_magic (abfd, execp);
- break;
- case n_magic:
- adjust_n_magic (abfd, execp);
- break;
- default:
- abort ();
- }
-
-#ifdef BFD_AOUT_DEBUG
- fprintf (stderr, " text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x>\n",
- obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
- obj_textsec(abfd)->filepos,
- obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
- obj_datasec(abfd)->filepos,
- obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size);
-#endif
-
- return true;
-}
-
-/*
-FUNCTION
- aout_@var{size}_new_section_hook
-
-SYNOPSIS
- boolean aout_@var{size}_new_section_hook,
- (bfd *abfd,
- asection *newsect));
-
-DESCRIPTION
- Called by the BFD in response to a @code{bfd_make_section}
- request.
-*/
-boolean
-NAME(aout,new_section_hook) (abfd, newsect)
- bfd *abfd;
- asection *newsect;
-{
- /* align to double at least */
- newsect->alignment_power = bfd_get_arch_info(abfd)->section_align_power;
-
-
- if (bfd_get_format (abfd) == bfd_object)
- {
- if (obj_textsec(abfd) == NULL && !strcmp(newsect->name, ".text")) {
- obj_textsec(abfd)= newsect;
- newsect->target_index = N_TEXT;
- return true;
- }
-
- if (obj_datasec(abfd) == NULL && !strcmp(newsect->name, ".data")) {
- obj_datasec(abfd) = newsect;
- newsect->target_index = N_DATA;
- return true;
- }
-
- if (obj_bsssec(abfd) == NULL && !strcmp(newsect->name, ".bss")) {
- obj_bsssec(abfd) = newsect;
- newsect->target_index = N_BSS;
- return true;
- }
-
- }
-
- /* We allow more than three sections internally */
- return true;
-}
-
-boolean
-NAME(aout,set_section_contents) (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- file_ptr text_end;
- bfd_size_type text_size;
-
- if (! abfd->output_has_begun)
- {
- if (! NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end))
- return false;
- }
-
- if (section == obj_bsssec (abfd))
- {
- bfd_set_error (bfd_error_no_contents);
- return false;
- }
-
- if (section != obj_textsec (abfd)
- && section != obj_datasec (abfd))
- {
- (*_bfd_error_handler)
- ("%s: can not represent section `%s' in a.out object file format",
- bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
-
- if (count != 0)
- {
- if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
- return false;
- }
-
- return true;
-}
-
-/* Read the external symbols from an a.out file. */
-
-static boolean
-aout_get_external_symbols (abfd)
- bfd *abfd;
-{
- if (obj_aout_external_syms (abfd) == (struct external_nlist *) NULL)
- {
- bfd_size_type count;
- struct external_nlist *syms;
-
- count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE;
-
-#ifdef USE_MMAP
- if (bfd_get_file_window (abfd,
- obj_sym_filepos (abfd), exec_hdr (abfd)->a_syms,
- &obj_aout_sym_window (abfd), true) == false)
- return false;
- syms = (struct external_nlist *) obj_aout_sym_window (abfd).data;
-#else
- /* We allocate using malloc to make the values easy to free
- later on. If we put them on the obstack it might not be
- possible to free them. */
- syms = ((struct external_nlist *)
- bfd_malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
- if (syms == (struct external_nlist *) NULL && count != 0)
- return false;
-
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || (bfd_read (syms, 1, exec_hdr (abfd)->a_syms, abfd)
- != exec_hdr (abfd)->a_syms))
- {
- free (syms);
- return false;
- }
-#endif
-
- obj_aout_external_syms (abfd) = syms;
- obj_aout_external_sym_count (abfd) = count;
- }
-
- if (obj_aout_external_strings (abfd) == NULL
- && exec_hdr (abfd)->a_syms != 0)
- {
- unsigned char string_chars[BYTES_IN_WORD];
- bfd_size_type stringsize;
- char *strings;
-
- /* Get the size of the strings. */
- if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0
- || (bfd_read ((PTR) string_chars, BYTES_IN_WORD, 1, abfd)
- != BYTES_IN_WORD))
- return false;
- stringsize = GET_WORD (abfd, string_chars);
-
-#ifdef USE_MMAP
- if (bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize,
- &obj_aout_string_window (abfd), true) == false)
- return false;
- strings = (char *) obj_aout_string_window (abfd).data;
-#else
- strings = (char *) bfd_malloc ((size_t) stringsize + 1);
- if (strings == NULL)
- return false;
-
- /* Skip space for the string count in the buffer for convenience
- when using indexes. */
- if (bfd_read (strings + BYTES_IN_WORD, 1, stringsize - BYTES_IN_WORD,
- abfd)
- != stringsize - BYTES_IN_WORD)
- {
- free (strings);
- return false;
- }
-#endif
-
- /* Ensure that a zero index yields an empty string. */
- strings[0] = '\0';
-
- strings[stringsize - 1] = 0;
-
- obj_aout_external_strings (abfd) = strings;
- obj_aout_external_string_size (abfd) = stringsize;
- }
-
- return true;
-}
-
-/* Translate an a.out symbol into a BFD symbol. The desc, other, type
- and symbol->value fields of CACHE_PTR will be set from the a.out
- nlist structure. This function is responsible for setting
- symbol->flags and symbol->section, and adjusting symbol->value. */
-
-static boolean
-translate_from_native_sym_flags (abfd, cache_ptr)
- bfd *abfd;
- aout_symbol_type *cache_ptr;
-{
- flagword visible;
-
- if ((cache_ptr->type & N_STAB) != 0
- || cache_ptr->type == N_FN)
- {
- asection *sec;
-
- /* This is a debugging symbol. */
-
- cache_ptr->symbol.flags = BSF_DEBUGGING;
-
- /* Work out the symbol section. */
- switch (cache_ptr->type & N_TYPE)
- {
- case N_TEXT:
- case N_FN:
- sec = obj_textsec (abfd);
- break;
- case N_DATA:
- sec = obj_datasec (abfd);
- break;
- case N_BSS:
- sec = obj_bsssec (abfd);
- break;
- default:
- case N_ABS:
- sec = bfd_abs_section_ptr;
- break;
- }
-
- cache_ptr->symbol.section = sec;
- cache_ptr->symbol.value -= sec->vma;
-
- return true;
- }
-
- /* Get the default visibility. This does not apply to all types, so
- we just hold it in a local variable to use if wanted. */
- if ((cache_ptr->type & N_EXT) == 0)
- visible = BSF_LOCAL;
- else
- visible = BSF_GLOBAL;
-
- switch (cache_ptr->type)
- {
- default:
- case N_ABS: case N_ABS | N_EXT:
- cache_ptr->symbol.section = bfd_abs_section_ptr;
- cache_ptr->symbol.flags = visible;
- break;
-
- case N_UNDF | N_EXT:
- if (cache_ptr->symbol.value != 0)
- {
- /* This is a common symbol. */
- cache_ptr->symbol.flags = BSF_GLOBAL;
- cache_ptr->symbol.section = bfd_com_section_ptr;
- }
- else
- {
- cache_ptr->symbol.flags = 0;
- cache_ptr->symbol.section = bfd_und_section_ptr;
- }
- break;
-
- case N_TEXT: case N_TEXT | N_EXT:
- cache_ptr->symbol.section = obj_textsec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = visible;
- break;
-
- /* N_SETV symbols used to represent set vectors placed in the
- data section. They are no longer generated. Theoretically,
- it was possible to extract the entries and combine them with
- new ones, although I don't know if that was ever actually
- done. Unless that feature is restored, treat them as data
- symbols. */
- case N_SETV: case N_SETV | N_EXT:
- case N_DATA: case N_DATA | N_EXT:
- cache_ptr->symbol.section = obj_datasec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = visible;
- break;
-
- case N_BSS: case N_BSS | N_EXT:
- cache_ptr->symbol.section = obj_bsssec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = visible;
- break;
-
- case N_SETA: case N_SETA | N_EXT:
- case N_SETT: case N_SETT | N_EXT:
- case N_SETD: case N_SETD | N_EXT:
- case N_SETB: case N_SETB | N_EXT:
- {
- asection *section;
- arelent_chain *reloc;
- asection *into_section;
-
- /* This is a set symbol. The name of the symbol is the name
- of the set (e.g., __CTOR_LIST__). The value of the symbol
- is the value to add to the set. We create a section with
- the same name as the symbol, and add a reloc to insert the
- appropriate value into the section.
-
- This action is actually obsolete; it used to make the
- linker do the right thing, but the linker no longer uses
- this function. */
-
- section = bfd_get_section_by_name (abfd, cache_ptr->symbol.name);
- if (section == NULL)
- {
- char *copy;
-
- copy = bfd_alloc (abfd, strlen (cache_ptr->symbol.name) + 1);
- if (copy == NULL)
- return false;
-
- strcpy (copy, cache_ptr->symbol.name);
- section = bfd_make_section (abfd, copy);
- if (section == NULL)
- return false;
- }
-
- reloc = (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
- if (reloc == NULL)
- return false;
-
- /* Build a relocation entry for the constructor. */
- switch (cache_ptr->type & N_TYPE)
- {
- case N_SETA:
- into_section = bfd_abs_section_ptr;
- cache_ptr->type = N_ABS;
- break;
- case N_SETT:
- into_section = obj_textsec (abfd);
- cache_ptr->type = N_TEXT;
- break;
- case N_SETD:
- into_section = obj_datasec (abfd);
- cache_ptr->type = N_DATA;
- break;
- case N_SETB:
- into_section = obj_bsssec (abfd);
- cache_ptr->type = N_BSS;
- break;
- }
-
- /* Build a relocation pointing into the constructor section
- pointing at the symbol in the set vector specified. */
- reloc->relent.addend = cache_ptr->symbol.value;
- cache_ptr->symbol.section = into_section;
- reloc->relent.sym_ptr_ptr = into_section->symbol_ptr_ptr;
-
- /* We modify the symbol to belong to a section depending upon
- the name of the symbol, and add to the size of the section
- to contain a pointer to the symbol. Build a reloc entry to
- relocate to this symbol attached to this section. */
- section->flags = SEC_CONSTRUCTOR | SEC_RELOC;
-
- section->reloc_count++;
- section->alignment_power = 2;
-
- reloc->next = section->constructor_chain;
- section->constructor_chain = reloc;
- reloc->relent.address = section->_raw_size;
- section->_raw_size += BYTES_IN_WORD;
-
- reloc->relent.howto = CTOR_TABLE_RELOC_HOWTO(abfd);
-
- cache_ptr->symbol.flags |= BSF_CONSTRUCTOR;
- }
- break;
-
- case N_WARNING:
- /* This symbol is the text of a warning message. The next
- symbol is the symbol to associate the warning with. If a
- reference is made to that symbol, a warning is issued. */
- cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_WARNING;
- cache_ptr->symbol.section = bfd_abs_section_ptr;
- break;
-
- case N_INDR: case N_INDR | N_EXT:
- /* An indirect symbol. This consists of two symbols in a row.
- The first symbol is the name of the indirection. The second
- symbol is the name of the target. A reference to the first
- symbol becomes a reference to the second. */
- cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_INDIRECT | visible;
- cache_ptr->symbol.section = bfd_ind_section_ptr;
- break;
-
- case N_WEAKU:
- cache_ptr->symbol.section = bfd_und_section_ptr;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
-
- case N_WEAKA:
- cache_ptr->symbol.section = bfd_abs_section_ptr;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
-
- case N_WEAKT:
- cache_ptr->symbol.section = obj_textsec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
-
- case N_WEAKD:
- cache_ptr->symbol.section = obj_datasec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
-
- case N_WEAKB:
- cache_ptr->symbol.section = obj_bsssec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
- }
-
- return true;
-}
-
-/* Set the fields of SYM_POINTER according to CACHE_PTR. */
-
-static boolean
-translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
- bfd *abfd;
- asymbol *cache_ptr;
- struct external_nlist *sym_pointer;
-{
- bfd_vma value = cache_ptr->value;
- asection *sec;
- bfd_vma off;
-
- /* Mask out any existing type bits in case copying from one section
- to another. */
- sym_pointer->e_type[0] &= ~N_TYPE;
-
- sec = bfd_get_section (cache_ptr);
- off = 0;
-
- if (sec == NULL)
- {
- /* This case occurs, e.g., for the *DEBUG* section of a COFF
- file. */
- (*_bfd_error_handler)
- ("%s: can not represent section `%s' in a.out object file format",
- bfd_get_filename (abfd), bfd_get_section_name (abfd, sec));
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
-
- if (sec->output_section != NULL)
- {
- off = sec->output_offset;
- sec = sec->output_section;
- }
-
- if (bfd_is_abs_section (sec))
- sym_pointer->e_type[0] |= N_ABS;
- else if (sec == obj_textsec (abfd))
- sym_pointer->e_type[0] |= N_TEXT;
- else if (sec == obj_datasec (abfd))
- sym_pointer->e_type[0] |= N_DATA;
- else if (sec == obj_bsssec (abfd))
- sym_pointer->e_type[0] |= N_BSS;
- else if (bfd_is_und_section (sec))
- sym_pointer->e_type[0] = N_UNDF | N_EXT;
- else if (bfd_is_ind_section (sec))
- sym_pointer->e_type[0] = N_INDR;
- else if (bfd_is_com_section (sec))
- sym_pointer->e_type[0] = N_UNDF | N_EXT;
- else
- {
- (*_bfd_error_handler)
- ("%s: can not represent section `%s' in a.out object file format",
- bfd_get_filename (abfd), bfd_get_section_name (abfd, sec));
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
-
- /* Turn the symbol from section relative to absolute again */
- value += sec->vma + off;
-
- if ((cache_ptr->flags & BSF_WARNING) != 0)
- sym_pointer->e_type[0] = N_WARNING;
-
- if ((cache_ptr->flags & BSF_DEBUGGING) != 0)
- sym_pointer->e_type[0] = ((aout_symbol_type *) cache_ptr)->type;
- else if ((cache_ptr->flags & BSF_GLOBAL) != 0)
- sym_pointer->e_type[0] |= N_EXT;
-
- if ((cache_ptr->flags & BSF_CONSTRUCTOR) != 0)
- {
- int type = ((aout_symbol_type *) cache_ptr)->type;
- switch (type)
- {
- case N_ABS: type = N_SETA; break;
- case N_TEXT: type = N_SETT; break;
- case N_DATA: type = N_SETD; break;
- case N_BSS: type = N_SETB; break;
- }
- sym_pointer->e_type[0] = type;
- }
-
- if ((cache_ptr->flags & BSF_WEAK) != 0)
- {
- int type;
-
- switch (sym_pointer->e_type[0] & N_TYPE)
- {
- default:
- case N_ABS: type = N_WEAKA; break;
- case N_TEXT: type = N_WEAKT; break;
- case N_DATA: type = N_WEAKD; break;
- case N_BSS: type = N_WEAKB; break;
- case N_UNDF: type = N_WEAKU; break;
- }
- sym_pointer->e_type[0] = type;
- }
-
- PUT_WORD(abfd, value, sym_pointer->e_value);
-
- return true;
-}
-
-/* Native-level interface to symbols. */
-
-asymbol *
-NAME(aout,make_empty_symbol) (abfd)
- bfd *abfd;
-{
- aout_symbol_type *new =
- (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
- if (!new)
- return NULL;
- new->symbol.the_bfd = abfd;
-
- return &new->symbol;
-}
-
-/* Translate a set of internal symbols into external symbols. */
-
-boolean
-NAME(aout,translate_symbol_table) (abfd, in, ext, count, str, strsize, dynamic)
- bfd *abfd;
- aout_symbol_type *in;
- struct external_nlist *ext;
- bfd_size_type count;
- char *str;
- bfd_size_type strsize;
- boolean dynamic;
-{
- struct external_nlist *ext_end;
-
- ext_end = ext + count;
- for (; ext < ext_end; ext++, in++)
- {
- bfd_vma x;
-
- x = GET_WORD (abfd, ext->e_strx);
- in->symbol.the_bfd = abfd;
-
- /* For the normal symbols, the zero index points at the number
- of bytes in the string table but is to be interpreted as the
- null string. For the dynamic symbols, the number of bytes in
- the string table is stored in the __DYNAMIC structure and the
- zero index points at an actual string. */
- if (x == 0 && ! dynamic)
- in->symbol.name = "";
- else if (x < strsize)
- in->symbol.name = str + x;
- else
- return false;
-
- in->symbol.value = GET_SWORD (abfd, ext->e_value);
- in->desc = bfd_h_get_16 (abfd, ext->e_desc);
- in->other = bfd_h_get_8 (abfd, ext->e_other);
- in->type = bfd_h_get_8 (abfd, ext->e_type);
- in->symbol.udata.p = NULL;
-
- if (! translate_from_native_sym_flags (abfd, in))
- return false;
-
- if (dynamic)
- in->symbol.flags |= BSF_DYNAMIC;
- }
-
- return true;
-}
-
-/* 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. */
-
-boolean
-NAME(aout,slurp_symbol_table) (abfd)
- bfd *abfd;
-{
- struct external_nlist *old_external_syms;
- aout_symbol_type *cached;
- size_t cached_size;
-
- /* If there's no work to be done, don't do any */
- if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
- return true;
-
- old_external_syms = obj_aout_external_syms (abfd);
-
- if (! aout_get_external_symbols (abfd))
- return false;
-
- cached_size = (obj_aout_external_sym_count (abfd)
- * sizeof (aout_symbol_type));
- cached = (aout_symbol_type *) bfd_malloc (cached_size);
- if (cached == NULL && cached_size != 0)
- return false;
- if (cached_size != 0)
- memset (cached, 0, cached_size);
-
- /* Convert from external symbol information to internal. */
- if (! (NAME(aout,translate_symbol_table)
- (abfd, cached,
- obj_aout_external_syms (abfd),
- obj_aout_external_sym_count (abfd),
- obj_aout_external_strings (abfd),
- obj_aout_external_string_size (abfd),
- false)))
- {
- free (cached);
- return false;
- }
-
- bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd);
-
- obj_aout_symbols (abfd) = cached;
-
- /* It is very likely that anybody who calls this function will not
- want the external symbol information, so if it was allocated
- because of our call to aout_get_external_symbols, we free it up
- right away to save space. */
- if (old_external_syms == (struct external_nlist *) NULL
- && obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
- {
-#ifdef USE_MMAP
- bfd_free_window (&obj_aout_sym_window (abfd));
-#else
- free (obj_aout_external_syms (abfd));
-#endif
- obj_aout_external_syms (abfd) = NULL;
- }
-
- return true;
-}
-
-/* We use a hash table when writing out symbols so that we only write
- out a particular string once. This helps particularly when the
- linker writes out stabs debugging entries, because each different
- contributing object file tends to have many duplicate stabs
- strings.
-
- This hash table code breaks dbx on SunOS 4.1.3, so we don't do it
- if BFD_TRADITIONAL_FORMAT is set. */
-
-static bfd_size_type add_to_stringtab
- PARAMS ((bfd *, struct bfd_strtab_hash *, const char *, boolean));
-static boolean emit_stringtab PARAMS ((bfd *, struct bfd_strtab_hash *));
-
-/* Get the index of a string in a strtab, adding it if it is not
- already present. */
-
-static INLINE bfd_size_type
-add_to_stringtab (abfd, tab, str, copy)
- bfd *abfd;
- struct bfd_strtab_hash *tab;
- const char *str;
- boolean copy;
-{
- boolean hash;
- bfd_size_type index;
-
- /* An index of 0 always means the empty string. */
- if (str == 0 || *str == '\0')
- return 0;
-
- /* Don't hash if BFD_TRADITIONAL_FORMAT is set, because SunOS dbx
- doesn't understand a hashed string table. */
- hash = true;
- if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
- hash = false;
-
- index = _bfd_stringtab_add (tab, str, hash, copy);
-
- if (index != (bfd_size_type) -1)
- {
- /* Add BYTES_IN_WORD to the return value to account for the
- space taken up by the string table size. */
- index += BYTES_IN_WORD;
- }
-
- return index;
-}
-
-/* Write out a strtab. ABFD is already at the right location in the
- file. */
-
-static boolean
-emit_stringtab (abfd, tab)
- register bfd *abfd;
- struct bfd_strtab_hash *tab;
-{
- bfd_byte buffer[BYTES_IN_WORD];
-
- /* The string table starts with the size. */
- PUT_WORD (abfd, _bfd_stringtab_size (tab) + BYTES_IN_WORD, buffer);
- if (bfd_write ((PTR) buffer, 1, BYTES_IN_WORD, abfd) != BYTES_IN_WORD)
- return false;
-
- return _bfd_stringtab_emit (abfd, tab);
-}
-
-boolean
-NAME(aout,write_syms) (abfd)
- bfd *abfd;
-{
- unsigned int count ;
- asymbol **generic = bfd_get_outsymbols (abfd);
- struct bfd_strtab_hash *strtab;
-
- strtab = _bfd_stringtab_init ();
- if (strtab == NULL)
- return false;
-
- for (count = 0; count < bfd_get_symcount (abfd); count++)
- {
- asymbol *g = generic[count];
- bfd_size_type indx;
- struct external_nlist nsp;
-
- indx = add_to_stringtab (abfd, strtab, g->name, false);
- if (indx == (bfd_size_type) -1)
- goto error_return;
- PUT_WORD (abfd, indx, (bfd_byte *) nsp.e_strx);
-
- if (bfd_asymbol_flavour(g) == abfd->xvec->flavour)
- {
- bfd_h_put_16(abfd, aout_symbol(g)->desc, nsp.e_desc);
- bfd_h_put_8(abfd, aout_symbol(g)->other, nsp.e_other);
- bfd_h_put_8(abfd, aout_symbol(g)->type, nsp.e_type);
- }
- else
- {
- bfd_h_put_16(abfd,0, nsp.e_desc);
- bfd_h_put_8(abfd, 0, nsp.e_other);
- bfd_h_put_8(abfd, 0, nsp.e_type);
- }
-
- if (! translate_to_native_sym_flags (abfd, g, &nsp))
- goto error_return;
-
- if (bfd_write((PTR)&nsp,1,EXTERNAL_NLIST_SIZE, abfd)
- != EXTERNAL_NLIST_SIZE)
- goto error_return;
-
- /* NB: `KEEPIT' currently overlays `udata.p', so set this only
- here, at the end. */
- g->KEEPIT = count;
- }
-
- if (! emit_stringtab (abfd, strtab))
- goto error_return;
-
- _bfd_stringtab_free (strtab);
-
- return true;
-
-error_return:
- _bfd_stringtab_free (strtab);
- return false;
-}
-
-
-long
-NAME(aout,get_symtab) (abfd, location)
- bfd *abfd;
- asymbol **location;
-{
- unsigned int counter = 0;
- aout_symbol_type *symbase;
-
- if (!NAME(aout,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);
-}
-
-
-/* Standard reloc stuff */
-/* Output standard relocation information to a file in target byte order. */
-
-void
-NAME(aout,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;
- 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? */
- /* XXX This relies on relocs coming from a.out files. */
- r_baserel = (g->howto->type & 8) != 0;
- r_jmptable = (g->howto->type & 16) != 0;
- r_relative = (g->howto->type & 32) != 0;
-
-#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)
- || 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 = (*(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(aout,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;
- if ((sym->flags & BSF_SECTION_SYM) != 0)
- r_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_abs_section (bfd_get_section (sym)))
- {
- r_extern = 0;
- r_index = 0;
- }
- else if ((sym->flags & BSF_SECTION_SYM) == 0)
- {
- if (bfd_is_und_section (bfd_get_section (sym))
- || (sym->flags & BSF_GLOBAL) != 0)
- r_extern = 1;
- else
- r_extern = 0;
- 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_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(aout,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;
-{
- unsigned 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));
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd)) {
- r_index = (bytes->r_index[0] << 16)
- | (bytes->r_index[1] << 8)
- | bytes->r_index[2];
- r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
- r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
- >> RELOC_EXT_BITS_TYPE_SH_BIG;
- } else {
- r_index = (bytes->r_index[2] << 16)
- | (bytes->r_index[1] << 8)
- | bytes->r_index[0];
- r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
- r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
- >> RELOC_EXT_BITS_TYPE_SH_LITTLE;
- }
-
- cache_ptr->howto = howto_table_ext + r_type;
-
- /* Base relative relocs are always against the symbol table,
- regardless of the setting of r_extern. r_extern just reflects
- whether the symbol the reloc is against is local or global. */
- if (r_type == RELOC_BASE10
- || r_type == RELOC_BASE13
- || r_type == RELOC_BASE22)
- r_extern = 1;
-
- if (r_extern && r_index > symcount)
- {
- /* We could arrange to return an error, but it might be useful
- to see the file even if it is bad. */
- r_extern = 0;
- r_index = N_ABS;
- }
-
- MOVE_ADDRESS(GET_SWORD(abfd, bytes->r_addend));
-}
-
-void
-NAME(aout,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;
-{
- unsigned 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);
- unsigned int howto_idx;
-
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd)) {
- r_index = (bytes->r_index[0] << 16)
- | (bytes->r_index[1] << 8)
- | bytes->r_index[2];
- r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
- r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
- r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));
- r_jmptable= (0 != (bytes->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG));
- r_relative= (0 != (bytes->r_type[0] & RELOC_STD_BITS_RELATIVE_BIG));
- r_length = (bytes->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
- >> RELOC_STD_BITS_LENGTH_SH_BIG;
- } else {
- r_index = (bytes->r_index[2] << 16)
- | (bytes->r_index[1] << 8)
- | bytes->r_index[0];
- r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
- r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
- r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_LITTLE));
- r_jmptable= (0 != (bytes->r_type[0] & RELOC_STD_BITS_JMPTABLE_LITTLE));
- r_relative= (0 != (bytes->r_type[0] & RELOC_STD_BITS_RELATIVE_LITTLE));
- r_length = (bytes->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
- >> RELOC_STD_BITS_LENGTH_SH_LITTLE;
- }
-
- howto_idx = r_length + 4 * r_pcrel + 8 * r_baserel
- + 16 * r_jmptable + 32 * r_relative;
- BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
- cache_ptr->howto = howto_table_std + howto_idx;
- BFD_ASSERT (cache_ptr->howto->type != (unsigned int) -1);
-
- /* Base relative relocs are always against the symbol table,
- regardless of the setting of r_extern. r_extern just reflects
- whether the symbol the reloc is against is local or global. */
- if (r_baserel)
- r_extern = 1;
-
- if (r_extern && r_index > symcount)
- {
- /* We could arrange to return an error, but it might be useful
- to see the file even if it is bad. */
- r_extern = 0;
- r_index = N_ABS;
- }
-
- MOVE_ADDRESS(0);
-}
-
-/* Read and swap the relocs for a section. */
-
-boolean
-NAME(aout,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;
- unsigned int counter = 0;
- 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;
- else if (asect == obj_textsec (abfd))
- reloc_size = exec_hdr(abfd)->a_trsize;
- else if (asect == obj_bsssec (abfd))
- reloc_size = 0;
- else
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- 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 ((size_t) (count * sizeof (arelent)));
- if (reloc_cache == NULL && count != 0)
- return false;
- memset (reloc_cache, 0, count * sizeof (arelent));
-
- relocs = bfd_malloc ((size_t) reloc_size);
- if (relocs == NULL && reloc_size != 0)
- {
- free (reloc_cache);
- return false;
- }
-
- if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
- {
- free (relocs);
- free (reloc_cache);
- return false;
- }
-
- cache_ptr = reloc_cache;
- if (each_size == RELOC_EXT_SIZE)
- {
- register struct reloc_ext_external *rptr =
- (struct reloc_ext_external *) relocs;
-
- for (; counter < count; counter++, rptr++, cache_ptr++)
- NAME(aout,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;
-
- for (; counter < count; counter++, rptr++, cache_ptr++)
- MY_swap_std_reloc_in (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
- }
-
- free (relocs);
-
- asect->relocation = reloc_cache;
- asect->reloc_count = cache_ptr - reloc_cache;
-
- return true;
-}
-
-/* Write out a relocation section into an object file. */
-
-boolean
-NAME(aout,squirt_out_relocs) (abfd, section)
- bfd *abfd;
- asection *section;
-{
- arelent **generic;
- unsigned char *native, *natptr;
- size_t each_size;
-
- unsigned int count = section->reloc_count;
- size_t natsize;
-
- if (count == 0) return true;
-
- each_size = obj_reloc_entry_size (abfd);
- natsize = each_size * count;
- native = (unsigned char *) bfd_zalloc (abfd, natsize);
- if (!native)
- return false;
-
- generic = section->orelocation;
-
- if (each_size == RELOC_EXT_SIZE)
- {
- for (natptr = native;
- count != 0;
- --count, natptr += each_size, ++generic)
- NAME(aout,swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *)natptr);
- }
- else
- {
- for (natptr = native;
- count != 0;
- --count, natptr += each_size, ++generic)
- MY_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(aout,canonicalize_reloc) (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr = section->relocation;
- unsigned int count;
-
- if (section == obj_bsssec (abfd))
- {
- *relptr = NULL;
- return 0;
- }
-
- if (!(tblptr || NAME(aout,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;
-}
-
-long
-NAME(aout,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 / obj_reloc_entry_size (abfd))
- + 1));
-
- if (asect == obj_textsec (abfd))
- return (sizeof (arelent *)
- * ((exec_hdr(abfd)->a_trsize / obj_reloc_entry_size (abfd))
- + 1));
-
- if (asect == obj_bsssec (abfd))
- return sizeof (arelent *);
-
- if (asect == obj_bsssec (abfd))
- return 0;
-
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
-}
-
-
-long
-NAME(aout,get_symtab_upper_bound) (abfd)
- bfd *abfd;
-{
- if (!NAME(aout,slurp_symbol_table)(abfd))
- return -1;
-
- return (bfd_get_symcount (abfd)+1) * (sizeof (aout_symbol_type *));
-}
-
-/*ARGSUSED*/
- alent *
-NAME(aout,get_lineno) (ignore_abfd, ignore_symbol)
- bfd *ignore_abfd;
- asymbol *ignore_symbol;
-{
-return (alent *)NULL;
-}
-
-/*ARGSUSED*/
-void
-NAME(aout,get_symbol_info) (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-
- if (ret->type == '?')
- {
- int type_code = aout_symbol(symbol)->type & 0xff;
- const char *stab_name = bfd_get_stab_name (type_code);
- static char buf[10];
-
- if (stab_name == NULL)
- {
- sprintf(buf, "(%d)", type_code);
- stab_name = buf;
- }
- ret->type = '-';
- ret->stab_type = type_code;
- ret->stab_other = (unsigned)(aout_symbol(symbol)->other & 0xff);
- ret->stab_desc = (unsigned)(aout_symbol(symbol)->desc & 0xffff);
- ret->stab_name = stab_name;
- }
-}
-
-/*ARGSUSED*/
-void
-NAME(aout,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:
- if (symbol->name)
- fprintf(file,"%s", symbol->name);
- break;
- case bfd_print_symbol_more:
- fprintf(file,"%4x %2x %2x",(unsigned)(aout_symbol(symbol)->desc & 0xffff),
- (unsigned)(aout_symbol(symbol)->other & 0xff),
- (unsigned)(aout_symbol(symbol)->type));
- break;
- case bfd_print_symbol_all:
- {
- CONST char *section_name = symbol->section->name;
-
-
- bfd_print_symbol_vandf((PTR)file,symbol);
-
- fprintf(file," %-5s %04x %02x %02x",
- section_name,
- (unsigned)(aout_symbol(symbol)->desc & 0xffff),
- (unsigned)(aout_symbol(symbol)->other & 0xff),
- (unsigned)(aout_symbol(symbol)->type & 0xff));
- if (symbol->name)
- fprintf(file," %s", symbol->name);
- }
- break;
- }
-}
-
-/* If we don't have to allocate more than 1MB to hold the generic
- symbols, we use the generic minisymbol methord: it's faster, since
- it only translates the symbols once, not multiple times. */
-#define MINISYM_THRESHOLD (1000000 / sizeof (asymbol))
-
-/* Read minisymbols. For minisymbols, we use the unmodified a.out
- symbols. The minisymbol_to_symbol function translates these into
- BFD asymbol structures. */
-
-long
-NAME(aout,read_minisymbols) (abfd, dynamic, minisymsp, sizep)
- bfd *abfd;
- boolean dynamic;
- PTR *minisymsp;
- unsigned int *sizep;
-{
- if (dynamic)
- {
- /* We could handle the dynamic symbols here as well, but it's
- easier to hand them off. */
- return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
- }
-
- if (! aout_get_external_symbols (abfd))
- return -1;
-
- if (obj_aout_external_sym_count (abfd) < MINISYM_THRESHOLD)
- return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
-
- *minisymsp = (PTR) obj_aout_external_syms (abfd);
-
- /* By passing the external symbols back from this routine, we are
- giving up control over the memory block. Clear
- obj_aout_external_syms, so that we do not try to free it
- ourselves. */
- obj_aout_external_syms (abfd) = NULL;
-
- *sizep = EXTERNAL_NLIST_SIZE;
- return obj_aout_external_sym_count (abfd);
-}
-
-/* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
- unmodified a.out symbol. The SYM argument is a structure returned
- by bfd_make_empty_symbol, which we fill in here. */
-
-asymbol *
-NAME(aout,minisymbol_to_symbol) (abfd, dynamic, minisym, sym)
- bfd *abfd;
- boolean dynamic;
- const PTR minisym;
- asymbol *sym;
-{
- if (dynamic
- || obj_aout_external_sym_count (abfd) < MINISYM_THRESHOLD)
- return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
-
- memset (sym, 0, sizeof (aout_symbol_type));
-
- /* We call translate_symbol_table to translate a single symbol. */
- if (! (NAME(aout,translate_symbol_table)
- (abfd,
- (aout_symbol_type *) sym,
- (struct external_nlist *) minisym,
- (bfd_size_type) 1,
- obj_aout_external_strings (abfd),
- obj_aout_external_string_size (abfd),
- false)))
- return NULL;
-
- return sym;
-}
-
-/*
- provided a BFD, a section and an offset into the section, calculate
- and return the name of the source file and the line nearest to the
- wanted location.
-*/
-
-boolean
-NAME(aout,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;
-{
- /* Run down the file looking for the filename, function and linenumber */
- asymbol **p;
- CONST char *directory_name = NULL;
- CONST char *main_file_name = NULL;
- CONST char *current_file_name = NULL;
- CONST char *line_file_name = NULL; /* Value of current_file_name at line number. */
- bfd_vma low_line_vma = 0;
- bfd_vma low_func_vma = 0;
- asymbol *func = 0;
- size_t filelen, funclen;
- char *buf;
-
- *filename_ptr = abfd->filename;
- *functionname_ptr = 0;
- *line_ptr = 0;
- if (symbols != (asymbol **)NULL) {
- for (p = symbols; *p; p++) {
- aout_symbol_type *q = (aout_symbol_type *)(*p);
- next:
- switch (q->type){
- case N_SO:
- main_file_name = current_file_name = q->symbol.name;
- /* Look ahead to next symbol to check if that too is an N_SO. */
- p++;
- if (*p == NULL)
- break;
- q = (aout_symbol_type *)(*p);
- if (q->type != (int)N_SO)
- goto next;
-
- /* Found a second N_SO First is directory; second is filename. */
- directory_name = current_file_name;
- main_file_name = current_file_name = q->symbol.name;
- if (obj_textsec(abfd) != section)
- goto done;
- break;
- case N_SOL:
- current_file_name = q->symbol.name;
- break;
-
- case N_SLINE:
-
- case N_DSLINE:
- case N_BSLINE:
- /* We'll keep this if it resolves nearer than the one we have
- already. */
- if (q->symbol.value >= low_line_vma
- && q->symbol.value <= offset)
- {
- *line_ptr = q->desc;
- low_line_vma = q->symbol.value;
- line_file_name = current_file_name;
- }
- break;
- case N_FUN:
- {
- /* We'll keep this if it is nearer than the one we have already */
- if (q->symbol.value >= low_func_vma &&
- q->symbol.value <= offset) {
- low_func_vma = q->symbol.value;
- func = (asymbol *)q;
- }
- else if (q->symbol.value > offset)
- goto done;
- }
- break;
- }
- }
- }
-
- done:
- if (*line_ptr != 0)
- main_file_name = line_file_name;
-
- if (main_file_name == NULL
- || main_file_name[0] == '/'
- || directory_name == NULL)
- filelen = 0;
- else
- filelen = strlen (directory_name) + strlen (main_file_name);
- if (func == NULL)
- funclen = 0;
- else
- funclen = strlen (bfd_asymbol_name (func));
-
- if (adata (abfd).line_buf != NULL)
- free (adata (abfd).line_buf);
- if (filelen + funclen == 0)
- adata (abfd).line_buf = buf = NULL;
- else
- {
- buf = (char *) bfd_malloc (filelen + funclen + 2);
- adata (abfd).line_buf = buf;
- if (buf == NULL)
- return false;
- }
-
- if (main_file_name != NULL)
- {
- if (main_file_name[0] == '/' || directory_name == NULL)
- *filename_ptr = main_file_name;
- else
- {
- sprintf (buf, "%s%s", directory_name, main_file_name);
- *filename_ptr = buf;
- buf += filelen + 1;
- }
- }
-
- if (func)
- {
- const char *function = func->name;
- char *p;
-
- /* The caller expects a symbol name. We actually have a
- function name, without the leading underscore. Put the
- underscore back in, so that the caller gets a symbol name. */
- if (bfd_get_symbol_leading_char (abfd) == '\0')
- strcpy (buf, function);
- else
- {
- buf[0] = bfd_get_symbol_leading_char (abfd);
- strcpy (buf + 1, function);
- }
- /* Have to remove : stuff */
- p = strchr (buf, ':');
- if (p != NULL)
- *p = '\0';
- *functionname_ptr = buf;
- }
-
- return true;
-}
-
-/*ARGSUSED*/
-int
-NAME(aout,sizeof_headers) (abfd, execable)
- bfd *abfd;
- boolean execable;
-{
- return adata(abfd).exec_bytes_size;
-}
-
-/* Free all information we have cached for this BFD. We can always
- read it again later if we need it. */
-
-boolean
-NAME(aout,bfd_free_cached_info) (abfd)
- bfd *abfd;
-{
- asection *o;
-
- if (bfd_get_format (abfd) != bfd_object)
- return true;
-
-#define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; }
- BFCI_FREE (obj_aout_symbols (abfd));
-#ifdef USE_MMAP
- obj_aout_external_syms (abfd) = 0;
- bfd_free_window (&obj_aout_sym_window (abfd));
- bfd_free_window (&obj_aout_string_window (abfd));
- obj_aout_external_strings (abfd) = 0;
-#else
- BFCI_FREE (obj_aout_external_syms (abfd));
- BFCI_FREE (obj_aout_external_strings (abfd));
-#endif
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- BFCI_FREE (o->relocation);
-#undef BFCI_FREE
-
- return true;
-}
-
-/* a.out link code. */
-
-static boolean aout_link_add_object_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean aout_link_check_archive_element
- PARAMS ((bfd *, struct bfd_link_info *, boolean *));
-static boolean aout_link_free_symbols PARAMS ((bfd *));
-static boolean aout_link_check_ar_symbols
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
-static boolean aout_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Routine to create an entry in an a.out link hash table. */
-
-struct bfd_hash_entry *
-NAME(aout,link_hash_newfunc) (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct aout_link_hash_entry *ret = (struct aout_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct aout_link_hash_entry *) NULL)
- ret = ((struct aout_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct aout_link_hash_entry)));
- if (ret == (struct aout_link_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct aout_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret)
- {
- /* Set local fields. */
- ret->written = false;
- ret->indx = -1;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize an a.out link hash table. */
-
-boolean
-NAME(aout,link_hash_table_init) (table, abfd, newfunc)
- struct aout_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 an a.out link hash table. */
-
-struct bfd_link_hash_table *
-NAME(aout,link_hash_table_create) (abfd)
- bfd *abfd;
-{
- struct aout_link_hash_table *ret;
-
- ret = ((struct aout_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct aout_link_hash_table)));
- if (ret == NULL)
- return (struct bfd_link_hash_table *) NULL;
- if (! NAME(aout,link_hash_table_init) (ret, abfd,
- NAME(aout,link_hash_newfunc)))
- {
- free (ret);
- return (struct bfd_link_hash_table *) NULL;
- }
- return &ret->root;
-}
-
-/* Given an a.out BFD, add symbols to the global hash table as
- appropriate. */
-
-boolean
-NAME(aout,link_add_symbols) (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- switch (bfd_get_format (abfd))
- {
- case bfd_object:
- return aout_link_add_object_symbols (abfd, info);
- case bfd_archive:
- return _bfd_generic_link_add_archive_symbols
- (abfd, info, aout_link_check_archive_element);
- default:
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-}
-
-/* Add symbols from an a.out object file. */
-
-static boolean
-aout_link_add_object_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- if (! aout_get_external_symbols (abfd))
- return false;
- if (! aout_link_add_symbols (abfd, info))
- return false;
- if (! info->keep_memory)
- {
- if (! aout_link_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 from
- _bfd_generic_link_add_archive_symbols. */
-
-static boolean
-aout_link_check_archive_element (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- if (! aout_get_external_symbols (abfd))
- return false;
-
- if (! aout_link_check_ar_symbols (abfd, info, pneeded))
- return false;
-
- if (*pneeded)
- {
- if (! aout_link_add_symbols (abfd, info))
- return false;
- }
-
- if (! info->keep_memory || ! *pneeded)
- {
- if (! aout_link_free_symbols (abfd))
- return false;
- }
-
- return true;
-}
-
-/* Free up the internal symbols read from an a.out file. */
-
-static boolean
-aout_link_free_symbols (abfd)
- bfd *abfd;
-{
- if (obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
- {
-#ifdef USE_MMAP
- bfd_free_window (&obj_aout_sym_window (abfd));
-#else
- free ((PTR) obj_aout_external_syms (abfd));
-#endif
- obj_aout_external_syms (abfd) = (struct external_nlist *) NULL;
- }
- if (obj_aout_external_strings (abfd) != (char *) NULL)
- {
-#ifdef USE_MMAP
- bfd_free_window (&obj_aout_string_window (abfd));
-#else
- free ((PTR) obj_aout_external_strings (abfd));
-#endif
- obj_aout_external_strings (abfd) = (char *) NULL;
- }
- return true;
-}
-
-/* Look through the internal symbols to see if this object file should
- be included in the link. We should include this object file if it
- defines any symbols which are currently undefined. If this object
- file defines a common symbol, then we may adjust the size of the
- known symbol but we do not include the object file in the link
- (unless there is some other reason to include it). */
-
-static boolean
-aout_link_check_ar_symbols (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- register struct external_nlist *p;
- struct external_nlist *pend;
- char *strings;
-
- *pneeded = false;
-
- /* Look through all the symbols. */
- p = obj_aout_external_syms (abfd);
- pend = p + obj_aout_external_sym_count (abfd);
- strings = obj_aout_external_strings (abfd);
- for (; p < pend; p++)
- {
- int type = bfd_h_get_8 (abfd, p->e_type);
- const char *name;
- struct bfd_link_hash_entry *h;
-
- /* Ignore symbols that are not externally visible. This is an
- optimization only, as we check the type more thoroughly
- below. */
- if (((type & N_EXT) == 0
- || (type & N_STAB) != 0
- || type == N_FN)
- && type != N_WEAKA
- && type != N_WEAKT
- && type != N_WEAKD
- && type != N_WEAKB)
- {
- if (type == N_WARNING
- || type == N_INDR)
- ++p;
- continue;
- }
-
- name = strings + GET_WORD (abfd, p->e_strx);
- h = bfd_link_hash_lookup (info->hash, name, false, false, true);
-
- /* We are only interested in symbols that are currently
- undefined or common. */
- if (h == (struct bfd_link_hash_entry *) NULL
- || (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common))
- {
- if (type == (N_INDR | N_EXT))
- ++p;
- continue;
- }
-
- if (type == (N_TEXT | N_EXT)
- || type == (N_DATA | N_EXT)
- || type == (N_BSS | N_EXT)
- || type == (N_ABS | N_EXT)
- || type == (N_INDR | N_EXT))
- {
- /* This object file defines this symbol. We must link it
- in. This is true regardless of whether the current
- definition of the symbol is undefined or common. If the
- current definition is common, we have a case in which we
- have already seen an object file including
- int a;
- and this object file from the archive includes
- int a = 5;
- In such a case we must include this object file.
-
- FIXME: The SunOS 4.1.3 linker will pull in the archive
- element if the symbol is defined in the .data section,
- but not if it is defined in the .text section. That
- seems a bit crazy to me, and I haven't implemented it.
- However, it might be correct. */
- if (! (*info->callbacks->add_archive_element) (info, abfd, name))
- return false;
- *pneeded = true;
- return true;
- }
-
- if (type == (N_UNDF | N_EXT))
- {
- bfd_vma value;
-
- value = GET_WORD (abfd, p->e_value);
- if (value != 0)
- {
- /* This symbol is common in the object from the archive
- file. */
- if (h->type == bfd_link_hash_undefined)
- {
- bfd *symbfd;
- unsigned int power;
-
- symbfd = h->u.undef.abfd;
- if (symbfd == (bfd *) NULL)
- {
- /* This symbol was created as undefined from
- outside BFD. We assume that we should link
- in the object file. This is done for the -u
- option in the linker. */
- if (! (*info->callbacks->add_archive_element) (info,
- abfd,
- name))
- return false;
- *pneeded = true;
- return true;
- }
- /* Turn the current link symbol into a common
- symbol. It is already on the undefs list. */
- h->type = bfd_link_hash_common;
- h->u.c.p = ((struct bfd_link_hash_common_entry *)
- bfd_hash_allocate (&info->hash->table,
- sizeof (struct bfd_link_hash_common_entry)));
- if (h->u.c.p == NULL)
- return false;
-
- h->u.c.size = value;
-
- /* FIXME: This isn't quite right. The maximum
- alignment of a common symbol should be set by the
- architecture of the output file, not of the input
- file. */
- power = bfd_log2 (value);
- if (power > bfd_get_arch_info (abfd)->section_align_power)
- power = bfd_get_arch_info (abfd)->section_align_power;
- h->u.c.p->alignment_power = power;
-
- h->u.c.p->section = bfd_make_section_old_way (symbfd,
- "COMMON");
- }
- else
- {
- /* Adjust the size of the common symbol if
- necessary. */
- if (value > h->u.c.size)
- h->u.c.size = value;
- }
- }
- }
-
- if (type == N_WEAKA
- || type == N_WEAKT
- || type == N_WEAKD
- || type == N_WEAKB)
- {
- /* This symbol is weak but defined. We must pull it in if
- the current link symbol is undefined, but we don't want
- it if the current link symbol is common. */
- if (h->type == bfd_link_hash_undefined)
- {
- if (! (*info->callbacks->add_archive_element) (info, abfd, name))
- return false;
- *pneeded = true;
- return true;
- }
- }
- }
-
- /* We do not need this object file. */
- return true;
-}
-
-/* Add all symbols from an object file to the hash table. */
-
-static boolean
-aout_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- boolean (*add_one_symbol) PARAMS ((struct bfd_link_info *, bfd *,
- const char *, flagword, asection *,
- bfd_vma, const char *, boolean,
- boolean,
- struct bfd_link_hash_entry **));
- struct external_nlist *syms;
- bfd_size_type sym_count;
- char *strings;
- boolean copy;
- struct aout_link_hash_entry **sym_hash;
- register struct external_nlist *p;
- struct external_nlist *pend;
-
- syms = obj_aout_external_syms (abfd);
- sym_count = obj_aout_external_sym_count (abfd);
- strings = obj_aout_external_strings (abfd);
- if (info->keep_memory)
- copy = false;
- else
- copy = true;
-
- if ((abfd->flags & DYNAMIC) != 0
- && aout_backend_info (abfd)->add_dynamic_symbols != NULL)
- {
- if (! ((*aout_backend_info (abfd)->add_dynamic_symbols)
- (abfd, info, &syms, &sym_count, &strings)))
- return false;
- }
-
- /* We keep a list of the linker hash table entries that correspond
- to particular symbols. We could just look them up in the hash
- table, but keeping the list is more efficient. Perhaps this
- should be conditional on info->keep_memory. */
- sym_hash = ((struct aout_link_hash_entry **)
- bfd_alloc (abfd,
- ((size_t) sym_count
- * sizeof (struct aout_link_hash_entry *))));
- if (sym_hash == NULL && sym_count != 0)
- return false;
- obj_aout_sym_hashes (abfd) = sym_hash;
-
- add_one_symbol = aout_backend_info (abfd)->add_one_symbol;
- if (add_one_symbol == NULL)
- add_one_symbol = _bfd_generic_link_add_one_symbol;
-
- p = syms;
- pend = p + sym_count;
- for (; p < pend; p++, sym_hash++)
- {
- int type;
- const char *name;
- bfd_vma value;
- asection *section;
- flagword flags;
- const char *string;
-
- *sym_hash = NULL;
-
- type = bfd_h_get_8 (abfd, p->e_type);
-
- /* Ignore debugging symbols. */
- if ((type & N_STAB) != 0)
- continue;
-
- name = strings + GET_WORD (abfd, p->e_strx);
- value = GET_WORD (abfd, p->e_value);
- flags = BSF_GLOBAL;
- string = NULL;
- switch (type)
- {
- default:
- abort ();
-
- case N_UNDF:
- case N_ABS:
- case N_TEXT:
- case N_DATA:
- case N_BSS:
- case N_FN_SEQ:
- case N_COMM:
- case N_SETV:
- case N_FN:
- /* Ignore symbols that are not externally visible. */
- continue;
- case N_INDR:
- /* Ignore local indirect symbol. */
- ++p;
- ++sym_hash;
- continue;
-
- case N_UNDF | N_EXT:
- if (value == 0)
- {
- section = bfd_und_section_ptr;
- flags = 0;
- }
- else
- section = bfd_com_section_ptr;
- break;
- case N_ABS | N_EXT:
- section = bfd_abs_section_ptr;
- break;
- case N_TEXT | N_EXT:
- section = obj_textsec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_DATA | N_EXT:
- case N_SETV | N_EXT:
- /* Treat N_SETV symbols as N_DATA symbol; see comment in
- translate_from_native_sym_flags. */
- section = obj_datasec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_BSS | N_EXT:
- section = obj_bsssec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_INDR | N_EXT:
- /* An indirect symbol. The next symbol is the symbol
- which this one really is. */
- BFD_ASSERT (p + 1 < pend);
- ++p;
- string = strings + GET_WORD (abfd, p->e_strx);
- section = bfd_ind_section_ptr;
- flags |= BSF_INDIRECT;
- break;
- case N_COMM | N_EXT:
- section = bfd_com_section_ptr;
- break;
- case N_SETA: case N_SETA | N_EXT:
- section = bfd_abs_section_ptr;
- flags |= BSF_CONSTRUCTOR;
- break;
- case N_SETT: case N_SETT | N_EXT:
- section = obj_textsec (abfd);
- flags |= BSF_CONSTRUCTOR;
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_SETD: case N_SETD | N_EXT:
- section = obj_datasec (abfd);
- flags |= BSF_CONSTRUCTOR;
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_SETB: case N_SETB | N_EXT:
- section = obj_bsssec (abfd);
- flags |= BSF_CONSTRUCTOR;
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_WARNING:
- /* A warning symbol. The next symbol is the one to warn
- about. */
- BFD_ASSERT (p + 1 < pend);
- ++p;
- string = name;
- name = strings + GET_WORD (abfd, p->e_strx);
- section = bfd_und_section_ptr;
- flags |= BSF_WARNING;
- break;
- case N_WEAKU:
- section = bfd_und_section_ptr;
- flags = BSF_WEAK;
- break;
- case N_WEAKA:
- section = bfd_abs_section_ptr;
- flags = BSF_WEAK;
- break;
- case N_WEAKT:
- section = obj_textsec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- flags = BSF_WEAK;
- break;
- case N_WEAKD:
- section = obj_datasec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- flags = BSF_WEAK;
- break;
- case N_WEAKB:
- section = obj_bsssec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- flags = BSF_WEAK;
- break;
- }
-
- if (! ((*add_one_symbol)
- (info, abfd, name, flags, section, value, string, copy, false,
- (struct bfd_link_hash_entry **) sym_hash)))
- return false;
-
- /* Restrict the maximum alignment of a common symbol based on
- the architecture, since a.out has no way to represent
- alignment requirements of a section in a .o file. FIXME:
- This isn't quite right: it should use the architecture of the
- output file, not the input files. */
- if ((*sym_hash)->root.type == bfd_link_hash_common
- && ((*sym_hash)->root.u.c.p->alignment_power >
- bfd_get_arch_info (abfd)->section_align_power))
- (*sym_hash)->root.u.c.p->alignment_power =
- bfd_get_arch_info (abfd)->section_align_power;
-
- /* If this is a set symbol, and we are not building sets, then
- it is possible for the hash entry to not have been set. In
- such a case, treat the symbol as not globally defined. */
- if ((*sym_hash)->root.type == bfd_link_hash_new)
- {
- BFD_ASSERT ((flags & BSF_CONSTRUCTOR) != 0);
- *sym_hash = NULL;
- }
-
- if (type == (N_INDR | N_EXT) || type == N_WARNING)
- ++sym_hash;
- }
-
- return true;
-}
-
-/* A hash table used for header files with N_BINCL entries. */
-
-struct aout_link_includes_table
-{
- struct bfd_hash_table root;
-};
-
-/* A linked list of totals that we have found for a particular header
- file. */
-
-struct aout_link_includes_totals
-{
- struct aout_link_includes_totals *next;
- bfd_vma total;
-};
-
-/* An entry in the header file hash table. */
-
-struct aout_link_includes_entry
-{
- struct bfd_hash_entry root;
- /* List of totals we have found for this file. */
- struct aout_link_includes_totals *totals;
-};
-
-/* Look up an entry in an the header file hash table. */
-
-#define aout_link_includes_lookup(table, string, create, copy) \
- ((struct aout_link_includes_entry *) \
- bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
-
-/* During the final link step we need to pass around a bunch of
- information, so we do it in an instance of this structure. */
-
-struct aout_final_link_info
-{
- /* General link information. */
- struct bfd_link_info *info;
- /* Output bfd. */
- bfd *output_bfd;
- /* Reloc file positions. */
- file_ptr treloff, dreloff;
- /* File position of symbols. */
- file_ptr symoff;
- /* String table. */
- struct bfd_strtab_hash *strtab;
- /* Header file hash table. */
- struct aout_link_includes_table includes;
- /* A buffer large enough to hold the contents of any section. */
- bfd_byte *contents;
- /* A buffer large enough to hold the relocs of any section. */
- PTR relocs;
- /* A buffer large enough to hold the symbol map of any input BFD. */
- int *symbol_map;
- /* A buffer large enough to hold output symbols of any input BFD. */
- struct external_nlist *output_syms;
-};
-
-static struct bfd_hash_entry *aout_link_includes_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static boolean aout_link_input_bfd
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
-static boolean aout_link_write_symbols
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
-static boolean aout_link_write_other_symbol
- PARAMS ((struct aout_link_hash_entry *, PTR));
-static boolean aout_link_input_section
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
- asection *input_section, file_ptr *reloff_ptr,
- bfd_size_type rel_size));
-static boolean aout_link_input_section_std
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
- asection *input_section, struct reloc_std_external *,
- bfd_size_type rel_size, bfd_byte *contents));
-static boolean aout_link_input_section_ext
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
- asection *input_section, struct reloc_ext_external *,
- bfd_size_type rel_size, bfd_byte *contents));
-static INLINE asection *aout_reloc_index_to_section
- PARAMS ((bfd *, int));
-static boolean aout_link_reloc_link_order
- PARAMS ((struct aout_final_link_info *, asection *,
- struct bfd_link_order *));
-
-/* The function to create a new entry in the header file hash table. */
-
-static struct bfd_hash_entry *
-aout_link_includes_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct aout_link_includes_entry *ret =
- (struct aout_link_includes_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct aout_link_includes_entry *) NULL)
- ret = ((struct aout_link_includes_entry *)
- bfd_hash_allocate (table,
- sizeof (struct aout_link_includes_entry)));
- if (ret == (struct aout_link_includes_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct aout_link_includes_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
- if (ret)
- {
- /* Set local fields. */
- ret->totals = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Do the final link step. This is called on the output BFD. The
- INFO structure should point to a list of BFDs linked through the
- link_next field which can be used to find each BFD which takes part
- in the output. Also, each section in ABFD should point to a list
- of bfd_link_order structures which list all the input sections for
- the output section. */
-
-boolean
-NAME(aout,final_link) (abfd, info, callback)
- bfd *abfd;
- struct bfd_link_info *info;
- void (*callback) PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
-{
- struct aout_final_link_info aout_info;
- boolean includes_hash_initialized = false;
- register bfd *sub;
- bfd_size_type trsize, drsize;
- size_t max_contents_size;
- size_t max_relocs_size;
- size_t max_sym_count;
- bfd_size_type text_size;
- file_ptr text_end;
- register struct bfd_link_order *p;
- asection *o;
- boolean have_link_order_relocs;
-
- if (info->shared)
- abfd->flags |= DYNAMIC;
-
- aout_info.info = info;
- aout_info.output_bfd = abfd;
- aout_info.contents = NULL;
- aout_info.relocs = NULL;
- aout_info.symbol_map = NULL;
- aout_info.output_syms = NULL;
-
- if (! bfd_hash_table_init_n (&aout_info.includes.root,
- aout_link_includes_newfunc,
- 251))
- goto error_return;
- includes_hash_initialized = true;
-
- /* Figure out the largest section size. Also, if generating
- relocateable output, count the relocs. */
- trsize = 0;
- drsize = 0;
- max_contents_size = 0;
- max_relocs_size = 0;
- max_sym_count = 0;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- {
- size_t sz;
-
- if (info->relocateable)
- {
- if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
- {
- trsize += exec_hdr (sub)->a_trsize;
- drsize += exec_hdr (sub)->a_drsize;
- }
- else
- {
- /* FIXME: We need to identify the .text and .data sections
- and call get_reloc_upper_bound and canonicalize_reloc to
- work out the number of relocs needed, and then multiply
- by the reloc size. */
- (*_bfd_error_handler)
- ("%s: relocateable link from %s to %s not supported",
- bfd_get_filename (abfd),
- sub->xvec->name, abfd->xvec->name);
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
- }
-
- if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
- {
- sz = bfd_section_size (sub, obj_textsec (sub));
- if (sz > max_contents_size)
- max_contents_size = sz;
- sz = bfd_section_size (sub, obj_datasec (sub));
- if (sz > max_contents_size)
- max_contents_size = sz;
-
- sz = exec_hdr (sub)->a_trsize;
- if (sz > max_relocs_size)
- max_relocs_size = sz;
- sz = exec_hdr (sub)->a_drsize;
- if (sz > max_relocs_size)
- max_relocs_size = sz;
-
- sz = obj_aout_external_sym_count (sub);
- if (sz > max_sym_count)
- max_sym_count = sz;
- }
- }
-
- if (info->relocateable)
- {
- if (obj_textsec (abfd) != (asection *) NULL)
- trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
- ->link_order_head)
- * obj_reloc_entry_size (abfd));
- if (obj_datasec (abfd) != (asection *) NULL)
- drsize += (_bfd_count_link_order_relocs (obj_datasec (abfd)
- ->link_order_head)
- * obj_reloc_entry_size (abfd));
- }
-
- exec_hdr (abfd)->a_trsize = trsize;
- exec_hdr (abfd)->a_drsize = drsize;
-
- exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
-
- /* Adjust the section sizes and vmas according to the magic number.
- This sets a_text, a_data and a_bss in the exec_hdr and sets the
- filepos for each section. */
- if (! NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end))
- goto error_return;
-
- /* The relocation and symbol file positions differ among a.out
- targets. We are passed a callback routine from the backend
- specific code to handle this.
- FIXME: At this point we do not know how much space the symbol
- table will require. This will not work for any (nonstandard)
- a.out target that needs to know the symbol table size before it
- can compute the relocation file positions. This may or may not
- be the case for the hp300hpux target, for example. */
- (*callback) (abfd, &aout_info.treloff, &aout_info.dreloff,
- &aout_info.symoff);
- obj_textsec (abfd)->rel_filepos = aout_info.treloff;
- obj_datasec (abfd)->rel_filepos = aout_info.dreloff;
- obj_sym_filepos (abfd) = aout_info.symoff;
-
- /* We keep a count of the symbols as we output them. */
- obj_aout_external_sym_count (abfd) = 0;
-
- /* We accumulate the string table as we write out the symbols. */
- aout_info.strtab = _bfd_stringtab_init ();
- if (aout_info.strtab == NULL)
- goto error_return;
-
- /* Allocate buffers to hold section contents and relocs. */
- aout_info.contents = (bfd_byte *) bfd_malloc (max_contents_size);
- aout_info.relocs = (PTR) bfd_malloc (max_relocs_size);
- aout_info.symbol_map = (int *) bfd_malloc (max_sym_count * sizeof (int *));
- aout_info.output_syms = ((struct external_nlist *)
- bfd_malloc ((max_sym_count + 1)
- * sizeof (struct external_nlist)));
- if ((aout_info.contents == NULL && max_contents_size != 0)
- || (aout_info.relocs == NULL && max_relocs_size != 0)
- || (aout_info.symbol_map == NULL && max_sym_count != 0)
- || aout_info.output_syms == NULL)
- goto error_return;
-
- /* If we have a symbol named __DYNAMIC, force it out now. This is
- required by SunOS. Doing this here rather than in sunos.c is a
- hack, but it's easier than exporting everything which would be
- needed. */
- {
- struct aout_link_hash_entry *h;
-
- h = aout_link_hash_lookup (aout_hash_table (info), "__DYNAMIC",
- false, false, false);
- if (h != NULL)
- aout_link_write_other_symbol (h, &aout_info);
- }
-
- /* The most time efficient way to do the link would be to read all
- the input object files into memory and then sort out the
- information into the output file. Unfortunately, that will
- probably use too much memory. Another method would be to step
- through everything that composes the text section and write it
- out, and then everything that composes the data section and write
- it out, and then write out the relocs, and then write out the
- symbols. Unfortunately, that requires reading stuff from each
- input file several times, and we will not be able to keep all the
- input files open simultaneously, and reopening them will be slow.
-
- What we do is basically process one input file at a time. We do
- everything we need to do with an input file once--copy over the
- section contents, handle the relocation information, and write
- out the symbols--and then we throw away the information we read
- from it. This approach requires a lot of lseeks of the output
- file, which is unfortunate but still faster than reopening a lot
- of files.
-
- We use the output_has_begun field of the input BFDs to see
- whether we have already handled it. */
- for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
- sub->output_has_begun = false;
-
- have_link_order_relocs = false;
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- if (p->type == bfd_indirect_link_order
- && (bfd_get_flavour (p->u.indirect.section->owner)
- == bfd_target_aout_flavour))
- {
- bfd *input_bfd;
-
- input_bfd = p->u.indirect.section->owner;
- if (! input_bfd->output_has_begun)
- {
- if (! aout_link_input_bfd (&aout_info, input_bfd))
- goto error_return;
- input_bfd->output_has_begun = true;
- }
- }
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- /* These are handled below. */
- have_link_order_relocs = true;
- }
- else
- {
- if (! _bfd_default_link_order (abfd, info, o, p))
- goto error_return;
- }
- }
- }
-
- /* Write out any symbols that we have not already written out. */
- aout_link_hash_traverse (aout_hash_table (info),
- aout_link_write_other_symbol,
- (PTR) &aout_info);
-
- /* Now handle any relocs we were asked to create by the linker.
- These did not come from any input file. We must do these after
- we have written out all the symbols, so that we know the symbol
- indices to use. */
- if (have_link_order_relocs)
- {
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- if (! aout_link_reloc_link_order (&aout_info, o, p))
- goto error_return;
- }
- }
- }
- }
-
- if (aout_info.contents != NULL)
- {
- free (aout_info.contents);
- aout_info.contents = NULL;
- }
- if (aout_info.relocs != NULL)
- {
- free (aout_info.relocs);
- aout_info.relocs = NULL;
- }
- if (aout_info.symbol_map != NULL)
- {
- free (aout_info.symbol_map);
- aout_info.symbol_map = NULL;
- }
- if (aout_info.output_syms != NULL)
- {
- free (aout_info.output_syms);
- aout_info.output_syms = NULL;
- }
- if (includes_hash_initialized)
- {
- bfd_hash_table_free (&aout_info.includes.root);
- includes_hash_initialized = false;
- }
-
- /* Finish up any dynamic linking we may be doing. */
- if (aout_backend_info (abfd)->finish_dynamic_link != NULL)
- {
- if (! (*aout_backend_info (abfd)->finish_dynamic_link) (abfd, info))
- goto error_return;
- }
-
- /* Update the header information. */
- abfd->symcount = obj_aout_external_sym_count (abfd);
- exec_hdr (abfd)->a_syms = abfd->symcount * EXTERNAL_NLIST_SIZE;
- obj_str_filepos (abfd) = obj_sym_filepos (abfd) + exec_hdr (abfd)->a_syms;
- obj_textsec (abfd)->reloc_count =
- exec_hdr (abfd)->a_trsize / obj_reloc_entry_size (abfd);
- obj_datasec (abfd)->reloc_count =
- exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd);
-
- /* Write out the string table. */
- if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0)
- goto error_return;
- return emit_stringtab (abfd, aout_info.strtab);
-
- error_return:
- if (aout_info.contents != NULL)
- free (aout_info.contents);
- if (aout_info.relocs != NULL)
- free (aout_info.relocs);
- if (aout_info.symbol_map != NULL)
- free (aout_info.symbol_map);
- if (aout_info.output_syms != NULL)
- free (aout_info.output_syms);
- if (includes_hash_initialized)
- bfd_hash_table_free (&aout_info.includes.root);
- return false;
-}
-
-/* Link an a.out input BFD into the output file. */
-
-static boolean
-aout_link_input_bfd (finfo, input_bfd)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
-{
- bfd_size_type sym_count;
-
- BFD_ASSERT (bfd_get_format (input_bfd) == bfd_object);
-
- /* If this is a dynamic object, it may need special handling. */
- if ((input_bfd->flags & DYNAMIC) != 0
- && aout_backend_info (input_bfd)->link_dynamic_object != NULL)
- {
- return ((*aout_backend_info (input_bfd)->link_dynamic_object)
- (finfo->info, input_bfd));
- }
-
- /* Get the symbols. We probably have them already, unless
- finfo->info->keep_memory is false. */
- if (! aout_get_external_symbols (input_bfd))
- return false;
-
- sym_count = obj_aout_external_sym_count (input_bfd);
-
- /* Write out the symbols and get a map of the new indices. The map
- is placed into finfo->symbol_map. */
- if (! aout_link_write_symbols (finfo, input_bfd))
- return false;
-
- /* Relocate and write out the sections. These functions use the
- symbol map created by aout_link_write_symbols. */
- if (! aout_link_input_section (finfo, input_bfd,
- obj_textsec (input_bfd),
- &finfo->treloff,
- exec_hdr (input_bfd)->a_trsize)
- || ! aout_link_input_section (finfo, input_bfd,
- obj_datasec (input_bfd),
- &finfo->dreloff,
- exec_hdr (input_bfd)->a_drsize))
- return false;
-
- /* If we are not keeping memory, we don't need the symbols any
- longer. We still need them if we are keeping memory, because the
- strings in the hash table point into them. */
- if (! finfo->info->keep_memory)
- {
- if (! aout_link_free_symbols (input_bfd))
- return false;
- }
-
- return true;
-}
-
-/* Adjust and write out the symbols for an a.out file. Set the new
- symbol indices into a symbol_map. */
-
-static boolean
-aout_link_write_symbols (finfo, input_bfd)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
-{
- bfd *output_bfd;
- bfd_size_type sym_count;
- char *strings;
- enum bfd_link_strip strip;
- enum bfd_link_discard discard;
- struct external_nlist *outsym;
- bfd_size_type strtab_index;
- register struct external_nlist *sym;
- struct external_nlist *sym_end;
- struct aout_link_hash_entry **sym_hash;
- int *symbol_map;
- boolean pass;
- boolean skip_next;
-
- output_bfd = finfo->output_bfd;
- sym_count = obj_aout_external_sym_count (input_bfd);
- strings = obj_aout_external_strings (input_bfd);
- strip = finfo->info->strip;
- discard = finfo->info->discard;
- outsym = finfo->output_syms;
-
- /* First write out a symbol for this object file, unless we are
- discarding such symbols. */
- if (strip != strip_all
- && (strip != strip_some
- || bfd_hash_lookup (finfo->info->keep_hash, input_bfd->filename,
- false, false) != NULL)
- && discard != discard_all)
- {
- bfd_h_put_8 (output_bfd, N_TEXT, outsym->e_type);
- bfd_h_put_8 (output_bfd, 0, outsym->e_other);
- bfd_h_put_16 (output_bfd, (bfd_vma) 0, outsym->e_desc);
- strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
- input_bfd->filename, false);
- if (strtab_index == (bfd_size_type) -1)
- return false;
- PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
- PUT_WORD (output_bfd,
- (bfd_get_section_vma (output_bfd,
- obj_textsec (input_bfd)->output_section)
- + obj_textsec (input_bfd)->output_offset),
- outsym->e_value);
- ++obj_aout_external_sym_count (output_bfd);
- ++outsym;
- }
-
- pass = false;
- skip_next = false;
- sym = obj_aout_external_syms (input_bfd);
- sym_end = sym + sym_count;
- sym_hash = obj_aout_sym_hashes (input_bfd);
- symbol_map = finfo->symbol_map;
- memset (symbol_map, 0, sym_count * sizeof *symbol_map);
- for (; sym < sym_end; sym++, sym_hash++, symbol_map++)
- {
- const char *name;
- int type;
- struct aout_link_hash_entry *h;
- boolean skip;
- asection *symsec;
- bfd_vma val = 0;
- boolean copy;
-
- /* We set *symbol_map to 0 above for all symbols. If it has
- already been set to -1 for this symbol, it means that we are
- discarding it because it appears in a duplicate header file.
- See the N_BINCL code below. */
- if (*symbol_map == -1)
- continue;
-
- /* Initialize *symbol_map to -1, which means that the symbol was
- not copied into the output file. We will change it later if
- we do copy the symbol over. */
- *symbol_map = -1;
-
- type = bfd_h_get_8 (input_bfd, sym->e_type);
- name = strings + GET_WORD (input_bfd, sym->e_strx);
-
- h = NULL;
-
- if (pass)
- {
- /* Pass this symbol through. It is the target of an
- indirect or warning symbol. */
- val = GET_WORD (input_bfd, sym->e_value);
- pass = false;
- }
- else if (skip_next)
- {
- /* Skip this symbol, which is the target of an indirect
- symbol that we have changed to no longer be an indirect
- symbol. */
- skip_next = false;
- continue;
- }
- else
- {
- struct aout_link_hash_entry *hresolve;
-
- /* We have saved the hash table entry for this symbol, if
- there is one. Note that we could just look it up again
- in the hash table, provided we first check that it is an
- external symbol. */
- h = *sym_hash;
-
- /* Use the name from the hash table, in case the symbol was
- wrapped. */
- if (h != NULL)
- name = h->root.root.string;
-
- /* If this is an indirect or warning symbol, then change
- hresolve to the base symbol. We also change *sym_hash so
- that the relocation routines relocate against the real
- symbol. */
- hresolve = h;
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning))
- {
- hresolve = (struct aout_link_hash_entry *) h->root.u.i.link;
- while (hresolve->root.type == bfd_link_hash_indirect
- || hresolve->root.type == bfd_link_hash_warning)
- hresolve = ((struct aout_link_hash_entry *)
- hresolve->root.u.i.link);
- *sym_hash = hresolve;
- }
-
- /* If the symbol has already been written out, skip it. */
- if (h != (struct aout_link_hash_entry *) NULL
- && h->root.type != bfd_link_hash_warning
- && h->written)
- {
- if ((type & N_TYPE) == N_INDR
- || type == N_WARNING)
- skip_next = true;
- *symbol_map = h->indx;
- continue;
- }
-
- /* See if we are stripping this symbol. */
- skip = false;
- switch (strip)
- {
- case strip_none:
- break;
- case strip_debugger:
- if ((type & N_STAB) != 0)
- skip = true;
- break;
- case strip_some:
- if (bfd_hash_lookup (finfo->info->keep_hash, name, false, false)
- == NULL)
- skip = true;
- break;
- case strip_all:
- skip = true;
- break;
- }
- if (skip)
- {
- if (h != (struct aout_link_hash_entry *) NULL)
- h->written = true;
- continue;
- }
-
- /* Get the value of the symbol. */
- if ((type & N_TYPE) == N_TEXT
- || type == N_WEAKT)
- symsec = obj_textsec (input_bfd);
- else if ((type & N_TYPE) == N_DATA
- || type == N_WEAKD)
- symsec = obj_datasec (input_bfd);
- else if ((type & N_TYPE) == N_BSS
- || type == N_WEAKB)
- symsec = obj_bsssec (input_bfd);
- else if ((type & N_TYPE) == N_ABS
- || type == N_WEAKA)
- symsec = bfd_abs_section_ptr;
- else if (((type & N_TYPE) == N_INDR
- && (hresolve == (struct aout_link_hash_entry *) NULL
- || (hresolve->root.type != bfd_link_hash_defined
- && hresolve->root.type != bfd_link_hash_defweak
- && hresolve->root.type != bfd_link_hash_common)))
- || type == N_WARNING)
- {
- /* Pass the next symbol through unchanged. The
- condition above for indirect symbols is so that if
- the indirect symbol was defined, we output it with
- the correct definition so the debugger will
- understand it. */
- pass = true;
- val = GET_WORD (input_bfd, sym->e_value);
- symsec = NULL;
- }
- else if ((type & N_STAB) != 0)
- {
- val = GET_WORD (input_bfd, sym->e_value);
- symsec = NULL;
- }
- else
- {
- /* If we get here with an indirect symbol, it means that
- we are outputting it with a real definition. In such
- a case we do not want to output the next symbol,
- which is the target of the indirection. */
- if ((type & N_TYPE) == N_INDR)
- skip_next = true;
-
- symsec = NULL;
-
- /* We need to get the value from the hash table. We use
- hresolve so that if we have defined an indirect
- symbol we output the final definition. */
- if (h == (struct aout_link_hash_entry *) NULL)
- {
- switch (type & N_TYPE)
- {
- case N_SETT:
- symsec = obj_textsec (input_bfd);
- break;
- case N_SETD:
- symsec = obj_datasec (input_bfd);
- break;
- case N_SETB:
- symsec = obj_bsssec (input_bfd);
- break;
- case N_SETA:
- symsec = bfd_abs_section_ptr;
- break;
- default:
- val = 0;
- break;
- }
- }
- else if (hresolve->root.type == bfd_link_hash_defined
- || hresolve->root.type == bfd_link_hash_defweak)
- {
- asection *input_section;
- asection *output_section;
-
- /* This case usually means a common symbol which was
- turned into a defined symbol. */
- input_section = hresolve->root.u.def.section;
- output_section = input_section->output_section;
- BFD_ASSERT (bfd_is_abs_section (output_section)
- || output_section->owner == output_bfd);
- val = (hresolve->root.u.def.value
- + bfd_get_section_vma (output_bfd, output_section)
- + input_section->output_offset);
-
- /* Get the correct type based on the section. If
- this is a constructed set, force it to be
- globally visible. */
- if (type == N_SETT
- || type == N_SETD
- || type == N_SETB
- || type == N_SETA)
- type |= N_EXT;
-
- type &=~ N_TYPE;
-
- if (output_section == obj_textsec (output_bfd))
- type |= (hresolve->root.type == bfd_link_hash_defined
- ? N_TEXT
- : N_WEAKT);
- else if (output_section == obj_datasec (output_bfd))
- type |= (hresolve->root.type == bfd_link_hash_defined
- ? N_DATA
- : N_WEAKD);
- else if (output_section == obj_bsssec (output_bfd))
- type |= (hresolve->root.type == bfd_link_hash_defined
- ? N_BSS
- : N_WEAKB);
- else
- type |= (hresolve->root.type == bfd_link_hash_defined
- ? N_ABS
- : N_WEAKA);
- }
- else if (hresolve->root.type == bfd_link_hash_common)
- val = hresolve->root.u.c.size;
- else if (hresolve->root.type == bfd_link_hash_undefweak)
- {
- val = 0;
- type = N_WEAKU;
- }
- else
- val = 0;
- }
- if (symsec != (asection *) NULL)
- val = (symsec->output_section->vma
- + symsec->output_offset
- + (GET_WORD (input_bfd, sym->e_value)
- - symsec->vma));
-
- /* If this is a global symbol set the written flag, and if
- it is a local symbol see if we should discard it. */
- if (h != (struct aout_link_hash_entry *) NULL)
- {
- h->written = true;
- h->indx = obj_aout_external_sym_count (output_bfd);
- }
- else if ((type & N_TYPE) != N_SETT
- && (type & N_TYPE) != N_SETD
- && (type & N_TYPE) != N_SETB
- && (type & N_TYPE) != N_SETA)
- {
- switch (discard)
- {
- case discard_none:
- break;
- case discard_l:
- if (*name == *finfo->info->lprefix
- && (finfo->info->lprefix_len == 1
- || strncmp (name, finfo->info->lprefix,
- finfo->info->lprefix_len) == 0))
- skip = true;
- break;
- case discard_all:
- skip = true;
- break;
- }
- if (skip)
- {
- pass = false;
- continue;
- }
- }
-
- /* An N_BINCL symbol indicates the start of the stabs
- entries for a header file. We need to scan ahead to the
- next N_EINCL symbol, ignoring nesting, adding up all the
- characters in the symbol names, not including the file
- numbers in types (the first number after an open
- parenthesis). */
- if (type == N_BINCL)
- {
- struct external_nlist *incl_sym;
- int nest;
- struct aout_link_includes_entry *incl_entry;
- struct aout_link_includes_totals *t;
-
- val = 0;
- nest = 0;
- for (incl_sym = sym + 1; incl_sym < sym_end; incl_sym++)
- {
- int incl_type;
-
- incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
- if (incl_type == N_EINCL)
- {
- if (nest == 0)
- break;
- --nest;
- }
- else if (incl_type == N_BINCL)
- ++nest;
- else if (nest == 0)
- {
- const char *s;
-
- s = strings + GET_WORD (input_bfd, incl_sym->e_strx);
- for (; *s != '\0'; s++)
- {
- val += *s;
- if (*s == '(')
- {
- /* Skip the file number. */
- ++s;
- while (isdigit ((unsigned char) *s))
- ++s;
- --s;
- }
- }
- }
- }
-
- /* If we have already included a header file with the
- same value, then replace this one with an N_EXCL
- symbol. */
- copy = ! finfo->info->keep_memory;
- incl_entry = aout_link_includes_lookup (&finfo->includes,
- name, true, copy);
- if (incl_entry == NULL)
- return false;
- for (t = incl_entry->totals; t != NULL; t = t->next)
- if (t->total == val)
- break;
- if (t == NULL)
- {
- /* This is the first time we have seen this header
- file with this set of stabs strings. */
- t = ((struct aout_link_includes_totals *)
- bfd_hash_allocate (&finfo->includes.root,
- sizeof *t));
- if (t == NULL)
- return false;
- t->total = val;
- t->next = incl_entry->totals;
- incl_entry->totals = t;
- }
- else
- {
- int *incl_map;
-
- /* This is a duplicate header file. We must change
- it to be an N_EXCL entry, and mark all the
- included symbols to prevent outputting them. */
- type = N_EXCL;
-
- nest = 0;
- for (incl_sym = sym + 1, incl_map = symbol_map + 1;
- incl_sym < sym_end;
- incl_sym++, incl_map++)
- {
- int incl_type;
-
- incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
- if (incl_type == N_EINCL)
- {
- if (nest == 0)
- {
- *incl_map = -1;
- break;
- }
- --nest;
- }
- else if (incl_type == N_BINCL)
- ++nest;
- else if (nest == 0)
- *incl_map = -1;
- }
- }
- }
- }
-
- /* Copy this symbol into the list of symbols we are going to
- write out. */
- bfd_h_put_8 (output_bfd, type, outsym->e_type);
- bfd_h_put_8 (output_bfd, bfd_h_get_8 (input_bfd, sym->e_other),
- outsym->e_other);
- bfd_h_put_16 (output_bfd, bfd_h_get_16 (input_bfd, sym->e_desc),
- outsym->e_desc);
- copy = false;
- if (! finfo->info->keep_memory)
- {
- /* name points into a string table which we are going to
- free. If there is a hash table entry, use that string.
- Otherwise, copy name into memory. */
- if (h != (struct aout_link_hash_entry *) NULL)
- name = h->root.root.string;
- else
- copy = true;
- }
- strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
- name, copy);
- if (strtab_index == (bfd_size_type) -1)
- return false;
- PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
- PUT_WORD (output_bfd, val, outsym->e_value);
- *symbol_map = obj_aout_external_sym_count (output_bfd);
- ++obj_aout_external_sym_count (output_bfd);
- ++outsym;
- }
-
- /* Write out the output symbols we have just constructed. */
- if (outsym > finfo->output_syms)
- {
- bfd_size_type outsym_count;
-
- if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0)
- return false;
- outsym_count = outsym - finfo->output_syms;
- if (bfd_write ((PTR) finfo->output_syms,
- (bfd_size_type) EXTERNAL_NLIST_SIZE,
- (bfd_size_type) outsym_count, output_bfd)
- != outsym_count * EXTERNAL_NLIST_SIZE)
- return false;
- finfo->symoff += outsym_count * EXTERNAL_NLIST_SIZE;
- }
-
- return true;
-}
-
-/* Write out a symbol that was not associated with an a.out input
- object. */
-
-static boolean
-aout_link_write_other_symbol (h, data)
- struct aout_link_hash_entry *h;
- PTR data;
-{
- struct aout_final_link_info *finfo = (struct aout_final_link_info *) data;
- bfd *output_bfd;
- int type;
- bfd_vma val;
- struct external_nlist outsym;
- bfd_size_type indx;
-
- output_bfd = finfo->output_bfd;
-
- if (aout_backend_info (output_bfd)->write_dynamic_symbol != NULL)
- {
- if (! ((*aout_backend_info (output_bfd)->write_dynamic_symbol)
- (output_bfd, finfo->info, h)))
- {
- /* FIXME: No way to handle errors. */
- abort ();
- }
- }
-
- if (h->written)
- return true;
-
- h->written = true;
-
- /* An indx of -2 means the symbol must be written. */
- 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:
- abort ();
- /* Avoid variable not initialized warnings. */
- return true;
- case bfd_link_hash_new:
- /* This can happen for set symbols when sets are not being
- built. */
- 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;
-
- sec = h->root.u.def.section->output_section;
- BFD_ASSERT (bfd_is_abs_section (sec)
- || sec->owner == output_bfd);
- if (sec == obj_textsec (output_bfd))
- type = h->root.type == bfd_link_hash_defined ? N_TEXT : N_WEAKT;
- else if (sec == obj_datasec (output_bfd))
- type = h->root.type == bfd_link_hash_defined ? N_DATA : N_WEAKD;
- else if (sec == obj_bsssec (output_bfd))
- type = h->root.type == bfd_link_hash_defined ? N_BSS : N_WEAKB;
- else
- type = h->root.type == bfd_link_hash_defined ? N_ABS : N_WEAKA;
- type |= N_EXT;
- val = (h->root.u.def.value
- + sec->vma
- + h->root.u.def.section->output_offset);
- }
- break;
- case bfd_link_hash_common:
- type = N_UNDF | N_EXT;
- val = h->root.u.c.size;
- break;
- case bfd_link_hash_undefweak:
- type = N_WEAKU;
- val = 0;
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- /* FIXME: Ignore these for now. The circumstances under which
- they should be written out are not clear to me. */
- return true;
- }
-
- bfd_h_put_8 (output_bfd, type, outsym.e_type);
- bfd_h_put_8 (output_bfd, 0, outsym.e_other);
- bfd_h_put_16 (output_bfd, 0, outsym.e_desc);
- indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string,
- false);
- if (indx == (bfd_size_type) -1)
- {
- /* FIXME: No way to handle errors. */
- abort ();
- }
- PUT_WORD (output_bfd, indx, outsym.e_strx);
- PUT_WORD (output_bfd, val, outsym.e_value);
-
- if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0
- || bfd_write ((PTR) &outsym, (bfd_size_type) EXTERNAL_NLIST_SIZE,
- (bfd_size_type) 1, output_bfd) != EXTERNAL_NLIST_SIZE)
- {
- /* FIXME: No way to handle errors. */
- abort ();
- }
-
- finfo->symoff += EXTERNAL_NLIST_SIZE;
- h->indx = obj_aout_external_sym_count (output_bfd);
- ++obj_aout_external_sym_count (output_bfd);
-
- return true;
-}
-
-/* Link an a.out section into the output file. */
-
-static boolean
-aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
- rel_size)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
- asection *input_section;
- file_ptr *reloff_ptr;
- bfd_size_type rel_size;
-{
- bfd_size_type input_size;
- PTR relocs;
-
- /* Get the section contents. */
- input_size = bfd_section_size (input_bfd, input_section);
- if (! bfd_get_section_contents (input_bfd, input_section,
- (PTR) finfo->contents,
- (file_ptr) 0, input_size))
- return false;
-
- /* Read in the relocs if we haven't already done it. */
- if (aout_section_data (input_section) != NULL
- && aout_section_data (input_section)->relocs != NULL)
- relocs = aout_section_data (input_section)->relocs;
- else
- {
- relocs = finfo->relocs;
- if (rel_size > 0)
- {
- if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
- || bfd_read (relocs, 1, rel_size, input_bfd) != rel_size)
- return false;
- }
- }
-
- /* Relocate the section contents. */
- if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
- {
- if (! aout_link_input_section_std (finfo, input_bfd, input_section,
- (struct reloc_std_external *) relocs,
- rel_size, finfo->contents))
- return false;
- }
- else
- {
- if (! aout_link_input_section_ext (finfo, input_bfd, input_section,
- (struct reloc_ext_external *) relocs,
- rel_size, finfo->contents))
- return false;
- }
-
- /* Write out the section contents. */
- if (! bfd_set_section_contents (finfo->output_bfd,
- input_section->output_section,
- (PTR) finfo->contents,
- input_section->output_offset,
- input_size))
- return false;
-
- /* If we are producing relocateable output, the relocs were
- modified, and we now write them out. */
- if (finfo->info->relocateable && rel_size > 0)
- {
- if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
- return false;
- if (bfd_write (relocs, (bfd_size_type) 1, rel_size, finfo->output_bfd)
- != rel_size)
- return false;
- *reloff_ptr += rel_size;
-
- /* Assert that the relocs have not run into the symbols, and
- that if these are the text relocs they have not run into the
- data relocs. */
- BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
- && (reloff_ptr != &finfo->treloff
- || (*reloff_ptr
- <= obj_datasec (finfo->output_bfd)->rel_filepos)));
- }
-
- return true;
-}
-
-/* Get the section corresponding to a reloc index. */
-
-static INLINE asection *
-aout_reloc_index_to_section (abfd, indx)
- bfd *abfd;
- int indx;
-{
- switch (indx & N_TYPE)
- {
- case N_TEXT:
- return obj_textsec (abfd);
- case N_DATA:
- return obj_datasec (abfd);
- case N_BSS:
- return obj_bsssec (abfd);
- case N_ABS:
- case N_UNDF:
- return bfd_abs_section_ptr;
- default:
- abort ();
- }
-}
-
-/* Relocate an a.out section using standard a.out relocs. */
-
-static boolean
-aout_link_input_section_std (finfo, input_bfd, input_section, relocs,
- rel_size, contents)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
- asection *input_section;
- struct reloc_std_external *relocs;
- bfd_size_type rel_size;
- bfd_byte *contents;
-{
- boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *,
- bfd *, asection *,
- struct aout_link_hash_entry *,
- PTR, bfd_byte *, boolean *,
- bfd_vma *));
- bfd *output_bfd;
- boolean relocateable;
- struct external_nlist *syms;
- char *strings;
- struct aout_link_hash_entry **sym_hashes;
- int *symbol_map;
- bfd_size_type reloc_count;
- register struct reloc_std_external *rel;
- struct reloc_std_external *rel_end;
-
- output_bfd = finfo->output_bfd;
- check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
-
- BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE);
- BFD_ASSERT (input_bfd->xvec->header_byteorder
- == output_bfd->xvec->header_byteorder);
-
- relocateable = finfo->info->relocateable;
- syms = obj_aout_external_syms (input_bfd);
- strings = obj_aout_external_strings (input_bfd);
- sym_hashes = obj_aout_sym_hashes (input_bfd);
- symbol_map = finfo->symbol_map;
-
- reloc_count = rel_size / RELOC_STD_SIZE;
- rel = relocs;
- rel_end = rel + reloc_count;
- for (; rel < rel_end; rel++)
- {
- bfd_vma r_addr;
- int r_index;
- int r_extern;
- int r_pcrel;
- int r_baserel = 0;
- reloc_howto_type *howto;
- struct aout_link_hash_entry *h = NULL;
- bfd_vma relocation;
- bfd_reloc_status_type r;
-
- r_addr = GET_SWORD (input_bfd, rel->r_address);
-
-#ifdef MY_reloc_howto
- howto = MY_reloc_howto(input_bfd, rel, r_index, r_extern, r_pcrel);
-#else
- {
- int r_jmptable;
- int r_relative;
- int r_length;
- unsigned int howto_idx;
-
- if (bfd_header_big_endian (input_bfd))
- {
- 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 = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
- r_baserel = (0 != (rel->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));
- r_jmptable= (0 != (rel->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG));
- r_relative= (0 != (rel->r_type[0] & RELOC_STD_BITS_RELATIVE_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 = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
- r_baserel = (0 != (rel->r_type[0]
- & RELOC_STD_BITS_BASEREL_LITTLE));
- r_jmptable= (0 != (rel->r_type[0]
- & RELOC_STD_BITS_JMPTABLE_LITTLE));
- r_relative= (0 != (rel->r_type[0]
- & RELOC_STD_BITS_RELATIVE_LITTLE));
- r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
- >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
- }
-
- howto_idx = (r_length + 4 * r_pcrel + 8 * r_baserel
- + 16 * r_jmptable + 32 * r_relative);
- BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
- howto = howto_table_std + howto_idx;
- }
-#endif
-
- if (relocateable)
- {
- /* We are generating a relocateable output file, and must
- modify the reloc accordingly. */
- if (r_extern)
- {
- /* If we know the symbol this relocation is against,
- convert it into a relocation against a section. This
- is what the native linker does. */
- h = sym_hashes[r_index];
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- asection *output_section;
-
- /* Change the r_extern value. */
- if (bfd_header_big_endian (output_bfd))
- rel->r_type[0] &=~ RELOC_STD_BITS_EXTERN_BIG;
- else
- rel->r_type[0] &=~ RELOC_STD_BITS_EXTERN_LITTLE;
-
- /* Compute a new r_index. */
- output_section = h->root.u.def.section->output_section;
- if (output_section == obj_textsec (output_bfd))
- r_index = N_TEXT;
- else if (output_section == obj_datasec (output_bfd))
- r_index = N_DATA;
- else if (output_section == obj_bsssec (output_bfd))
- r_index = N_BSS;
- else
- r_index = N_ABS;
-
- /* Add the symbol value and the section VMA to the
- addend stored in the contents. */
- relocation = (h->root.u.def.value
- + output_section->vma
- + h->root.u.def.section->output_offset);
- }
- else
- {
- /* We must change r_index according to the symbol
- map. */
- r_index = symbol_map[r_index];
-
- if (r_index == -1)
- {
- if (h != NULL)
- {
- /* We decided to strip this symbol, but it
- turns out that we can't. Note that we
- lose the other and desc information here.
- I don't think that will ever matter for a
- global symbol. */
- if (h->indx < 0)
- {
- h->indx = -2;
- h->written = false;
- if (! aout_link_write_other_symbol (h,
- (PTR) finfo))
- return false;
- }
- r_index = h->indx;
- }
- else
- {
- const char *name;
-
- name = strings + GET_WORD (input_bfd,
- syms[r_index].e_strx);
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, name, input_bfd, input_section,
- r_addr)))
- return false;
- r_index = 0;
- }
- }
-
- relocation = 0;
- }
-
- /* Write out the new r_index value. */
- if (bfd_header_big_endian (output_bfd))
- {
- rel->r_index[0] = r_index >> 16;
- rel->r_index[1] = r_index >> 8;
- rel->r_index[2] = r_index;
- }
- else
- {
- rel->r_index[2] = r_index >> 16;
- rel->r_index[1] = r_index >> 8;
- rel->r_index[0] = r_index;
- }
- }
- else
- {
- asection *section;
-
- /* This is a relocation against a section. We must
- adjust by the amount that the section moved. */
- section = aout_reloc_index_to_section (input_bfd, r_index);
- relocation = (section->output_section->vma
- + section->output_offset
- - section->vma);
- }
-
- /* Change the address of the relocation. */
- PUT_WORD (output_bfd,
- r_addr + input_section->output_offset,
- rel->r_address);
-
- /* Adjust a PC relative relocation by removing the reference
- to the original address in the section and including the
- reference to the new address. */
- if (r_pcrel)
- relocation -= (input_section->output_section->vma
- + input_section->output_offset
- - input_section->vma);
-
-#ifdef MY_relocatable_reloc
- MY_relocatable_reloc (howto, output_bfd, rel, relocation, r_addr);
-#endif
-
- if (relocation == 0)
- r = bfd_reloc_ok;
- else
- r = MY_relocate_contents (howto,
- input_bfd, relocation,
- contents + r_addr);
- }
- else
- {
- boolean hundef;
-
- /* We are generating an executable, and must do a full
- relocation. */
- hundef = false;
- if (r_extern)
- {
- h = sym_hashes[r_index];
-
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- relocation = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- }
- else if (h != (struct aout_link_hash_entry *) NULL
- && h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else
- {
- hundef = true;
- relocation = 0;
- }
- }
- else
- {
- asection *section;
-
- section = aout_reloc_index_to_section (input_bfd, r_index);
- relocation = (section->output_section->vma
- + section->output_offset
- - section->vma);
- if (r_pcrel)
- relocation += input_section->vma;
- }
-
- if (check_dynamic_reloc != NULL)
- {
- boolean skip;
-
- if (! ((*check_dynamic_reloc)
- (finfo->info, input_bfd, input_section, h,
- (PTR) rel, contents, &skip, &relocation)))
- return false;
- if (skip)
- continue;
- }
-
- /* Now warn if a global symbol is undefined. We could not
- do this earlier, because check_dynamic_reloc might want
- to skip this reloc. */
- if (hundef && ! finfo->info->shared && ! r_baserel)
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
- if (! ((*finfo->info->callbacks->undefined_symbol)
- (finfo->info, name, input_bfd, input_section, r_addr)))
- return false;
- }
-
- r = MY_final_link_relocate (howto,
- input_bfd, input_section,
- contents, r_addr, 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 (r_extern)
- name = strings + GET_WORD (input_bfd,
- syms[r_index].e_strx);
- else
- {
- asection *s;
-
- s = aout_reloc_index_to_section (input_bfd, r_index);
- name = bfd_section_name (input_bfd, s);
- }
- if (! ((*finfo->info->callbacks->reloc_overflow)
- (finfo->info, name, howto->name,
- (bfd_vma) 0, input_bfd, input_section, r_addr)))
- return false;
- }
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Relocate an a.out section using extended a.out relocs. */
-
-static boolean
-aout_link_input_section_ext (finfo, input_bfd, input_section, relocs,
- rel_size, contents)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
- asection *input_section;
- struct reloc_ext_external *relocs;
- bfd_size_type rel_size;
- bfd_byte *contents;
-{
- boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *,
- bfd *, asection *,
- struct aout_link_hash_entry *,
- PTR, bfd_byte *, boolean *,
- bfd_vma *));
- bfd *output_bfd;
- boolean relocateable;
- struct external_nlist *syms;
- char *strings;
- struct aout_link_hash_entry **sym_hashes;
- int *symbol_map;
- bfd_size_type reloc_count;
- register struct reloc_ext_external *rel;
- struct reloc_ext_external *rel_end;
-
- output_bfd = finfo->output_bfd;
- check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
-
- BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_EXT_SIZE);
- BFD_ASSERT (input_bfd->xvec->header_byteorder
- == output_bfd->xvec->header_byteorder);
-
- relocateable = finfo->info->relocateable;
- syms = obj_aout_external_syms (input_bfd);
- strings = obj_aout_external_strings (input_bfd);
- sym_hashes = obj_aout_sym_hashes (input_bfd);
- symbol_map = finfo->symbol_map;
-
- reloc_count = rel_size / RELOC_EXT_SIZE;
- rel = relocs;
- rel_end = rel + reloc_count;
- for (; rel < rel_end; rel++)
- {
- bfd_vma r_addr;
- int r_index;
- int r_extern;
- unsigned int r_type;
- bfd_vma r_addend;
- struct aout_link_hash_entry *h = NULL;
- asection *r_section = NULL;
- bfd_vma relocation;
-
- r_addr = GET_SWORD (input_bfd, rel->r_address);
-
- if (bfd_header_big_endian (input_bfd))
- {
- 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);
- }
-
- r_addend = GET_SWORD (input_bfd, rel->r_addend);
-
- BFD_ASSERT (r_type < TABLE_SIZE (howto_table_ext));
-
- if (relocateable)
- {
- /* We are generating a relocateable output file, and must
- modify the reloc accordingly. */
- if (r_extern)
- {
- /* If we know the symbol this relocation is against,
- convert it into a relocation against a section. This
- is what the native linker does. */
- h = sym_hashes[r_index];
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- asection *output_section;
-
- /* Change the r_extern value. */
- if (bfd_header_big_endian (output_bfd))
- rel->r_type[0] &=~ RELOC_EXT_BITS_EXTERN_BIG;
- else
- rel->r_type[0] &=~ RELOC_EXT_BITS_EXTERN_LITTLE;
-
- /* Compute a new r_index. */
- output_section = h->root.u.def.section->output_section;
- if (output_section == obj_textsec (output_bfd))
- r_index = N_TEXT;
- else if (output_section == obj_datasec (output_bfd))
- r_index = N_DATA;
- else if (output_section == obj_bsssec (output_bfd))
- r_index = N_BSS;
- else
- r_index = N_ABS;
-
- /* Add the symbol value and the section VMA to the
- addend. */
- relocation = (h->root.u.def.value
- + output_section->vma
- + h->root.u.def.section->output_offset);
-
- /* Now RELOCATION is the VMA of the final
- destination. If this is a PC relative reloc,
- then ADDEND is the negative of the source VMA.
- We want to set ADDEND to the difference between
- the destination VMA and the source VMA, which
- means we must adjust RELOCATION by the change in
- the source VMA. This is done below. */
- }
- else
- {
- /* We must change r_index according to the symbol
- map. */
- r_index = symbol_map[r_index];
-
- if (r_index == -1)
- {
- if (h != NULL)
- {
- /* We decided to strip this symbol, but it
- turns out that we can't. Note that we
- lose the other and desc information here.
- I don't think that will ever matter for a
- global symbol. */
- if (h->indx < 0)
- {
- h->indx = -2;
- h->written = false;
- if (! aout_link_write_other_symbol (h,
- (PTR) finfo))
- return false;
- }
- r_index = h->indx;
- }
- else
- {
- const char *name;
-
- name = strings + GET_WORD (input_bfd,
- syms[r_index].e_strx);
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, name, input_bfd, input_section,
- r_addr)))
- return false;
- r_index = 0;
- }
- }
-
- relocation = 0;
-
- /* If this is a PC relative reloc, then the addend
- is the negative of the source VMA. We must
- adjust it by the change in the source VMA. This
- is done below. */
- }
-
- /* Write out the new r_index value. */
- if (bfd_header_big_endian (output_bfd))
- {
- rel->r_index[0] = r_index >> 16;
- rel->r_index[1] = r_index >> 8;
- rel->r_index[2] = r_index;
- }
- else
- {
- rel->r_index[2] = r_index >> 16;
- rel->r_index[1] = r_index >> 8;
- rel->r_index[0] = r_index;
- }
- }
- else
- {
- /* This is a relocation against a section. We must
- adjust by the amount that the section moved. */
- r_section = aout_reloc_index_to_section (input_bfd, r_index);
- relocation = (r_section->output_section->vma
- + r_section->output_offset
- - r_section->vma);
-
- /* If this is a PC relative reloc, then the addend is
- the difference in VMA between the destination and the
- source. We have just adjusted for the change in VMA
- of the destination, so we must also adjust by the
- change in VMA of the source. This is done below. */
- }
-
- /* As described above, we must always adjust a PC relative
- reloc by the change in VMA of the source. */
- if (howto_table_ext[r_type].pc_relative)
- relocation -= (input_section->output_section->vma
- + input_section->output_offset
- - input_section->vma);
-
- /* Change the addend if necessary. */
- if (relocation != 0)
- PUT_WORD (output_bfd, r_addend + relocation, rel->r_addend);
-
- /* Change the address of the relocation. */
- PUT_WORD (output_bfd,
- r_addr + input_section->output_offset,
- rel->r_address);
- }
- else
- {
- boolean hundef;
- bfd_reloc_status_type r;
-
- /* We are generating an executable, and must do a full
- relocation. */
- hundef = false;
- if (r_extern)
- {
- h = sym_hashes[r_index];
-
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- relocation = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- }
- else if (h != (struct aout_link_hash_entry *) NULL
- && h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else
- {
- hundef = true;
- relocation = 0;
- }
- }
- else if (r_type == RELOC_BASE10
- || r_type == RELOC_BASE13
- || r_type == RELOC_BASE22)
- {
- struct external_nlist *sym;
- int type;
-
- /* For base relative relocs, r_index is always an index
- into the symbol table, even if r_extern is 0. */
- sym = syms + r_index;
- type = bfd_h_get_8 (input_bfd, sym->e_type);
- if ((type & N_TYPE) == N_TEXT
- || type == N_WEAKT)
- r_section = obj_textsec (input_bfd);
- else if ((type & N_TYPE) == N_DATA
- || type == N_WEAKD)
- r_section = obj_datasec (input_bfd);
- else if ((type & N_TYPE) == N_BSS
- || type == N_WEAKB)
- r_section = obj_bsssec (input_bfd);
- else if ((type & N_TYPE) == N_ABS
- || type == N_WEAKA)
- r_section = bfd_abs_section_ptr;
- else
- abort ();
- relocation = (r_section->output_section->vma
- + r_section->output_offset
- + (GET_WORD (input_bfd, sym->e_value)
- - r_section->vma));
- }
- else
- {
- r_section = aout_reloc_index_to_section (input_bfd, r_index);
-
- /* If this is a PC relative reloc, then R_ADDEND is the
- difference between the two vmas, or
- old_dest_sec + old_dest_off - (old_src_sec + old_src_off)
- where
- old_dest_sec == section->vma
- and
- old_src_sec == input_section->vma
- and
- old_src_off == r_addr
-
- _bfd_final_link_relocate expects RELOCATION +
- R_ADDEND to be the VMA of the destination minus
- r_addr (the minus r_addr is because this relocation
- is not pcrel_offset, which is a bit confusing and
- should, perhaps, be changed), or
- new_dest_sec
- where
- new_dest_sec == output_section->vma + output_offset
- We arrange for this to happen by setting RELOCATION to
- new_dest_sec + old_src_sec - old_dest_sec
-
- If this is not a PC relative reloc, then R_ADDEND is
- simply the VMA of the destination, so we set
- RELOCATION to the change in the destination VMA, or
- new_dest_sec - old_dest_sec
- */
- relocation = (r_section->output_section->vma
- + r_section->output_offset
- - r_section->vma);
- if (howto_table_ext[r_type].pc_relative)
- relocation += input_section->vma;
- }
-
- if (check_dynamic_reloc != NULL)
- {
- boolean skip;
-
- if (! ((*check_dynamic_reloc)
- (finfo->info, input_bfd, input_section, h,
- (PTR) rel, contents, &skip, &relocation)))
- return false;
- if (skip)
- continue;
- }
-
- /* Now warn if a global symbol is undefined. We could not
- do this earlier, because check_dynamic_reloc might want
- to skip this reloc. */
- if (hundef
- && ! finfo->info->shared
- && r_type != RELOC_BASE10
- && r_type != RELOC_BASE13
- && r_type != RELOC_BASE22)
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
- if (! ((*finfo->info->callbacks->undefined_symbol)
- (finfo->info, name, input_bfd, input_section, r_addr)))
- return false;
- }
-
- r = MY_final_link_relocate (howto_table_ext + r_type,
- input_bfd, input_section,
- contents, r_addr, relocation,
- r_addend);
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (r_extern
- || r_type == RELOC_BASE10
- || r_type == RELOC_BASE13
- || r_type == RELOC_BASE22)
- name = strings + GET_WORD (input_bfd,
- syms[r_index].e_strx);
- else
- {
- asection *s;
-
- s = aout_reloc_index_to_section (input_bfd, r_index);
- name = bfd_section_name (input_bfd, s);
- }
- if (! ((*finfo->info->callbacks->reloc_overflow)
- (finfo->info, name, howto_table_ext[r_type].name,
- r_addend, input_bfd, input_section, r_addr)))
- return false;
- }
- break;
- }
- }
- }
- }
-
- return true;
-}
-
-/* Handle a link order which is supposed to generate a reloc. */
-
-static boolean
-aout_link_reloc_link_order (finfo, o, p)
- struct aout_final_link_info *finfo;
- asection *o;
- struct bfd_link_order *p;
-{
- struct bfd_link_order_reloc *pr;
- int r_index;
- int r_extern;
- reloc_howto_type *howto;
- file_ptr *reloff_ptr;
- struct reloc_std_external srel;
- struct reloc_ext_external erel;
- PTR rel_ptr;
-
- pr = p->u.reloc.p;
-
- if (p->type == bfd_section_reloc_link_order)
- {
- r_extern = 0;
- if (bfd_is_abs_section (pr->u.section))
- r_index = N_ABS | N_EXT;
- else
- {
- BFD_ASSERT (pr->u.section->owner == finfo->output_bfd);
- r_index = pr->u.section->target_index;
- }
- }
- else
- {
- struct aout_link_hash_entry *h;
-
- BFD_ASSERT (p->type == bfd_symbol_reloc_link_order);
- r_extern = 1;
- h = ((struct aout_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (finfo->output_bfd, finfo->info,
- pr->u.name, false, false, true));
- if (h != (struct aout_link_hash_entry *) NULL
- && h->indx >= 0)
- r_index = h->indx;
- else if (h != NULL)
- {
- /* We decided to strip this symbol, but it turns out that we
- can't. Note that we lose the other and desc information
- here. I don't think that will ever matter for a global
- symbol. */
- h->indx = -2;
- h->written = false;
- if (! aout_link_write_other_symbol (h, (PTR) finfo))
- return false;
- r_index = h->indx;
- }
- else
- {
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, pr->u.name, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- return false;
- r_index = 0;
- }
- }
-
- howto = bfd_reloc_type_lookup (finfo->output_bfd, pr->reloc);
- if (howto == 0)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- if (o == obj_textsec (finfo->output_bfd))
- reloff_ptr = &finfo->treloff;
- else if (o == obj_datasec (finfo->output_bfd))
- reloff_ptr = &finfo->dreloff;
- else
- abort ();
-
- if (obj_reloc_entry_size (finfo->output_bfd) == RELOC_STD_SIZE)
- {
-#ifdef MY_put_reloc
- MY_put_reloc(finfo->output_bfd, r_extern, r_index, p->offset, howto,
- &srel);
-#else
- {
- int r_pcrel;
- int r_baserel;
- int r_jmptable;
- int r_relative;
- int r_length;
-
- r_pcrel = howto->pc_relative;
- r_baserel = (howto->type & 8) != 0;
- r_jmptable = (howto->type & 16) != 0;
- r_relative = (howto->type & 32) != 0;
- r_length = howto->size;
-
- PUT_WORD (finfo->output_bfd, p->offset, srel.r_address);
- if (bfd_header_big_endian (finfo->output_bfd))
- {
- srel.r_index[0] = r_index >> 16;
- srel.r_index[1] = r_index >> 8;
- srel.r_index[2] = r_index;
- srel.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
- {
- srel.r_index[2] = r_index >> 16;
- srel.r_index[1] = r_index >> 8;
- srel.r_index[0] = r_index;
- srel.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));
- }
- }
-#endif
- rel_ptr = (PTR) &srel;
-
- /* We have to write the addend into the object file, since
- standard a.out relocs are in place. It would be more
- reliable if we had the current contents of the file here,
- rather than assuming zeroes, but we can't read the file since
- it was opened using bfd_openw. */
- if (pr->addend != 0)
- {
- bfd_size_type size;
- bfd_reloc_status_type r;
- bfd_byte *buf;
- boolean ok;
-
- size = bfd_get_reloc_size (howto);
- buf = (bfd_byte *) bfd_zmalloc (size);
- if (buf == (bfd_byte *) NULL)
- return false;
- r = MY_relocate_contents (howto, finfo->output_bfd,
- pr->addend, buf);
- switch (r)
- {
- case bfd_reloc_ok:
- break;
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- if (! ((*finfo->info->callbacks->reloc_overflow)
- (finfo->info,
- (p->type == bfd_section_reloc_link_order
- ? bfd_section_name (finfo->output_bfd,
- pr->u.section)
- : pr->u.name),
- howto->name, pr->addend, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- {
- free (buf);
- return false;
- }
- break;
- }
- ok = bfd_set_section_contents (finfo->output_bfd, o,
- (PTR) buf,
- (file_ptr) p->offset,
- size);
- free (buf);
- if (! ok)
- return false;
- }
- }
- else
- {
- PUT_WORD (finfo->output_bfd, p->offset, erel.r_address);
-
- if (bfd_header_big_endian (finfo->output_bfd))
- {
- erel.r_index[0] = r_index >> 16;
- erel.r_index[1] = r_index >> 8;
- erel.r_index[2] = r_index;
- erel.r_type[0] =
- ((r_extern ? RELOC_EXT_BITS_EXTERN_BIG : 0)
- | (howto->type << RELOC_EXT_BITS_TYPE_SH_BIG));
- }
- else
- {
- erel.r_index[2] = r_index >> 16;
- erel.r_index[1] = r_index >> 8;
- erel.r_index[0] = r_index;
- erel.r_type[0] =
- (r_extern ? RELOC_EXT_BITS_EXTERN_LITTLE : 0)
- | (howto->type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
- }
-
- PUT_WORD (finfo->output_bfd, pr->addend, erel.r_addend);
-
- rel_ptr = (PTR) &erel;
- }
-
- if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
- || (bfd_write (rel_ptr, (bfd_size_type) 1,
- obj_reloc_entry_size (finfo->output_bfd),
- finfo->output_bfd)
- != obj_reloc_entry_size (finfo->output_bfd)))
- return false;
-
- *reloff_ptr += obj_reloc_entry_size (finfo->output_bfd);
-
- /* Assert that the relocs have not run into the symbols, and that n
- the text relocs have not run into the data relocs. */
- BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
- && (reloff_ptr != &finfo->treloff
- || (*reloff_ptr
- <= obj_datasec (finfo->output_bfd)->rel_filepos)));
-
- return true;
-}
diff --git a/contrib/gdb/bfd/archive.c b/contrib/gdb/bfd/archive.c
deleted file mode 100644
index 248b9181e75e..000000000000
--- a/contrib/gdb/bfd/archive.c
+++ /dev/null
@@ -1,2094 +0,0 @@
-/* BFD back-end for archive files (libraries).
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-@setfilename archive-info
-SECTION
- Archives
-
-DESCRIPTION
- An archive (or library) is just another BFD. It has a symbol
- table, although there's not much a user program will do with it.
-
- The big difference between an archive BFD and an ordinary BFD
- is that the archive doesn't have sections. Instead it has a
- chain of BFDs that are considered its contents. These BFDs can
- be manipulated like any other. The BFDs contained in an
- archive opened for reading will all be opened for reading. You
- may put either input or output BFDs into an archive opened for
- output; they will be handled correctly when the archive is closed.
-
- Use <<bfd_openr_next_archived_file>> to step through
- the contents of an archive opened for input. You don't
- have to read the entire archive if you don't want
- to! Read it until you find what you want.
-
- Archive contents of output BFDs are chained through the
- <<next>> pointer in a BFD. The first one is findable through
- the <<archive_head>> slot of the archive. Set it with
- <<bfd_set_archive_head>> (q.v.). A given BFD may be in only one
- open output archive at a time.
-
- As expected, the BFD archive code is more general than the
- archive code of any given environment. BFD archives may
- contain files of different formats (e.g., a.out and coff) and
- even different architectures. You may even place archives
- recursively into archives!
-
- This can cause unexpected confusion, since some archive
- formats are more expressive than others. For instance, Intel
- COFF archives can preserve long filenames; SunOS a.out archives
- cannot. If you move a file from the first to the second
- format and back again, the filename may be truncated.
- Likewise, different a.out environments have different
- conventions as to how they truncate filenames, whether they
- preserve directory names in filenames, etc. When
- interoperating with native tools, be sure your files are
- homogeneous.
-
- Beware: most of these formats do not react well to the
- presence of spaces in filenames. We do the best we can, but
- can't always handle this case due to restrictions in the format of
- archives. Many Unix utilities are braindead in regards to
- spaces and such in filenames anyway, so this shouldn't be much
- of a restriction.
-
- Archives are supported in BFD in <<archive.c>>.
-
-*/
-
-/* Assumes:
- o - all archive elements start on an even boundary, newline padded;
- o - all arch headers are char *;
- o - all arch headers are the same size (across architectures).
-*/
-
-/* Some formats provide a way to cram a long filename into the short
- (16 chars) space provided by a BSD archive. The trick is: make a
- special "file" in the front of the archive, sort of like the SYMDEF
- entry. If the filename is too long to fit, put it in the extended
- name table, and use its index as the filename. To prevent
- confusion prepend the index with a space. This means you can't
- have filenames that start with a space, but then again, many Unix
- utilities can't handle that anyway.
-
- This scheme unfortunately requires that you stand on your head in
- order to write an archive since you need to put a magic file at the
- front, and need to touch every entry to do so. C'est la vie.
-
- We support two variants of this idea:
- The SVR4 format (extended name table is named "//"),
- and an extended pseudo-BSD variant (extended name table is named
- "ARFILENAMES/"). The origin of the latter format is uncertain.
-
- BSD 4.4 uses a third scheme: It writes a long filename
- directly after the header. This allows 'ar q' to work.
- We currently can read BSD 4.4 archives, but not write them.
-*/
-
-/* Summary of archive member names:
-
- Symbol table (must be first):
- "__.SYMDEF " - Symbol table, Berkeley style, produced by ranlib.
- "/ " - Symbol table, system 5 style.
-
- Long name table (must be before regular file members):
- "// " - Long name table, System 5 R4 style.
- "ARFILENAMES/ " - Long name table, non-standard extended BSD (not BSD 4.4).
-
- Regular file members with short names:
- "filename.o/ " - Regular file, System 5 style (embedded spaces ok).
- "filename.o " - Regular file, Berkeley style (no embedded spaces).
-
- Regular files with long names (or embedded spaces, for BSD variants):
- "/18 " - SVR4 style, name at offset 18 in name table.
- "#1/23 " - Long name (or embedded paces) 23 characters long,
- BSD 4.4 style, full name follows header.
- Implemented for reading, not writing.
- " 18 " - Long name 18 characters long, extended pseudo-BSD.
- */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "aout/ar.h"
-#include "aout/ranlib.h"
-#include <errno.h>
-#include <string.h> /* For memchr, strrchr and friends */
-#include <ctype.h>
-
-#ifndef errno
-extern int errno;
-#endif
-
-#ifdef GNU960
-#define BFD_GNU960_ARMAG(abfd) (BFD_COFF_FILE_P((abfd)) ? ARMAG : ARMAGB)
-#endif
-
-/* Can't define this in hosts/foo.h, because (e.g. in gprof) the hosts file
- is included, then obstack.h, which thinks if offsetof is defined, it
- doesn't need to include stddef.h. */
-/* Define offsetof for those systems which lack it */
-
-#if !defined (offsetof)
-#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
-#endif
-
-/* We keep a cache of archive filepointers to archive elements to
- speed up searching the archive by filepos. We only add an entry to
- the cache when we actually read one. We also don't sort the cache;
- it's generally short enough to search linearly.
- Note that the pointers here point to the front of the ar_hdr, not
- to the front of the contents!
-*/
-struct ar_cache
-{
- file_ptr ptr;
- bfd *arelt;
- struct ar_cache *next;
-};
-
-#define ar_padchar(abfd) ((abfd)->xvec->ar_pad_char)
-#define ar_maxnamelen(abfd) ((abfd)->xvec->ar_max_namelen)
-
-#define arch_eltdata(bfd) ((struct areltdata *)((bfd)->arelt_data))
-#define arch_hdr(bfd) ((struct ar_hdr *)arch_eltdata(bfd)->arch_header)
-
-static char *get_extended_arelt_filename PARAMS ((bfd *arch,
- const char *name));
-static boolean do_slurp_bsd_armap PARAMS ((bfd *abfd));
-static boolean do_slurp_coff_armap PARAMS ((bfd *abfd));
-static const char *normalize PARAMS ((bfd *, const char *file));
-static struct areltdata *bfd_ar_hdr_from_filesystem PARAMS ((bfd *abfd,
- const char *));
-
-boolean
-_bfd_generic_mkarchive (abfd)
- bfd *abfd;
-{
- abfd->tdata.aout_ar_data = ((struct artdata *)
- bfd_zalloc (abfd, sizeof (struct artdata)));
-
- if (bfd_ardata (abfd) == NULL)
- return false;
-
- 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 = NULL;
-
- return true;
-}
-
-/*
-FUNCTION
- bfd_get_next_mapent
-
-SYNOPSIS
- symindex bfd_get_next_mapent(bfd *abfd, symindex previous, carsym **sym);
-
-DESCRIPTION
- Step through archive @var{abfd}'s symbol table (if it
- has one). Successively update @var{sym} with the next symbol's
- information, returning that symbol's (internal) index into the
- symbol table.
-
- Supply <<BFD_NO_MORE_SYMBOLS>> as the @var{previous} entry to get
- the first one; returns <<BFD_NO_MORE_SYMBOLS>> when you've already
- got the last one.
-
- A <<carsym>> is a canonical archive symbol. The only
- user-visible element is its name, a null-terminated string.
-*/
-
-symindex
-bfd_get_next_mapent (abfd, prev, entry)
- bfd *abfd;
- symindex prev;
- carsym **entry;
-{
- if (!bfd_has_map (abfd))
- {
- bfd_set_error (bfd_error_invalid_operation);
- return BFD_NO_MORE_SYMBOLS;
- }
-
- if (prev == BFD_NO_MORE_SYMBOLS)
- prev = 0;
- else
- ++prev;
- if (prev >= bfd_ardata (abfd)->symdef_count)
- return BFD_NO_MORE_SYMBOLS;
-
- *entry = (bfd_ardata (abfd)->symdefs + prev);
- return prev;
-}
-
-/* To be called by backends only */
-
-bfd *
-_bfd_create_empty_archive_element_shell (obfd)
- bfd *obfd;
-{
- return _bfd_new_bfd_contained_in (obfd);
-}
-
-/*
-FUNCTION
- bfd_set_archive_head
-
-SYNOPSIS
- boolean bfd_set_archive_head(bfd *output, bfd *new_head);
-
-DESCRIPTION
- Set the head of the chain of
- BFDs contained in the archive @var{output} to @var{new_head}.
-*/
-
-boolean
-bfd_set_archive_head (output_archive, new_head)
- bfd *output_archive;
- bfd *new_head;
-{
-
- output_archive->archive_head = new_head;
- return true;
-}
-
-bfd *
-_bfd_look_for_bfd_in_cache (arch_bfd, filepos)
- bfd *arch_bfd;
- file_ptr filepos;
-{
- struct ar_cache *current;
-
- for (current = bfd_ardata (arch_bfd)->cache; current != NULL;
- current = current->next)
- if (current->ptr == filepos)
- return current->arelt;
-
- return NULL;
-}
-
-/* Kind of stupid to call cons for each one, but we don't do too many */
-boolean
-_bfd_add_bfd_to_archive_cache (arch_bfd, filepos, new_elt)
- bfd *arch_bfd, *new_elt;
- file_ptr filepos;
-{
- struct ar_cache *new_cache = ((struct ar_cache *)
- bfd_zalloc (arch_bfd,
- sizeof (struct ar_cache)));
-
- if (new_cache == NULL)
- return false;
-
- new_cache->ptr = filepos;
- new_cache->arelt = new_elt;
- new_cache->next = (struct ar_cache *) NULL;
- if (bfd_ardata (arch_bfd)->cache == NULL)
- bfd_ardata (arch_bfd)->cache = new_cache;
- else
- {
- struct ar_cache *current = bfd_ardata (arch_bfd)->cache;
-
- while (current->next != NULL)
- current = current->next;
- current->next = new_cache;
- }
-
- return true;
-}
-
-/* The name begins with space. Hence the rest of the name is an index into
- the string table. */
-
-static char *
-get_extended_arelt_filename (arch, name)
- bfd *arch;
- const char *name;
-{
- unsigned long index = 0;
-
- /* Should extract string so that I can guarantee not to overflow into
- the next region, but I'm too lazy. */
- errno = 0;
- /* Skip first char, which is '/' in SVR4 or ' ' in some other variants. */
- index = strtol (name + 1, NULL, 10);
- if (errno != 0)
- {
- bfd_set_error (bfd_error_malformed_archive);
- return NULL;
- }
-
- return bfd_ardata (arch)->extended_names + index;
-}
-
-/* This functions reads an arch header and returns an areltdata pointer, or
- NULL on error.
-
- Presumes the file pointer is already in the right place (ie pointing
- to the ar_hdr in the file). Moves the file pointer; on success it
- should be pointing to the front of the file contents; on failure it
- could have been moved arbitrarily.
-*/
-
-PTR
-_bfd_generic_read_ar_hdr (abfd)
- bfd *abfd;
-{
- return _bfd_generic_read_ar_hdr_mag (abfd, (const char *) NULL);
-}
-
-/* Alpha ECOFF uses an optional different ARFMAG value, so we have a
- variant of _bfd_generic_read_ar_hdr which accepts a magic string. */
-
-PTR
-_bfd_generic_read_ar_hdr_mag (abfd, mag)
- bfd *abfd;
- const char *mag;
-{
- struct ar_hdr hdr;
- char *hdrp = (char *) &hdr;
- unsigned int parsed_size;
- struct areltdata *ared;
- char *filename = NULL;
- unsigned int namelen = 0;
- unsigned int allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr);
- char *allocptr = 0;
-
- if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_no_more_archived_files);
- return NULL;
- }
- if (strncmp (hdr.ar_fmag, ARFMAG, 2) != 0
- && (mag == NULL
- || strncmp (hdr.ar_fmag, mag, 2) != 0))
- {
- bfd_set_error (bfd_error_malformed_archive);
- return NULL;
- }
-
- errno = 0;
- parsed_size = strtol (hdr.ar_size, NULL, 10);
- if (errno != 0)
- {
- bfd_set_error (bfd_error_malformed_archive);
- return NULL;
- }
-
- /* Extract the filename from the archive - there are two ways to
- specify an extendend name table, either the first char of the
- name is a space, or it's a slash. */
- if ((hdr.ar_name[0] == '/'
- || (hdr.ar_name[0] == ' '
- && memchr (hdr.ar_name, '/', ar_maxnamelen (abfd)) == NULL))
- && bfd_ardata (abfd)->extended_names != NULL)
- {
- filename = get_extended_arelt_filename (abfd, hdr.ar_name);
- if (filename == NULL)
- {
- bfd_set_error (bfd_error_malformed_archive);
- return NULL;
- }
- }
- /* BSD4.4-style long filename.
- Only implemented for reading, so far! */
- else if (hdr.ar_name[0] == '#' && hdr.ar_name[1] == '1'
- && hdr.ar_name[2] == '/' && isdigit (hdr.ar_name[3]))
- {
- /* BSD-4.4 extended name */
- namelen = atoi (&hdr.ar_name[3]);
- allocsize += namelen + 1;
- parsed_size -= namelen;
-
- allocptr = bfd_zalloc (abfd, allocsize);
- if (allocptr == NULL)
- return NULL;
- filename = (allocptr
- + sizeof (struct areltdata)
- + sizeof (struct ar_hdr));
- if (bfd_read (filename, 1, namelen, abfd) != namelen)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_no_more_archived_files);
- return NULL;
- }
- filename[namelen] = '\0';
- }
- else
- {
- /* We judge the end of the name by looking for '/' or ' '.
- Note: The SYSV format (terminated by '/') allows embedded
- spaces, so only look for ' ' if we don't find '/'. */
-
- namelen = 0;
- while (hdr.ar_name[namelen] != '\0' &&
- hdr.ar_name[namelen] != '/')
- {
- namelen++;
- if (namelen == (unsigned) ar_maxnamelen (abfd))
- {
- namelen = 0;
- while (hdr.ar_name[namelen] != ' '
- && namelen < (unsigned) ar_maxnamelen (abfd))
- namelen++;
- break;
- }
- }
-
- allocsize += namelen + 1;
- }
-
- if (!allocptr)
- {
- allocptr = bfd_zalloc (abfd, allocsize);
- if (allocptr == NULL)
- return NULL;
- }
-
- ared = (struct areltdata *) allocptr;
-
- ared->arch_header = allocptr + sizeof (struct areltdata);
- memcpy ((char *) ared->arch_header, (char *) &hdr, sizeof (struct ar_hdr));
- ared->parsed_size = parsed_size;
-
- if (filename != NULL)
- ared->filename = filename;
- else
- {
- ared->filename = allocptr + (sizeof (struct areltdata) +
- sizeof (struct ar_hdr));
- if (namelen)
- memcpy (ared->filename, hdr.ar_name, namelen);
- ared->filename[namelen] = '\0';
- }
-
- return (PTR) ared;
-}
-
-/* This is an internal function; it's mainly used when indexing
- through the archive symbol table, but also used to get the next
- element, since it handles the bookkeeping so nicely for us. */
-
-bfd *
-_bfd_get_elt_at_filepos (archive, filepos)
- bfd *archive;
- file_ptr filepos;
-{
- struct areltdata *new_areldata;
- bfd *n_nfd;
-
- n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);
- if (n_nfd)
- return n_nfd;
-
- if (0 > bfd_seek (archive, filepos, SEEK_SET))
- return NULL;
-
- if ((new_areldata = (struct areltdata *) _bfd_read_ar_hdr (archive)) == NULL)
- return NULL;
-
- n_nfd = _bfd_create_empty_archive_element_shell (archive);
- if (n_nfd == NULL)
- {
- bfd_release (archive, (PTR) new_areldata);
- return NULL;
- }
-
- n_nfd->origin = bfd_tell (archive);
- n_nfd->arelt_data = (PTR) new_areldata;
- n_nfd->filename = new_areldata->filename;
-
- if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_nfd))
- return n_nfd;
-
- /* huh? */
- bfd_release (archive, (PTR) n_nfd);
- bfd_release (archive, (PTR) new_areldata);
- return NULL;
-}
-
-/* Return the BFD which is referenced by the symbol in ABFD indexed by
- INDEX. INDEX should have been returned by bfd_get_next_mapent. */
-
-bfd *
-_bfd_generic_get_elt_at_index (abfd, index)
- bfd *abfd;
- symindex index;
-{
- carsym *entry;
-
- entry = bfd_ardata (abfd)->symdefs + index;
- return _bfd_get_elt_at_filepos (abfd, entry->file_offset);
-}
-
-/*
-FUNCTION
- bfd_openr_next_archived_file
-
-SYNOPSIS
- bfd *bfd_openr_next_archived_file(bfd *archive, bfd *previous);
-
-DESCRIPTION
- Provided a BFD, @var{archive}, containing an archive and NULL, open
- an input BFD on the first contained element and returns that.
- Subsequent calls should pass
- the archive and the previous return value to return a created
- BFD to the next contained element. NULL is returned when there
- are no more.
-
-*/
-
-bfd *
-bfd_openr_next_archived_file (archive, last_file)
- bfd *archive;
- bfd *last_file;
-{
- if ((bfd_get_format (archive) != bfd_archive) ||
- (archive->direction == write_direction))
- {
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
- }
-
- return BFD_SEND (archive,
- openr_next_archived_file,
- (archive,
- last_file));
-}
-
-bfd *
-bfd_generic_openr_next_archived_file (archive, last_file)
- bfd *archive;
- bfd *last_file;
-{
- file_ptr filestart;
-
- if (!last_file)
- filestart = bfd_ardata (archive)->first_file_filepos;
- else
- {
- unsigned int size = arelt_size (last_file);
- /* Pad to an even boundary...
- 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 _bfd_get_elt_at_filepos (archive, filestart);
-}
-
-
-const bfd_target *
-bfd_generic_archive_p (abfd)
- bfd *abfd;
-{
- struct artdata *tdata_hold;
- char armag[SARMAG + 1];
-
- tdata_hold = abfd->tdata.aout_ar_data;
-
- if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
-#ifdef GNU960
- if (strncmp (armag, BFD_GNU960_ARMAG (abfd), SARMAG) != 0)
- return 0;
-#else
- if (strncmp (armag, ARMAG, SARMAG) != 0 &&
- strncmp (armag, ARMAGB, SARMAG) != 0)
- return 0;
-#endif
-
- /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
- involves a cast, we can't do it as the left operand of assignment. */
- abfd->tdata.aout_ar_data = ((struct artdata *)
- bfd_zalloc (abfd, sizeof (struct artdata)));
-
- if (bfd_ardata (abfd) == NULL)
- return NULL;
-
- bfd_ardata (abfd)->first_file_filepos = SARMAG;
- 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 = NULL;
-
- if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)))
- {
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = tdata_hold;
- return NULL;
- }
-
- if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))
- {
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = tdata_hold;
- return NULL;
- }
-
- if (bfd_has_map (abfd))
- {
- bfd *first;
-
- /* This archive has a map, so we may presume that the contents
- are object files. Make sure that if the first file in the
- archive can be recognized as an object file, it is for this
- target. If not, assume that this is the wrong format. If
- the first file is not an object file, somebody is doing
- something weird, and we permit it so that ar -t will work.
-
- This is done because any normal format will recognize any
- normal archive, regardless of the format of the object files.
- We do accept an empty archive. */
-
- first = bfd_openr_next_archived_file (abfd, (bfd *) NULL);
- if (first != NULL)
- {
- boolean fail;
-
- first->target_defaulted = false;
- fail = false;
- if (bfd_check_format (first, bfd_object)
- && first->xvec != abfd->xvec)
- {
- (void) bfd_close (first);
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = tdata_hold;
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* We ought to close first here, but we can't, because we
- have no way to remove it from the archive cache. FIXME. */
- }
- }
-
- return abfd->xvec;
-}
-
-/* Some constants for a 32 bit BSD archive structure. We do not
- support 64 bit archives presently; so far as I know, none actually
- exist. Supporting them would require changing these constants, and
- changing some bfd_h_get_32 to bfd_h_get_64. */
-
-/* The size of an external symdef structure. */
-#define BSD_SYMDEF_SIZE 8
-
-/* The offset from the start of a symdef structure to the file offset. */
-#define BSD_SYMDEF_OFFSET_SIZE 4
-
-/* The size of the symdef count. */
-#define BSD_SYMDEF_COUNT_SIZE 4
-
-/* The size of the string count. */
-#define BSD_STRING_COUNT_SIZE 4
-
-/* Returns false on error, true otherwise */
-
-static boolean
-do_slurp_bsd_armap (abfd)
- bfd *abfd;
-{
- struct areltdata *mapdata;
- unsigned int counter;
- bfd_byte *raw_armap, *rbase;
- struct artdata *ardata = bfd_ardata (abfd);
- char *stringbase;
- unsigned int parsed_size;
- carsym *set;
-
- mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (mapdata == NULL)
- return false;
- parsed_size = mapdata->parsed_size;
- bfd_release (abfd, (PTR) mapdata); /* Don't need it any more. */
-
- raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
- if (raw_armap == (bfd_byte *) NULL)
- return false;
-
- if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- byebye:
- bfd_release (abfd, (PTR) raw_armap);
- return false;
- }
-
- ardata->symdef_count = bfd_h_get_32 (abfd, raw_armap) / BSD_SYMDEF_SIZE;
-
- if (ardata->symdef_count * BSD_SYMDEF_SIZE >
- parsed_size - BSD_SYMDEF_COUNT_SIZE)
- {
- /* Probably we're using the wrong byte ordering. */
- bfd_set_error (bfd_error_wrong_format);
- goto byebye;
- }
-
- ardata->cache = 0;
- rbase = raw_armap + BSD_SYMDEF_COUNT_SIZE;
- stringbase = ((char *) rbase
- + ardata->symdef_count * BSD_SYMDEF_SIZE
- + BSD_STRING_COUNT_SIZE);
- ardata->symdefs = (carsym *) bfd_alloc (abfd,
- (ardata->symdef_count
- * sizeof (carsym)));
- if (!ardata->symdefs)
- return false;
-
- for (counter = 0, set = ardata->symdefs;
- counter < ardata->symdef_count;
- counter++, set++, rbase += BSD_SYMDEF_SIZE)
- {
- set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
- set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
- }
-
- ardata->first_file_filepos = bfd_tell (abfd);
- /* Pad to an even boundary if you have to */
- ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
- /* FIXME, we should provide some way to free raw_ardata when
- we are done using the strings from it. For now, it seems
- to be allocated on an obstack anyway... */
- bfd_has_map (abfd) = true;
- return true;
-}
-
-/* Returns false on error, true otherwise */
-static boolean
-do_slurp_coff_armap (abfd)
- bfd *abfd;
-{
- struct areltdata *mapdata;
- int *raw_armap, *rawptr;
- struct artdata *ardata = bfd_ardata (abfd);
- char *stringbase;
- unsigned int stringsize;
- unsigned int parsed_size;
- carsym *carsyms;
- unsigned int nsymz; /* Number of symbols in armap. */
- bfd_vma (*swap) PARAMS ((const bfd_byte *));
- char int_buf[sizeof (long)];
- unsigned int carsym_size, ptrsize, i;
-
- mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (mapdata == NULL)
- return false;
- parsed_size = mapdata->parsed_size;
- bfd_release (abfd, (PTR) mapdata); /* Don't need it any more. */
-
- if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- return false;
- }
- /* It seems that all numeric information in a coff archive is always
- in big endian format, nomatter the host or target. */
- swap = bfd_getb32;
- nsymz = bfd_getb32 ((PTR) int_buf);
- stringsize = parsed_size - (4 * nsymz) - 4;
-
-#if 1
- /* ... except that some archive formats are broken, and it may be our
- fault - the i960 little endian coff sometimes has big and sometimes
- little, because our tools changed. Here's a horrible hack to clean
- up the crap. */
-
- if (stringsize > 0xfffff)
- {
- /* This looks dangerous, let's do it the other way around */
- nsymz = bfd_getl32 ((PTR) int_buf);
- stringsize = parsed_size - (4 * nsymz) - 4;
- swap = bfd_getl32;
- }
-#endif
-
- /* The coff armap must be read sequentially. So we construct a
- bsd-style one in core all at once, for simplicity. */
-
- carsym_size = (nsymz * sizeof (carsym));
- ptrsize = (4 * nsymz);
-
- ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
- if (ardata->symdefs == NULL)
- return false;
- carsyms = ardata->symdefs;
- stringbase = ((char *) ardata->symdefs) + carsym_size;
-
- /* Allocate and read in the raw offsets. */
- raw_armap = (int *) bfd_alloc (abfd, ptrsize);
- if (raw_armap == NULL)
- goto release_symdefs;
- if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
- || bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- goto release_raw_armap;
- }
-
- /* OK, build the carsyms */
- for (i = 0; i < nsymz; i++)
- {
- rawptr = raw_armap + i;
- carsyms->file_offset = swap ((PTR) rawptr);
- carsyms->name = stringbase;
- stringbase += strlen (stringbase) + 1;
- carsyms++;
- }
- *stringbase = 0;
-
- ardata->symdef_count = nsymz;
- ardata->first_file_filepos = bfd_tell (abfd);
- /* Pad to an even boundary if you have to */
- ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
-
-
- bfd_has_map (abfd) = true;
- bfd_release (abfd, (PTR) raw_armap);
-
-
- /* Check for a second archive header (as used by PE) */
- {
- struct areltdata *tmp;
-
- bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET);
- tmp = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (tmp != NULL)
- {
- if (tmp->arch_header[0] == '/'
- && tmp->arch_header[1] == ' ')
- {
- ardata->first_file_filepos +=
- (tmp->parsed_size + sizeof(struct ar_hdr) + 1) & ~1;
- }
- bfd_release (abfd, tmp);
- }
- }
-
- return true;
-
-release_raw_armap:
- bfd_release (abfd, (PTR) raw_armap);
-release_symdefs:
- bfd_release (abfd, (PTR) (ardata)->symdefs);
- return false;
-}
-
-/* This routine can handle either coff-style or bsd-style armaps.
- Returns false on error, true otherwise */
-
-boolean
-bfd_slurp_armap (abfd)
- bfd *abfd;
-{
- char nextname[17];
- int i = bfd_read ((PTR) nextname, 1, 16, abfd);
-
- if (i == 0)
- return true;
- if (i != 16)
- return false;
-
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
- return false;
-
- if (!strncmp (nextname, "__.SYMDEF ", 16)
- || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* old Linux archives */
- return do_slurp_bsd_armap (abfd);
- else if (!strncmp (nextname, "/ ", 16))
- return do_slurp_coff_armap (abfd);
-
- bfd_has_map (abfd) = false;
- return true;
-}
-
-/* Returns false on error, true otherwise */
-/* flavor 2 of a bsd armap, similar to bfd_slurp_bsd_armap except the
- header is in a slightly different order and the map name is '/'.
- This flavour is used by hp300hpux. */
-
-#define HPUX_SYMDEF_COUNT_SIZE 2
-
-boolean
-bfd_slurp_bsd_armap_f2 (abfd)
- bfd *abfd;
-{
- struct areltdata *mapdata;
- char nextname[17];
- unsigned int counter;
- bfd_byte *raw_armap, *rbase;
- struct artdata *ardata = bfd_ardata (abfd);
- char *stringbase;
- unsigned int stringsize;
- carsym *set;
- int i = bfd_read ((PTR) nextname, 1, 16, abfd);
-
- if (i == 0)
- return true;
- if (i != 16)
- return false;
-
- /* The archive has at least 16 bytes in it */
- if (bfd_seek (abfd, -16L, SEEK_CUR) != 0)
- return false;
-
- if (!strncmp (nextname, "__.SYMDEF ", 16)
- || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* old Linux archives */
- return do_slurp_bsd_armap (abfd);
-
- if (strncmp (nextname, "/ ", 16))
- {
- bfd_has_map (abfd) = false;
- return true;
- }
-
- mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (mapdata == NULL)
- return false;
-
- raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
- if (raw_armap == NULL)
- {
- byebye:
- bfd_release (abfd, (PTR) mapdata);
- return false;
- }
-
- if (bfd_read ((PTR) raw_armap, 1, mapdata->parsed_size, abfd) !=
- mapdata->parsed_size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- byebyebye:
- bfd_release (abfd, (PTR) raw_armap);
- goto byebye;
- }
-
- ardata->symdef_count = bfd_h_get_16 (abfd, (PTR) raw_armap);
-
- if (ardata->symdef_count * BSD_SYMDEF_SIZE
- > mapdata->parsed_size - HPUX_SYMDEF_COUNT_SIZE)
- {
- /* Probably we're using the wrong byte ordering. */
- bfd_set_error (bfd_error_wrong_format);
- goto byebyebye;
- }
-
- ardata->cache = 0;
-
- stringsize = bfd_h_get_32 (abfd, raw_armap + HPUX_SYMDEF_COUNT_SIZE);
- /* skip sym count and string sz */
- stringbase = ((char *) raw_armap
- + HPUX_SYMDEF_COUNT_SIZE
- + BSD_STRING_COUNT_SIZE);
- rbase = (bfd_byte *) stringbase + stringsize;
- ardata->symdefs = (carsym *) bfd_alloc (abfd,
- (ardata->symdef_count
- * BSD_SYMDEF_SIZE));
- if (!ardata->symdefs)
- return false;
-
- for (counter = 0, set = ardata->symdefs;
- counter < ardata->symdef_count;
- counter++, set++, rbase += BSD_SYMDEF_SIZE)
- {
- set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
- set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
- }
-
- ardata->first_file_filepos = bfd_tell (abfd);
- /* Pad to an even boundary if you have to */
- ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
- /* FIXME, we should provide some way to free raw_ardata when
- we are done using the strings from it. For now, it seems
- to be allocated on an obstack anyway... */
- bfd_has_map (abfd) = true;
- return true;
-}
-
-/** Extended name table.
-
- Normally archives support only 14-character filenames.
-
- Intel has extended the format: longer names are stored in a special
- element (the first in the archive, or second if there is an armap);
- the name in the ar_hdr is replaced by <space><index into filename
- element>. Index is the P.R. of an int (decimal). Data General have
- extended the format by using the prefix // for the special element */
-
-/* Returns false on error, true otherwise */
-boolean
-_bfd_slurp_extended_name_table (abfd)
- bfd *abfd;
-{
- char nextname[17];
- struct areltdata *namedata;
-
- /* FIXME: Formatting sucks here, and in case of failure of BFD_READ,
- we probably don't want to return true. */
- bfd_seek (abfd, bfd_ardata (abfd)->first_file_filepos, SEEK_SET);
- if (bfd_read ((PTR) nextname, 1, 16, abfd) == 16)
- {
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
- return false;
-
- if (strncmp (nextname, "ARFILENAMES/ ", 16) != 0 &&
- strncmp (nextname, "// ", 16) != 0)
- {
- bfd_ardata (abfd)->extended_names = NULL;
- return true;
- }
-
- namedata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (namedata == NULL)
- return false;
-
- bfd_ardata (abfd)->extended_names =
- bfd_zalloc (abfd, namedata->parsed_size);
- if (bfd_ardata (abfd)->extended_names == NULL)
- {
- byebye:
- bfd_release (abfd, (PTR) namedata);
- return false;
- }
-
- if (bfd_read ((PTR) bfd_ardata (abfd)->extended_names, 1,
- namedata->parsed_size, abfd) != namedata->parsed_size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- bfd_release (abfd, (PTR) (bfd_ardata (abfd)->extended_names));
- bfd_ardata (abfd)->extended_names = NULL;
- goto byebye;
- }
-
- /* Since the archive is supposed to be printable if it contains
- text, the entries in the list are newline-padded, not null
- padded. In SVR4-style archives, the names also have a
- trailing '/'. DOS/NT created archive often have \ in them
- We'll fix all problems here.. */
- {
- char *temp = bfd_ardata (abfd)->extended_names;
- char *limit = temp + namedata->parsed_size;
- for (; temp < limit; ++temp) {
- if (*temp == '\012')
- temp[temp[-1] == '/' ? -1 : 0] = '\0';
- if (*temp == '\\')
- *temp = '/';
- }
- }
-
- /* Pad to an even boundary if you have to */
- bfd_ardata (abfd)->first_file_filepos = bfd_tell (abfd);
- bfd_ardata (abfd)->first_file_filepos +=
- (bfd_ardata (abfd)->first_file_filepos) % 2;
-
- /* FIXME, we can't release namedata here because it was allocated
- below extended_names on the obstack... */
- /* bfd_release (abfd, namedata); */
- }
- return true;
-}
-
-#ifdef VMS
-
-/* Return a copy of the stuff in the filename between any :]> and a
- semicolon */
-static const char *
-normalize (abfd, file)
- bfd *abfd;
- const char *file;
-{
- CONST char *first;
- CONST char *last;
- char *copy;
-
- first = file + strlen (file) - 1;
- last = first + 1;
-
- while (first != file)
- {
- if (*first == ';')
- last = first;
- if (*first == ':' || *first == ']' || *first == '>')
- {
- first++;
- break;
- }
- first--;
- }
-
- copy = (char *) bfd_alloc (abfd, last - first + 1);
- if (copy == NULL)
- return NULL;
-
- memcpy (copy, first, last - first);
- copy[last - first] = 0;
-
- return copy;
-}
-
-#else
-static const char *
-normalize (abfd, file)
- bfd *abfd;
- const char *file;
-{
- const char *filename = strrchr (file, '/');
-
- if (filename != (char *) NULL)
- filename++;
- else
- filename = file;
- return filename;
-}
-#endif
-
-/* Build a BFD style extended name table. */
-
-boolean
-_bfd_archive_bsd_construct_extended_name_table (abfd, tabloc, tablen, name)
- bfd *abfd;
- char **tabloc;
- bfd_size_type *tablen;
- const char **name;
-{
- *name = "ARFILENAMES/";
- return _bfd_construct_extended_name_table (abfd, false, tabloc, tablen);
-}
-
-/* Build an SVR4 style extended name table. */
-
-boolean
-_bfd_archive_coff_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, true, tabloc, tablen);
-}
-
-/* Follows archive_head and produces an extended name table if
- necessary. Returns (in tabloc) a pointer to an extended name
- table, and in tablen the length of the table. If it makes an entry
- it clobbers the filename so that the element may be written without
- further massage. Returns true if it ran successfully, false if
- something went wrong. A successful return may still involve a
- zero-length tablen! */
-
-boolean
-_bfd_construct_extended_name_table (abfd, trailing_slash, tabloc, tablen)
- bfd *abfd;
- boolean trailing_slash;
- char **tabloc;
- bfd_size_type *tablen;
-{
- unsigned int maxname = abfd->xvec->ar_max_namelen;
- unsigned int total_namelen = 0;
- bfd *current;
- char *strptr;
-
- *tablen = 0;
-
- /* Figure out how long the table should be */
- for (current = abfd->archive_head; current != NULL; current = current->next)
- {
- const char *normal;
- unsigned int thislen;
-
- normal = normalize (current, current->filename);
- if (normal == NULL)
- return false;
-
- thislen = strlen (normal);
-
- if (thislen > maxname
- && (bfd_get_file_flags (abfd) & BFD_TRADITIONAL_FORMAT) != 0)
- thislen = maxname;
-
- if (thislen > maxname)
- {
- /* Add one to leave room for \n. */
- total_namelen += thislen + 1;
- if (trailing_slash)
- {
- /* Leave room for trailing slash. */
- ++total_namelen;
- }
- }
- else
- {
- struct ar_hdr *hdr = arch_hdr (current);
- if (strncmp (normal, hdr->ar_name, thislen) != 0
- || (thislen < sizeof hdr->ar_name
- && hdr->ar_name[thislen] != ar_padchar (current)))
- {
- /* Must have been using extended format even though it
- didn't need to. Fix it to use normal format. */
- memcpy (hdr->ar_name, normal, thislen);
- if (thislen < maxname
- || (thislen == maxname && thislen < sizeof hdr->ar_name))
- hdr->ar_name[thislen] = ar_padchar (current);
- }
- }
- }
-
- if (total_namelen == 0)
- return true;
-
- *tabloc = bfd_zalloc (abfd, total_namelen);
- if (*tabloc == NULL)
- return false;
-
- *tablen = total_namelen;
- strptr = *tabloc;
-
- for (current = abfd->archive_head; current != NULL; current =
- current->next)
- {
- const char *normal;
- unsigned int thislen;
-
- normal = normalize (current, current->filename);
- if (normal == NULL)
- return false;
-
- thislen = strlen (normal);
- if (thislen > maxname)
- {
- /* Works for now; may need to be re-engineered if we
- encounter an oddball archive format and want to
- generalise this hack. */
- struct ar_hdr *hdr = arch_hdr (current);
- strcpy (strptr, normal);
- if (! trailing_slash)
- strptr[thislen] = '\012';
- else
- {
- strptr[thislen] = '/';
- strptr[thislen + 1] = '\012';
- }
- hdr->ar_name[0] = ar_padchar (current);
- /* We know there will always be enough room (one of the few
- cases where you may safely use sprintf). */
- sprintf ((hdr->ar_name) + 1, "%-d", (unsigned) (strptr - *tabloc));
- /* Kinda Kludgy. We should just use the returned value of
- sprintf but not all implementations get this right */
- {
- char *temp = hdr->ar_name + 2;
- for (; temp < hdr->ar_name + maxname; temp++)
- if (*temp == '\0')
- *temp = ' ';
- }
- strptr += thislen + 1;
- if (trailing_slash)
- ++strptr;
- }
- }
-
- return true;
-}
-
-/** A couple of functions for creating ar_hdrs */
-
-/* Takes a filename, returns an arelt_data for it, or NULL if it can't
- make one. The filename must refer to a filename in the filesystem.
- The filename field of the ar_hdr will NOT be initialized */
-
-static struct areltdata *
-bfd_ar_hdr_from_filesystem (abfd, filename)
- bfd *abfd;
- const char *filename;
-{
- struct stat status;
- struct areltdata *ared;
- struct ar_hdr *hdr;
- char *temp, *temp1;
-
- if (stat (filename, &status) != 0)
- {
- bfd_set_error (bfd_error_system_call);
- return NULL;
- }
-
- ared = (struct areltdata *) bfd_zalloc (abfd, sizeof (struct ar_hdr) +
- sizeof (struct areltdata));
- if (ared == NULL)
- return NULL;
- hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
-
- /* ar headers are space padded, not null padded! */
- memset ((PTR) hdr, ' ', sizeof (struct ar_hdr));
-
- strncpy (hdr->ar_fmag, ARFMAG, 2);
-
- /* Goddamned sprintf doesn't permit MAXIMUM field lengths */
- sprintf ((hdr->ar_date), "%-12ld", (long) status.st_mtime);
- sprintf ((hdr->ar_uid), "%ld", (long) status.st_uid);
- sprintf ((hdr->ar_gid), "%ld", (long) status.st_gid);
- sprintf ((hdr->ar_mode), "%-8o", (unsigned int) status.st_mode);
- sprintf ((hdr->ar_size), "%-10ld", (long) status.st_size);
- /* Correct for a lossage in sprintf whereby it null-terminates. I cannot
- understand how these C losers could design such a ramshackle bunch of
- IO operations */
- temp = (char *) hdr;
- temp1 = temp + sizeof (struct ar_hdr) - 2;
- for (; temp < temp1; temp++)
- {
- if (*temp == '\0')
- *temp = ' ';
- }
- strncpy (hdr->ar_fmag, ARFMAG, 2);
- ared->parsed_size = status.st_size;
- ared->arch_header = (char *) hdr;
-
- return ared;
-}
-
-/* This is magic required by the "ar" program. Since it's
- undocumented, it's undocumented. You may think that it would take
- a strong stomach to write this, and it does, but it takes even a
- stronger stomach to try to code around such a thing! */
-
-struct ar_hdr *
-bfd_special_undocumented_glue (abfd, filename)
- bfd *abfd;
- char *filename;
-{
- struct areltdata *ar_elt = bfd_ar_hdr_from_filesystem (abfd, filename);
- if (ar_elt == NULL)
- return NULL;
- return (struct ar_hdr *) ar_elt->arch_header;
-}
-
-
-/* Analogous to stat call */
-int
-bfd_generic_stat_arch_elt (abfd, buf)
- bfd *abfd;
- struct stat *buf;
-{
- struct ar_hdr *hdr;
- char *aloser;
-
- if (abfd->arelt_data == NULL)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
-
- hdr = arch_hdr (abfd);
-
-#define foo(arelt, stelt, size) \
- buf->stelt = strtol (hdr->arelt, &aloser, size); \
- if (aloser == hdr->arelt) return -1;
-
- foo (ar_date, st_mtime, 10);
- foo (ar_uid, st_uid, 10);
- foo (ar_gid, st_gid, 10);
- foo (ar_mode, st_mode, 8);
-
- buf->st_size = arch_eltdata (abfd)->parsed_size;
-
- return 0;
-}
-
-void
-bfd_dont_truncate_arname (abfd, pathname, arhdr)
- bfd *abfd;
- CONST char *pathname;
- char *arhdr;
-{
- /* FIXME: This interacts unpleasantly with ar's quick-append option.
- Fortunately ic960 users will never use that option. Fixing this
- is very hard; fortunately I know how to do it and will do so once
- intel's release is out the door. */
-
- struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
- size_t length;
- const char *filename;
- size_t maxlen = ar_maxnamelen (abfd);
-
- if ((bfd_get_file_flags (abfd) & BFD_TRADITIONAL_FORMAT) != 0)
- {
- bfd_bsd_truncate_arname (abfd, pathname, arhdr);
- return;
- }
-
- filename = normalize (abfd, pathname);
- if (filename == NULL)
- {
- /* FIXME */
- abort ();
- }
-
- length = strlen (filename);
-
- if (length <= maxlen)
- memcpy (hdr->ar_name, filename, length);
-
- /* Add the padding character if there is room for it. */
- if (length < maxlen
- || (length == maxlen && length < sizeof hdr->ar_name))
- (hdr->ar_name)[length] = ar_padchar (abfd);
-}
-
-void
-bfd_bsd_truncate_arname (abfd, pathname, arhdr)
- bfd *abfd;
- CONST char *pathname;
- char *arhdr;
-{
- struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
- int length;
- CONST char *filename = strrchr (pathname, '/');
- int maxlen = ar_maxnamelen (abfd);
-
- if (filename == NULL)
- filename = pathname;
- else
- ++filename;
-
- length = strlen (filename);
-
- if (length <= maxlen)
- memcpy (hdr->ar_name, filename, length);
- else
- {
- /* pathname: meet procrustes */
- memcpy (hdr->ar_name, filename, maxlen);
- length = maxlen;
- }
-
- if (length < maxlen)
- (hdr->ar_name)[length] = ar_padchar (abfd);
-}
-
-/* Store name into ar header. Truncates the name to fit.
- 1> strip pathname to be just the basename.
- 2> if it's short enuf to fit, stuff it in.
- 3> If it doesn't end with .o, truncate it to fit
- 4> truncate it before the .o, append .o, stuff THAT in. */
-
-/* This is what gnu ar does. It's better but incompatible with the
- bsd ar. */
-
-void
-bfd_gnu_truncate_arname (abfd, pathname, arhdr)
- bfd *abfd;
- CONST char *pathname;
- char *arhdr;
-{
- struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
- int length;
- CONST char *filename = strrchr (pathname, '/');
- int maxlen = ar_maxnamelen (abfd);
-
- if (filename == NULL)
- filename = pathname;
- else
- ++filename;
-
- length = strlen (filename);
-
- if (length <= maxlen)
- memcpy (hdr->ar_name, filename, length);
- else
- { /* pathname: meet procrustes */
- memcpy (hdr->ar_name, filename, maxlen);
- if ((filename[length - 2] == '.') && (filename[length - 1] == 'o'))
- {
- hdr->ar_name[maxlen - 2] = '.';
- hdr->ar_name[maxlen - 1] = 'o';
- }
- length = maxlen;
- }
-
- if (length < 16)
- (hdr->ar_name)[length] = ar_padchar (abfd);
-}
-
-/* The BFD is open for write and has its format set to bfd_archive */
-
-boolean
-_bfd_write_archive_contents (arch)
- bfd *arch;
-{
- bfd *current;
- char *etable = NULL;
- bfd_size_type elength = 0;
- const char *ename = NULL;
- boolean makemap = bfd_has_map (arch);
- boolean hasobjects = false; /* if no .o's, don't bother to make a map */
- bfd_size_type wrote;
- unsigned int i;
- int tries;
-
- /* Verify the viability of all entries; if any of them live in the
- filesystem (as opposed to living in an archive open for input)
- then construct a fresh ar_hdr for them. */
- for (current = arch->archive_head; current; current = current->next)
- {
- if (bfd_write_p (current))
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
- if (!current->arelt_data)
- {
- current->arelt_data =
- (PTR) bfd_ar_hdr_from_filesystem (arch, current->filename);
- if (!current->arelt_data)
- return false;
-
- /* Put in the file name */
- BFD_SEND (arch, _bfd_truncate_arname, (arch,
- current->filename,
- (char *) arch_hdr (current)));
- }
-
- if (makemap && ! hasobjects)
- { /* don't bother if we won't make a map! */
- if ((bfd_check_format (current, bfd_object))
-#if 0 /* FIXME -- these are not set correctly */
- && ((bfd_get_file_flags (current) & HAS_SYMS))
-#endif
- )
- hasobjects = true;
- }
- }
-
- if (!BFD_SEND (arch, _bfd_construct_extended_name_table,
- (arch, &etable, &elength, &ename)))
- return false;
-
- if (bfd_seek (arch, (file_ptr) 0, SEEK_SET) != 0)
- return false;
-#ifdef GNU960
- wrote = bfd_write (BFD_GNU960_ARMAG (arch), 1, SARMAG, arch);
-#else
- wrote = bfd_write (ARMAG, 1, SARMAG, arch);
-#endif
- if (wrote != SARMAG)
- return false;
-
- if (makemap && hasobjects)
- {
- if (_bfd_compute_and_write_armap (arch, elength) != true)
- return false;
- }
-
- if (elength != 0)
- {
- struct ar_hdr hdr;
-
- memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
- strcpy (hdr.ar_name, ename);
- /* Round size up to even number in archive header. */
- sprintf (&(hdr.ar_size[0]), "%-10d",
- (int) ((elength + 1) & ~1));
- strncpy (hdr.ar_fmag, ARFMAG, 2);
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *) (&hdr))[i] == '\0')
- (((char *) (&hdr))[i]) = ' ';
- if ((bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
- != sizeof (struct ar_hdr))
- || bfd_write (etable, 1, elength, arch) != elength)
- return false;
- if ((elength % 2) == 1)
- {
- if (bfd_write ("\012", 1, 1, arch) != 1)
- return false;
- }
- }
-
- for (current = arch->archive_head; current; current = current->next)
- {
- char buffer[DEFAULT_BUFFERSIZE];
- unsigned int remaining = arelt_size (current);
- struct ar_hdr *hdr = arch_hdr (current);
-
- /* write ar header */
- if (bfd_write ((char *) hdr, 1, sizeof (*hdr), arch) != sizeof (*hdr))
- return false;
- if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
- return false;
- while (remaining)
- {
- unsigned int amt = DEFAULT_BUFFERSIZE;
- if (amt > remaining)
- amt = remaining;
- errno = 0;
- if (bfd_read (buffer, amt, 1, current) != amt)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- return false;
- }
- if (bfd_write (buffer, amt, 1, arch) != amt)
- return false;
- remaining -= amt;
- }
- if ((arelt_size (current) % 2) == 1)
- {
- if (bfd_write ("\012", 1, 1, arch) != 1)
- return false;
- }
- }
-
- if (makemap && hasobjects)
- {
- /* Verify the timestamp in the archive file. If it would not be
- accepted by the linker, rewrite it until it would be. If
- anything odd happens, break out and just return. (The
- Berkeley linker checks the timestamp and refuses to read the
- table-of-contents if it is >60 seconds less than the file's
- modified-time. That painful hack requires this painful hack. */
- tries = 1;
- do
- {
- if (bfd_update_armap_timestamp (arch))
- break;
- (*_bfd_error_handler)
- ("Warning: writing archive was slow: rewriting timestamp\n");
- }
- while (++tries < 6);
- }
-
- return true;
-}
-
-/* Note that the namidx for the first symbol is 0 */
-
-boolean
-_bfd_compute_and_write_armap (arch, elength)
- bfd *arch;
- unsigned int elength;
-{
- char *first_name = NULL;
- bfd *current;
- file_ptr elt_no = 0;
- struct orl *map = NULL;
- int orl_max = 1024; /* fine initial default */
- int orl_count = 0;
- int stridx = 0; /* string index */
- asymbol **syms = NULL;
- long syms_max = 0;
- boolean ret;
-
- /* Dunno if this is the best place for this info... */
- if (elength != 0)
- elength += sizeof (struct ar_hdr);
- elength += elength % 2;
-
- map = (struct orl *) bfd_malloc (orl_max * sizeof (struct orl));
- if (map == NULL)
- goto error_return;
-
- /* We put the symbol names on the arch obstack, and then discard
- them when done. */
- first_name = bfd_alloc (arch, 1);
- if (first_name == NULL)
- goto error_return;
-
- /* Drop all the files called __.SYMDEF, we're going to make our
- own */
- while (arch->archive_head &&
- strcmp (arch->archive_head->filename, "__.SYMDEF") == 0)
- arch->archive_head = arch->archive_head->next;
-
- /* Map over each element */
- for (current = arch->archive_head;
- current != (bfd *) NULL;
- current = current->next, elt_no++)
- {
- if ((bfd_check_format (current, bfd_object) == true)
- && ((bfd_get_file_flags (current) & HAS_SYMS)))
- {
- long storage;
- long symcount;
- long src_count;
-
- storage = bfd_get_symtab_upper_bound (current);
- if (storage < 0)
- goto error_return;
-
- if (storage != 0)
- {
- if (storage > syms_max)
- {
- if (syms_max > 0)
- free (syms);
- syms_max = storage;
- syms = (asymbol **) bfd_malloc ((size_t) syms_max);
- if (syms == NULL)
- goto error_return;
- }
- symcount = bfd_canonicalize_symtab (current, syms);
- if (symcount < 0)
- goto error_return;
-
- /* Now map over all the symbols, picking out the ones we want */
- for (src_count = 0; src_count < symcount; src_count++)
- {
- flagword flags = (syms[src_count])->flags;
- asection *sec = syms[src_count]->section;
-
- if ((flags & BSF_GLOBAL ||
- flags & BSF_WEAK ||
- flags & BSF_INDIRECT ||
- bfd_is_com_section (sec))
- && ! bfd_is_und_section (sec))
- {
- size_t namelen;
- struct orl *new_map;
-
- /* This symbol will go into the archive header */
- if (orl_count == orl_max)
- {
- orl_max *= 2;
- new_map =
- ((struct orl *)
- bfd_realloc (map, orl_max * sizeof (struct orl)));
- if (new_map == (struct orl *) NULL)
- goto error_return;
-
- map = new_map;
- }
-
- namelen = strlen (syms[src_count]->name);
- map[orl_count].name = ((char **)
- bfd_alloc (arch,
- sizeof (char *)));
- if (map[orl_count].name == NULL)
- goto error_return;
- *(map[orl_count].name) = bfd_alloc (arch, namelen + 1);
- if (*(map[orl_count].name) == NULL)
- goto error_return;
- strcpy (*(map[orl_count].name), syms[src_count]->name);
- (map[orl_count]).pos = (file_ptr) current;
- (map[orl_count]).namidx = stridx;
-
- stridx += namelen + 1;
- ++orl_count;
- }
- }
- }
-
- /* Now ask the BFD to free up any cached information, so we
- don't fill all of memory with symbol tables. */
- if (! bfd_free_cached_info (current))
- goto error_return;
- }
- }
-
- /* OK, now we have collected all the data, let's write them out */
- ret = BFD_SEND (arch, write_armap,
- (arch, elength, map, orl_count, stridx));
-
- if (syms_max > 0)
- free (syms);
- if (map != NULL)
- free (map);
- if (first_name != NULL)
- bfd_release (arch, first_name);
-
- return ret;
-
- error_return:
- if (syms_max > 0)
- free (syms);
- if (map != NULL)
- free (map);
- if (first_name != NULL)
- bfd_release (arch, first_name);
-
- return false;
-}
-
-boolean
-bsd_write_armap (arch, elength, map, orl_count, stridx)
- bfd *arch;
- unsigned int elength;
- struct orl *map;
- unsigned int orl_count;
- int stridx;
-{
- int padit = stridx & 1;
- unsigned int ranlibsize = orl_count * BSD_SYMDEF_SIZE;
- unsigned int stringsize = stridx + padit;
- /* Include 8 bytes to store ranlibsize and stringsize in output. */
- unsigned int mapsize = ranlibsize + stringsize + 8;
- file_ptr firstreal;
- bfd *current = arch->archive_head;
- bfd *last_elt = current; /* last element arch seen */
- bfd_byte temp[4];
- unsigned int count;
- struct ar_hdr hdr;
- struct stat statbuf;
- unsigned int i;
-
- firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG;
-
- stat (arch->filename, &statbuf);
- memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
- sprintf (hdr.ar_name, RANLIBMAG);
- /* Remember the timestamp, to keep it holy. But fudge it a little. */
- bfd_ardata (arch)->armap_timestamp = statbuf.st_mtime + ARMAP_TIME_OFFSET;
- bfd_ardata (arch)->armap_datepos = (SARMAG
- + offsetof (struct ar_hdr, ar_date[0]));
- sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp);
- sprintf (hdr.ar_uid, "%ld", (long) getuid ());
- sprintf (hdr.ar_gid, "%ld", (long) getgid ());
- sprintf (hdr.ar_size, "%-10d", (int) mapsize);
- strncpy (hdr.ar_fmag, ARFMAG, 2);
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *) (&hdr))[i] == '\0')
- (((char *) (&hdr))[i]) = ' ';
- if (bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
- != sizeof (struct ar_hdr))
- return false;
- bfd_h_put_32 (arch, (bfd_vma) ranlibsize, temp);
- if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
- return false;
-
- for (count = 0; count < orl_count; count++)
- {
- bfd_byte buf[BSD_SYMDEF_SIZE];
-
- if (((bfd *) (map[count]).pos) != last_elt)
- {
- do
- {
- firstreal += arelt_size (current) + sizeof (struct ar_hdr);
- firstreal += firstreal % 2;
- current = current->next;
- }
- while (current != (bfd *) (map[count]).pos);
- } /* if new archive element */
-
- last_elt = current;
- bfd_h_put_32 (arch, map[count].namidx, buf);
- bfd_h_put_32 (arch, firstreal, buf + BSD_SYMDEF_OFFSET_SIZE);
- if (bfd_write (buf, BSD_SYMDEF_SIZE, 1, arch) != BSD_SYMDEF_SIZE)
- return false;
- }
-
- /* now write the strings themselves */
- bfd_h_put_32 (arch, stringsize, temp);
- if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
- return false;
- for (count = 0; count < orl_count; count++)
- {
- size_t len = strlen (*map[count].name) + 1;
-
- if (bfd_write (*map[count].name, 1, len, arch) != len)
- return false;
- }
-
- /* The spec sez this should be a newline. But in order to be
- bug-compatible for sun's ar we use a null. */
- if (padit)
- {
- if (bfd_write ("", 1, 1, arch) != 1)
- return false;
- }
-
- return true;
-}
-
-/* At the end of archive file handling, update the timestamp in the
- file, so the linker will accept it.
-
- Return true if the timestamp was OK, or an unusual problem happened.
- Return false if we updated the timestamp. */
-
-boolean
-_bfd_archive_bsd_update_armap_timestamp (arch)
- bfd *arch;
-{
- struct stat archstat;
- struct ar_hdr hdr;
- unsigned int i;
-
- /* Flush writes, get last-write timestamp from file, and compare it
- to the timestamp IN the file. */
- bfd_flush (arch);
- if (bfd_stat (arch, &archstat) == -1)
- {
- perror ("Reading archive file mod timestamp");
- return true; /* Can't read mod time for some reason */
- }
- if (archstat.st_mtime <= bfd_ardata (arch)->armap_timestamp)
- return true; /* OK by the linker's rules */
-
- /* Update the timestamp. */
- bfd_ardata (arch)->armap_timestamp = archstat.st_mtime + ARMAP_TIME_OFFSET;
-
- /* Prepare an ASCII version suitable for writing. */
- memset (hdr.ar_date, 0, sizeof (hdr.ar_date));
- sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp);
- for (i = 0; i < sizeof (hdr.ar_date); i++)
- if (hdr.ar_date[i] == '\0')
- (hdr.ar_date)[i] = ' ';
-
- /* Write it into the file. */
- bfd_ardata (arch)->armap_datepos = (SARMAG
- + offsetof (struct ar_hdr, ar_date[0]));
- if (bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET) != 0
- || (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch)
- != sizeof (hdr.ar_date)))
- {
- /* FIXME: bfd can't call perror. */
- perror ("Writing updated armap timestamp");
- return true; /* Some error while writing */
- }
-
- return false; /* We updated the timestamp successfully. */
-}
-
-/* A coff armap looks like :
- lARMAG
- struct ar_hdr with name = '/'
- number of symbols
- offset of file for symbol 0
- offset of file for symbol 1
-
- offset of file for symbol n-1
- symbol name 0
- symbol name 1
-
- symbol name n-1
-*/
-
-boolean
-coff_write_armap (arch, elength, map, symbol_count, stridx)
- bfd *arch;
- unsigned int elength;
- struct orl *map;
- unsigned int symbol_count;
- int stridx;
-{
- /* The size of the ranlib is the number of exported symbols in the
- archive * the number of bytes in a int, + an int for the count */
- unsigned int ranlibsize = (symbol_count * 4) + 4;
- unsigned int stringsize = stridx;
- unsigned int mapsize = stringsize + ranlibsize;
- file_ptr archive_member_file_ptr;
- bfd *current = arch->archive_head;
- unsigned int count;
- struct ar_hdr hdr;
- unsigned int i;
- int padit = mapsize & 1;
-
- if (padit)
- mapsize++;
-
- /* work out where the first object file will go in the archive */
- archive_member_file_ptr = (mapsize
- + elength
- + sizeof (struct ar_hdr)
- + SARMAG);
-
- memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
- hdr.ar_name[0] = '/';
- sprintf (hdr.ar_size, "%-10d", (int) mapsize);
- sprintf (hdr.ar_date, "%ld", (long) time (NULL));
- /* This, at least, is what Intel coff sets the values to.: */
- sprintf ((hdr.ar_uid), "%d", 0);
- sprintf ((hdr.ar_gid), "%d", 0);
- sprintf ((hdr.ar_mode), "%-7o", (unsigned) 0);
- strncpy (hdr.ar_fmag, ARFMAG, 2);
-
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *) (&hdr))[i] == '\0')
- (((char *) (&hdr))[i]) = ' ';
-
- /* Write the ar header for this item and the number of symbols */
-
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch)
- != sizeof (struct ar_hdr))
- return false;
-
- bfd_write_bigendian_4byte_int (arch, symbol_count);
-
- /* Two passes, first write the file offsets for each symbol -
- remembering that each offset is on a two byte boundary. */
-
- /* Write out the file offset for the file associated with each
- symbol, and remember to keep the offsets padded out. */
-
- current = arch->archive_head;
- count = 0;
- while (current != (bfd *) NULL && count < symbol_count)
- {
- /* For each symbol which is used defined in this object, write out
- the object file's address in the archive */
-
- while (((bfd *) (map[count]).pos) == current)
- {
- bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr);
- count++;
- }
- /* Add size of this archive entry */
- archive_member_file_ptr += (arelt_size (current)
- + sizeof (struct ar_hdr));
- /* remember aboout the even alignment */
- archive_member_file_ptr += archive_member_file_ptr % 2;
- current = current->next;
- }
-
- /* now write the strings themselves */
- for (count = 0; count < symbol_count; count++)
- {
- size_t len = strlen (*map[count].name) + 1;
-
- if (bfd_write (*map[count].name, 1, len, arch) != len)
- return false;
- }
-
- /* The spec sez this should be a newline. But in order to be
- bug-compatible for arc960 we use a null. */
- if (padit)
- {
- if (bfd_write ("", 1, 1, arch) != 1)
- return false;
- }
-
- return true;
-}
diff --git a/contrib/gdb/bfd/archures.c b/contrib/gdb/bfd/archures.c
deleted file mode 100644
index 1db8bc24b86f..000000000000
--- a/contrib/gdb/bfd/archures.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/* BFD library support routines for architectures.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include <ctype.h>
-
-/*
-
-SECTION
- Architectures
-
- BFD keeps one atom in a BFD describing the
- architecture of the data attached to the BFD: a pointer to a
- <<bfd_arch_info_type>>.
-
- Pointers to structures can be requested independently of a BFD
- so that an architecture's information can be interrogated
- without access to an open BFD.
-
- The architecture information is provided by each architecture package.
- The set of default architectures is selected by the macro
- <<SELECT_ARCHITECTURES>>. This is normally set up in the
- @file{config/@var{target}.mt} file of your choice. If the name is not
- defined, then all the architectures supported are included.
-
- When BFD starts up, all the architectures are called with an
- initialize method. It is up to the architecture back end to
- insert as many items into the list of architectures as it wants to;
- generally this would be one for each machine and one for the
- default case (an item with a machine field of 0).
-
- BFD's idea of an architecture is implemented in @file{archures.c}.
-*/
-
-/*
-
-SUBSECTION
- bfd_architecture
-
-DESCRIPTION
- This enum gives the object file's CPU architecture, in a
- global sense---i.e., what processor family does it belong to?
- Another field indicates which processor within
- the family is in use. The machine gives a number which
- distinguishes different versions of the architecture,
- containing, for example, 2 and 3 for Intel i960 KA and i960 KB,
- and 68020 and 68030 for Motorola 68020 and 68030.
-
-.enum bfd_architecture
-.{
-. bfd_arch_unknown, {* File arch not known *}
-. bfd_arch_obscure, {* Arch known, not one of these *}
-. bfd_arch_m68k, {* Motorola 68xxx *}
-. bfd_arch_vax, {* DEC Vax *}
-. bfd_arch_i960, {* Intel 960 *}
-. {* The order of the following is important.
-. lower number indicates a machine type that
-. only accepts a subset of the instructions
-. available to machines with higher numbers.
-. The exception is the "ca", which is
-. incompatible with all other machines except
-. "core". *}
-.
-.#define bfd_mach_i960_core 1
-.#define bfd_mach_i960_ka_sa 2
-.#define bfd_mach_i960_kb_sb 3
-.#define bfd_mach_i960_mc 4
-.#define bfd_mach_i960_xa 5
-.#define bfd_mach_i960_ca 6
-.#define bfd_mach_i960_jx 7
-.#define bfd_mach_i960_hx 8
-.
-. bfd_arch_a29k, {* AMD 29000 *}
-. bfd_arch_sparc, {* SPARC *}
-.#define bfd_mach_sparc 1
-.{* The difference between v8plus and v9 is that v9 is a true 64 bit env. *}
-.#define bfd_mach_sparc_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
-. };
-
-
-*/
-
-/*
-
-SUBSECTION
- bfd_arch_info
-
-DESCRIPTION
- This structure contains information on architectures for use
- within BFD.
-
-.
-.typedef struct bfd_arch_info
-.{
-. int bits_per_word;
-. int bits_per_address;
-. int bits_per_byte;
-. enum bfd_architecture arch;
-. unsigned long mach;
-. const char *arch_name;
-. const char *printable_name;
-. unsigned int section_align_power;
-. {* true if this is the default machine for the architecture *}
-. boolean the_default;
-. const struct bfd_arch_info * (*compatible)
-. PARAMS ((const struct bfd_arch_info *a,
-. const struct bfd_arch_info *b));
-.
-. boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
-.
-. const struct bfd_arch_info *next;
-.} bfd_arch_info_type;
-*/
-
-extern const bfd_arch_info_type bfd_a29k_arch;
-extern const bfd_arch_info_type bfd_alpha_arch;
-extern const bfd_arch_info_type bfd_arm_arch;
-extern const bfd_arch_info_type bfd_h8300_arch;
-extern const bfd_arch_info_type bfd_h8500_arch;
-extern const bfd_arch_info_type bfd_hppa_arch;
-extern const bfd_arch_info_type bfd_i386_arch;
-extern const bfd_arch_info_type bfd_i860_arch;
-extern const bfd_arch_info_type bfd_i960_arch;
-extern const bfd_arch_info_type bfd_m68k_arch;
-extern const bfd_arch_info_type bfd_m88k_arch;
-extern const bfd_arch_info_type bfd_mips_arch;
-extern const bfd_arch_info_type bfd_powerpc_arch;
-extern const bfd_arch_info_type bfd_rs6000_arch;
-extern const bfd_arch_info_type bfd_sh_arch;
-extern const bfd_arch_info_type bfd_sparc_arch;
-extern const bfd_arch_info_type bfd_vax_arch;
-extern const bfd_arch_info_type bfd_we32k_arch;
-extern const bfd_arch_info_type bfd_z8k_arch;
-extern const bfd_arch_info_type bfd_ns32k_arch;
-extern const bfd_arch_info_type bfd_w65_arch;
-
-static const bfd_arch_info_type * const bfd_archures_list[] =
-{
-#ifdef SELECT_ARCHITECTURES
- SELECT_ARCHITECTURES,
-#else
- &bfd_a29k_arch,
- &bfd_alpha_arch,
- &bfd_arm_arch,
- &bfd_h8300_arch,
- &bfd_h8500_arch,
- &bfd_hppa_arch,
- &bfd_i386_arch,
- &bfd_i860_arch,
- &bfd_i960_arch,
- &bfd_m68k_arch,
- &bfd_m88k_arch,
- &bfd_mips_arch,
- &bfd_powerpc_arch,
- &bfd_rs6000_arch,
- &bfd_sh_arch,
- &bfd_sparc_arch,
- &bfd_vax_arch,
- &bfd_we32k_arch,
- &bfd_z8k_arch,
- &bfd_ns32k_arch,
- &bfd_w65_arch,
-#endif
- 0
-};
-
-/*
-FUNCTION
- bfd_printable_name
-
-SYNOPSIS
- const char *bfd_printable_name(bfd *abfd);
-
-DESCRIPTION
- Return a printable string representing the architecture and machine
- from the pointer to the architecture info structure.
-
-*/
-
-const char *
-bfd_printable_name (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->printable_name;
-}
-
-
-
-/*
-FUNCTION
- bfd_scan_arch
-
-SYNOPSIS
- const bfd_arch_info_type *bfd_scan_arch(const char *string);
-
-DESCRIPTION
- Figure out if BFD supports any cpu which could be described with
- the name @var{string}. Return a pointer to an <<arch_info>>
- structure if a machine is found, otherwise NULL.
-
-*/
-
-const bfd_arch_info_type *
-bfd_scan_arch (string)
- const char *string;
-{
- const bfd_arch_info_type * const *app, *ap;
-
- /* Look through all the installed architectures */
- for (app = bfd_archures_list; *app != NULL; app++)
- {
- for (ap = *app; ap != NULL; ap = ap->next)
- {
- if (ap->scan (ap, string))
- return ap;
- }
- }
-
- return NULL;
-}
-
-
-
-/*
-FUNCTION
- bfd_arch_get_compatible
-
-SYNOPSIS
- const bfd_arch_info_type *bfd_arch_get_compatible(
- const bfd *abfd,
- const bfd *bbfd);
-
-DESCRIPTION
- Determine whether two BFDs'
- architectures and machine types are compatible. Calculates
- the lowest common denominator between the two architectures
- and machine types implied by the BFDs and returns a pointer to
- an <<arch_info>> structure describing the compatible machine.
-*/
-
-const bfd_arch_info_type *
-bfd_arch_get_compatible (abfd, bbfd)
- const bfd *abfd;
- const bfd *bbfd;
-{
- /* If either architecture is unknown, then all we can do is assume
- the user knows what he's doing. */
- if (abfd->arch_info->arch == bfd_arch_unknown)
- return bbfd->arch_info;
- if (bbfd->arch_info->arch == bfd_arch_unknown)
- return abfd->arch_info;
-
- /* Otherwise architecture-specific code has to decide. */
- return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info);
-}
-
-
-/*
-INTERNAL_DEFINITION
- bfd_default_arch_struct
-
-DESCRIPTION
- The <<bfd_default_arch_struct>> is an item of
- <<bfd_arch_info_type>> which has been initialized to a fairly
- generic state. A BFD starts life by pointing to this
- structure, until the correct back end has determined the real
- architecture of the file.
-
-.extern const bfd_arch_info_type bfd_default_arch_struct;
-
-*/
-
-const bfd_arch_info_type bfd_default_arch_struct =
-{
- 32,32,8,bfd_arch_unknown,0,"unknown","unknown",2,true,
- bfd_default_compatible,
- bfd_default_scan,
- 0,
-};
-
-/*
-FUNCTION
- bfd_set_arch_info
-
-SYNOPSIS
- void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg);
-
-DESCRIPTION
- Set the architecture info of @var{abfd} to @var{arg}.
-*/
-
-void
-bfd_set_arch_info (abfd, arg)
- bfd *abfd;
- const bfd_arch_info_type *arg;
-{
- abfd->arch_info = arg;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_default_set_arch_mach
-
-SYNOPSIS
- boolean bfd_default_set_arch_mach(bfd *abfd,
- enum bfd_architecture arch,
- unsigned long mach);
-
-DESCRIPTION
- Set the architecture and machine type in BFD @var{abfd}
- to @var{arch} and @var{mach}. Find the correct
- pointer to a structure and insert it into the <<arch_info>>
- pointer.
-*/
-
-boolean
-bfd_default_set_arch_mach (abfd, arch, mach)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long mach;
-{
- const bfd_arch_info_type * const *app, *ap;
-
- for (app = bfd_archures_list; *app != NULL; app++)
- {
- for (ap = *app; ap != NULL; ap = ap->next)
- {
- if (ap->arch == arch
- && (ap->mach == mach
- || (mach == 0 && ap->the_default)))
- {
- abfd->arch_info = ap;
- return true;
- }
- }
- }
-
- abfd->arch_info = &bfd_default_arch_struct;
- bfd_set_error (bfd_error_bad_value);
- return false;
-}
-
-
-/*
-FUNCTION
- bfd_get_arch
-
-SYNOPSIS
- enum bfd_architecture bfd_get_arch(bfd *abfd);
-
-DESCRIPTION
- Return the enumerated type which describes the BFD @var{abfd}'s
- architecture.
-
-*/
-
-enum bfd_architecture
-bfd_get_arch (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->arch;
-}
-
-/*
-FUNCTION
- bfd_get_mach
-
-SYNOPSIS
- unsigned long bfd_get_mach(bfd *abfd);
-
-DESCRIPTION
- Return the long type which describes the BFD @var{abfd}'s
- machine.
-*/
-
-unsigned long
-bfd_get_mach (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->mach;
-}
-
-/*
-FUNCTION
- bfd_arch_bits_per_byte
-
-SYNOPSIS
- unsigned int bfd_arch_bits_per_byte(bfd *abfd);
-
-DESCRIPTION
- Return the number of bits in one of the BFD @var{abfd}'s
- architecture's bytes.
-
-*/
-
-unsigned int
-bfd_arch_bits_per_byte (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->bits_per_byte;
-}
-
-/*
-FUNCTION
- bfd_arch_bits_per_address
-
-SYNOPSIS
- unsigned int bfd_arch_bits_per_address(bfd *abfd);
-
-DESCRIPTION
- Return the number of bits in one of the BFD @var{abfd}'s
- architecture's addresses.
-*/
-
-unsigned int
-bfd_arch_bits_per_address (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->bits_per_address;
-}
-
-
-/*
-INTERNAL_FUNCTION
- bfd_default_compatible
-
-SYNOPSIS
- const bfd_arch_info_type *bfd_default_compatible
- (const bfd_arch_info_type *a,
- const bfd_arch_info_type *b);
-
-DESCRIPTION
- The default function for testing for compatibility.
-*/
-
-const bfd_arch_info_type *
-bfd_default_compatible (a,b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- if (a->arch != b->arch)
- return NULL;
-
- if (a->mach > b->mach)
- return a;
-
- if (b->mach > a->mach)
- return b;
-
- return a;
-}
-
-
-/*
-INTERNAL_FUNCTION
- bfd_default_scan
-
-SYNOPSIS
- boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string);
-
-DESCRIPTION
- The default function for working out whether this is an
- architecture hit and a machine hit.
-*/
-
-boolean
-bfd_default_scan (info, string)
- const struct bfd_arch_info *info;
- const char *string;
-{
- const char *ptr_src;
- const char *ptr_tst;
- unsigned long number;
- enum bfd_architecture arch;
-
- /* First test for an exact match */
- if (strcmp (string, info->printable_name) == 0)
- return true;
-
- /* See how much of the supplied string matches with the
- architecture, eg the string m68k:68020 would match the 68k entry
- up to the :, then we get left with the machine number */
-
- for (ptr_src = string, ptr_tst = info->arch_name;
- *ptr_src && *ptr_tst;
- ptr_src++, ptr_tst++)
- {
- if (*ptr_src != *ptr_tst) break;
- }
-
- /* Chewed up as much of the architecture as will match, skip any
- colons */
- if (*ptr_src == ':')
- ptr_src++;
-
- if (*ptr_src == 0)
- {
- /* nothing more, then only keep this one if it is the default
- machine for this architecture */
- return info->the_default;
- }
-
- number = 0;
- while (isdigit(*ptr_src))
- {
- number = number * 10 + *ptr_src - '0';
- ptr_src++;
- }
-
- switch (number)
- {
- case 65:
- arch = bfd_arch_w65;
- break;
-
- case 300:
- arch = bfd_arch_h8300;
- break;
-
- case 500:
- arch = bfd_arch_h8500;
- break;
-
- case 68010:
- case 68020:
- case 68030:
- case 68040:
- case 68332:
- case 68050:
- case 68000:
- arch = bfd_arch_m68k;
- break;
-
- case 386:
- case 80386:
- case 486:
- case 80486:
- arch = bfd_arch_i386;
- break;
-
- case 29000:
- arch = bfd_arch_a29k;
- break;
-
- case 8000:
- arch = bfd_arch_z8k;
- break;
-
- case 32000:
- arch = bfd_arch_we32k;
- break;
-
- case 860:
- case 80860:
- arch = bfd_arch_i860;
- break;
- case 960:
- case 80960:
- arch = bfd_arch_i960;
- break;
-
- case 2000:
- case 3000:
- case 4000:
- case 4400:
- arch = bfd_arch_mips;
- break;
-
- case 6000:
- arch = bfd_arch_rs6000;
- break;
-
- default:
- return false;
- }
-
- if (arch != info->arch)
- return false;
-
- if (number != info->mach)
- return false;
-
- return true;
-}
-
-
-/*
-FUNCTION
- bfd_get_arch_info
-
-SYNOPSIS
- const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
-
-DESCRIPTION
- Return the architecture info struct in @var{abfd}.
-*/
-
-const bfd_arch_info_type *
-bfd_get_arch_info (abfd)
- bfd *abfd;
-{
- return abfd->arch_info;
-}
-
-
-/*
-FUNCTION
- bfd_lookup_arch
-
-SYNOPSIS
- const bfd_arch_info_type *bfd_lookup_arch
- (enum bfd_architecture
- arch,
- unsigned long machine);
-
-DESCRIPTION
- Look for the architecure info structure which matches the
- arguments @var{arch} and @var{machine}. A machine of 0 matches the
- machine/architecture structure which marks itself as the
- default.
-*/
-
-const bfd_arch_info_type *
-bfd_lookup_arch (arch, machine)
- enum bfd_architecture arch;
- unsigned long machine;
-{
- const bfd_arch_info_type * const *app, *ap;
-
- for (app = bfd_archures_list; *app != NULL; app++)
- {
- for (ap = *app; ap != NULL; ap = ap->next)
- {
- if (ap->arch == arch
- && (ap->mach == machine
- || (machine == 0 && ap->the_default)))
- return ap;
- }
- }
-
- return NULL;
-}
-
-
-/*
-FUNCTION
- bfd_printable_arch_mach
-
-SYNOPSIS
- const char *bfd_printable_arch_mach
- (enum bfd_architecture arch, unsigned long machine);
-
-DESCRIPTION
- Return a printable string representing the architecture and
- machine type.
-
- This routine is depreciated.
-*/
-
-const char *
-bfd_printable_arch_mach (arch, machine)
- enum bfd_architecture arch;
- unsigned long machine;
-{
- const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine);
-
- if (ap)
- return ap->printable_name;
- return "UNKNOWN!";
-}
diff --git a/contrib/gdb/bfd/bfd-in.h b/contrib/gdb/bfd/bfd-in.h
deleted file mode 100644
index d2912396551a..000000000000
--- a/contrib/gdb/bfd/bfd-in.h
+++ /dev/null
@@ -1,668 +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. */
diff --git a/contrib/gdb/bfd/bfd-in2.h b/contrib/gdb/bfd/bfd-in2.h
deleted file mode 100644
index d238d5afa4a0..000000000000
--- 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/bfd.c b/contrib/gdb/bfd/bfd.c
deleted file mode 100644
index 10ec67efaa6f..000000000000
--- a/contrib/gdb/bfd/bfd.c
+++ /dev/null
@@ -1,1144 +0,0 @@
-/* Generic BFD library interface and support routines.
- 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. */
-
-/*
-SECTION
- <<typedef bfd>>
-
- A BFD has type <<bfd>>; objects of this type are the
- cornerstone of any application using BFD. Using BFD
- consists of making references though the BFD and to data in the BFD.
-
- Here is the structure that defines the type <<bfd>>. It
- contains the major data about the file and pointers
- to the rest of the data.
-
-CODE_FRAGMENT
-.
-.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;
-.};
-.
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "coff/internal.h"
-#include "coff/sym.h"
-#include "libcoff.h"
-#include "libecoff.h"
-#undef obj_symbols
-#include "elf-bfd.h"
-
-#include <ctype.h>
-
-/* provide storage for subsystem, stack and heap data which may have been
- passed in on the command line. Ld puts this data into a bfd_link_info
- struct which ultimately gets passed in to the bfd. When it arrives, copy
- it to the following struct so that the data will be available in coffcode.h
- where it is needed. The typedef's used are defined in bfd.h */
-
-
-
-/*
-SECTION
- Error reporting
-
- Most BFD functions return nonzero on success (check their
- individual documentation for precise semantics). On an error,
- they call <<bfd_set_error>> to set an error condition that callers
- can check by calling <<bfd_get_error>>.
- If that returns <<bfd_error_system_call>>, then check
- <<errno>>.
-
- The easiest way to report a BFD error to the user is to
- use <<bfd_perror>>.
-
-SUBSECTION
- Type <<bfd_error_type>>
-
- The values returned by <<bfd_get_error>> are defined by the
- enumerated type <<bfd_error_type>>.
-
-CODE_FRAGMENT
-.
-.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;
-.
-*/
-
-#undef strerror
-extern char *strerror();
-
-static bfd_error_type bfd_error = bfd_error_no_error;
-
-CONST char *CONST bfd_errmsgs[] = {
- "No error",
- "System call error",
- "Invalid bfd target",
- "File in wrong format",
- "Invalid operation",
- "Memory exhausted",
- "No symbols",
- "Archive has no index; run ranlib to add one",
- "No more archived files",
- "Malformed archive",
- "File format not recognized",
- "File format is ambiguous",
- "Section has no contents",
- "Nonrepresentable section on output",
- "Symbol needs debug section which does not exist",
- "Bad value",
- "File truncated",
- "File too big",
- "#<Invalid error code>"
- };
-
-/*
-FUNCTION
- bfd_get_error
-
-SYNOPSIS
- bfd_error_type bfd_get_error (void);
-
-DESCRIPTION
- Return the current BFD error condition.
-*/
-
-bfd_error_type
-bfd_get_error ()
-{
- return bfd_error;
-}
-
-/*
-FUNCTION
- bfd_set_error
-
-SYNOPSIS
- void bfd_set_error (bfd_error_type error_tag);
-
-DESCRIPTION
- Set the BFD error condition to be @var{error_tag}.
-*/
-
-void
-bfd_set_error (error_tag)
- bfd_error_type error_tag;
-{
- bfd_error = error_tag;
-}
-
-/*
-FUNCTION
- bfd_errmsg
-
-SYNOPSIS
- CONST char *bfd_errmsg (bfd_error_type error_tag);
-
-DESCRIPTION
- Return a string describing the error @var{error_tag}, or
- the system error if @var{error_tag} is <<bfd_error_system_call>>.
-*/
-
-CONST char *
-bfd_errmsg (error_tag)
- bfd_error_type error_tag;
-{
-#ifndef errno
- extern int errno;
-#endif
- if (error_tag == bfd_error_system_call)
- {
- const char *errmsg;
-
- errmsg = strerror (errno);
- if (errmsg == NULL)
- {
- static char buf[32];
-
- sprintf (buf, "Error %d", errno);
- errmsg = buf;
- }
- return errmsg;
- }
-
- if ((((int)error_tag <(int) bfd_error_no_error) ||
- ((int)error_tag > (int)bfd_error_invalid_error_code)))
- error_tag = bfd_error_invalid_error_code;/* sanity check */
-
- return bfd_errmsgs [(int)error_tag];
-}
-
-/*
-FUNCTION
- bfd_perror
-
-SYNOPSIS
- void bfd_perror (CONST char *message);
-
-DESCRIPTION
- Print to the standard error stream a string describing the
- last BFD error that occurred, or the last system error if
- the last BFD error was a system call failure. If @var{message}
- is non-NULL and non-empty, the error string printed is preceded
- by @var{message}, a colon, and a space. It is followed by a newline.
-*/
-
-void
-bfd_perror (message)
- CONST char *message;
-{
- if (bfd_get_error () == bfd_error_system_call)
- perror((char *)message); /* must be system error then... */
- else {
- if (message == NULL || *message == '\0')
- fprintf (stderr, "%s\n", bfd_errmsg (bfd_get_error ()));
- else
- fprintf (stderr, "%s: %s\n", message, bfd_errmsg (bfd_get_error ()));
- }
-}
-
-/*
-SUBSECTION
- BFD error handler
-
- Some BFD functions want to print messages describing the
- problem. They call a BFD error handler function. This
- function may be overriden by the program.
-
- The BFD error handler acts like printf.
-
-CODE_FRAGMENT
-.
-.typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...));
-.
-*/
-
-/* The program name used when printing BFD error messages. */
-
-static const char *_bfd_error_program_name;
-
-/* This is the default routine to handle BFD error messages. */
-
-#ifdef ANSI_PROTOTYPES
-
-static void _bfd_default_error_handler PARAMS ((const char *s, ...));
-
-static void
-_bfd_default_error_handler (const char *s, ...)
-{
- va_list p;
-
- if (_bfd_error_program_name != NULL)
- fprintf (stderr, "%s: ", _bfd_error_program_name);
-
- va_start (p, s);
-
- vfprintf (stderr, s, p);
-
- va_end (p);
-
- fprintf (stderr, "\n");
-}
-
-#else /* ! defined (ANSI_PROTOTYPES) */
-
-static void _bfd_default_error_handler ();
-
-static void
-_bfd_default_error_handler (va_alist)
- va_dcl
-{
- va_list p;
- const char *s;
-
- if (_bfd_error_program_name != NULL)
- fprintf (stderr, "%s: ", _bfd_error_program_name);
-
- va_start (p);
-
- s = va_arg (p, const char *);
- vfprintf (stderr, s, p);
-
- va_end (p);
-
- fprintf (stderr, "\n");
-}
-
-#endif /* ! defined (ANSI_PROTOTYPES) */
-
-/* This is a function pointer to the routine which should handle BFD
- error messages. It is called when a BFD routine encounters an
- error for which it wants to print a message. Going through a
- function pointer permits a program linked against BFD to intercept
- the messages and deal with them itself. */
-
-bfd_error_handler_type _bfd_error_handler = _bfd_default_error_handler;
-
-/*
-FUNCTION
- bfd_set_error_handler
-
-SYNOPSIS
- bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type);
-
-DESCRIPTION
- Set the BFD error handler function. Returns the previous
- function.
-*/
-
-bfd_error_handler_type
-bfd_set_error_handler (pnew)
- bfd_error_handler_type pnew;
-{
- bfd_error_handler_type pold;
-
- pold = _bfd_error_handler;
- _bfd_error_handler = pnew;
- return pold;
-}
-
-/*
-FUNCTION
- bfd_set_error_program_name
-
-SYNOPSIS
- void bfd_set_error_program_name (const char *);
-
-DESCRIPTION
- Set the program name to use when printing a BFD error. This
- is printed before the error message followed by a colon and
- space. The string must not be changed after it is passed to
- this function.
-*/
-
-void
-bfd_set_error_program_name (name)
- const char *name;
-{
- _bfd_error_program_name = name;
-}
-
-/*
-SECTION
- Symbols
-*/
-
-/*
-FUNCTION
- bfd_get_reloc_upper_bound
-
-SYNOPSIS
- long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect);
-
-DESCRIPTION
- Return the number of bytes required to store the
- relocation information associated with section @var{sect}
- attached to bfd @var{abfd}. If an error occurs, return -1.
-
-*/
-
-
-long
-bfd_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- if (abfd->format != bfd_object) {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
-
- return BFD_SEND (abfd, _get_reloc_upper_bound, (abfd, asect));
-}
-
-/*
-FUNCTION
- bfd_canonicalize_reloc
-
-SYNOPSIS
- long bfd_canonicalize_reloc
- (bfd *abfd,
- asection *sec,
- arelent **loc,
- asymbol **syms);
-
-DESCRIPTION
- Call the back end associated with the open BFD
- @var{abfd} and translate the external form of the relocation
- information attached to @var{sec} into the internal canonical
- form. Place the table into memory at @var{loc}, which has
- been preallocated, usually by a call to
- <<bfd_get_reloc_upper_bound>>. Returns the number of relocs, or
- -1 on error.
-
- The @var{syms} table is also needed for horrible internal magic
- reasons.
-
-
-*/
-long
-bfd_canonicalize_reloc (abfd, asect, location, symbols)
- bfd *abfd;
- sec_ptr asect;
- arelent **location;
- asymbol **symbols;
-{
- if (abfd->format != bfd_object) {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
- return BFD_SEND (abfd, _bfd_canonicalize_reloc,
- (abfd, asect, location, symbols));
-}
-
-/*
-FUNCTION
- bfd_set_reloc
-
-SYNOPSIS
- void bfd_set_reloc
- (bfd *abfd, asection *sec, arelent **rel, unsigned int count)
-
-DESCRIPTION
- Set the relocation pointer and count within
- section @var{sec} to the values @var{rel} and @var{count}.
- The argument @var{abfd} is ignored.
-
-*/
-/*ARGSUSED*/
-void
-bfd_set_reloc (ignore_abfd, asect, location, count)
- bfd *ignore_abfd;
- sec_ptr asect;
- arelent **location;
- unsigned int count;
-{
- asect->orelocation = location;
- asect->reloc_count = count;
-}
-
-/*
-FUNCTION
- bfd_set_file_flags
-
-SYNOPSIS
- boolean bfd_set_file_flags(bfd *abfd, flagword flags);
-
-DESCRIPTION
- Set the flag word in the BFD @var{abfd} to the value @var{flags}.
-
- Possible errors are:
- o <<bfd_error_wrong_format>> - The target bfd was not of object format.
- o <<bfd_error_invalid_operation>> - The target bfd was open for reading.
- o <<bfd_error_invalid_operation>> -
- The flag word contained a bit which was not applicable to the
- type of file. E.g., an attempt was made to set the <<D_PAGED>> bit
- on a BFD format which does not support demand paging.
-
-*/
-
-boolean
-bfd_set_file_flags (abfd, flags)
- bfd *abfd;
- flagword flags;
-{
- if (abfd->format != bfd_object) {
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- if (bfd_read_p (abfd)) {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- bfd_get_file_flags (abfd) = flags;
- if ((flags & bfd_applicable_file_flags (abfd)) != flags) {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
-return true;
-}
-
-void
-bfd_assert (file, line)
- const char *file;
- int line;
-{
- (*_bfd_error_handler) ("bfd assertion fail %s:%d", file, line);
-}
-
-
-/*
-FUNCTION
- bfd_set_start_address
-
-SYNOPSIS
- boolean bfd_set_start_address(bfd *abfd, bfd_vma vma);
-
-DESCRIPTION
- Make @var{vma} the entry point of output BFD @var{abfd}.
-
-RETURNS
- Returns <<true>> on success, <<false>> otherwise.
-*/
-
-boolean
-bfd_set_start_address(abfd, vma)
-bfd *abfd;
-bfd_vma vma;
-{
- abfd->start_address = vma;
- return true;
-}
-
-
-/*
-FUNCTION
- bfd_get_mtime
-
-SYNOPSIS
- long bfd_get_mtime(bfd *abfd);
-
-DESCRIPTION
- Return the file modification time (as read from the file system, or
- from the archive header for archive members).
-
-*/
-
-long
-bfd_get_mtime (abfd)
- bfd *abfd;
-{
- FILE *fp;
- struct stat buf;
-
- if (abfd->mtime_set)
- return abfd->mtime;
-
- fp = bfd_cache_lookup (abfd);
- if (0 != fstat (fileno (fp), &buf))
- return 0;
-
- abfd->mtime = buf.st_mtime; /* Save value in case anyone wants it */
- return buf.st_mtime;
-}
-
-/*
-FUNCTION
- bfd_get_size
-
-SYNOPSIS
- long bfd_get_size(bfd *abfd);
-
-DESCRIPTION
- Return the file size (as read from file system) for the file
- associated with BFD @var{abfd}.
-
- The initial motivation for, and use of, this routine is not
- so we can get the exact size of the object the BFD applies to, since
- that might not be generally possible (archive members for example).
- It would be ideal if someone could eventually modify
- it so that such results were guaranteed.
-
- Instead, we want to ask questions like "is this NNN byte sized
- object I'm about to try read from file offset YYY reasonable?"
- As as example of where we might do this, some object formats
- use string tables for which the first <<sizeof(long)>> bytes of the
- table contain the size of the table itself, including the size bytes.
- If an application tries to read what it thinks is one of these
- string tables, without some way to validate the size, and for
- some reason the size is wrong (byte swapping error, wrong location
- for the string table, etc.), the only clue is likely to be a read
- error when it tries to read the table, or a "virtual memory
- exhausted" error when it tries to allocate 15 bazillon bytes
- of space for the 15 bazillon byte table it is about to read.
- This function at least allows us to answer the quesion, "is the
- size reasonable?".
-*/
-
-long
-bfd_get_size (abfd)
- bfd *abfd;
-{
- FILE *fp;
- struct stat buf;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- return ((struct bfd_in_memory *) abfd->iostream)->size;
-
- fp = bfd_cache_lookup (abfd);
- if (0 != fstat (fileno (fp), &buf))
- return 0;
-
- return buf.st_size;
-}
-
-/*
-FUNCTION
- bfd_get_gp_size
-
-SYNOPSIS
- int bfd_get_gp_size(bfd *abfd);
-
-DESCRIPTION
- Return the maximum size of objects to be optimized using the GP
- register under MIPS ECOFF. This is typically set by the <<-G>>
- argument to the compiler, assembler or linker.
-*/
-
-int
-bfd_get_gp_size (abfd)
- bfd *abfd;
-{
- if (abfd->format == bfd_object)
- {
- if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
- return ecoff_data (abfd)->gp_size;
- else if (abfd->xvec->flavour == bfd_target_elf_flavour)
- return elf_gp_size (abfd);
- }
- return 0;
-}
-
-/*
-FUNCTION
- bfd_set_gp_size
-
-SYNOPSIS
- void bfd_set_gp_size(bfd *abfd, int i);
-
-DESCRIPTION
- Set the maximum size of objects to be optimized using the GP
- register under ECOFF or MIPS ELF. This is typically set by
- the <<-G>> argument to the compiler, assembler or linker.
-*/
-
-void
-bfd_set_gp_size (abfd, i)
- bfd *abfd;
- int i;
-{
- /* Don't try to set GP size on an archive or core file! */
- if (abfd->format != bfd_object)
- return;
- if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
- ecoff_data (abfd)->gp_size = i;
- else if (abfd->xvec->flavour == bfd_target_elf_flavour)
- elf_gp_size (abfd) = i;
-}
-
-/* Get the GP value. This is an internal function used by some of the
- relocation special_function routines on targets which support a GP
- register. */
-
-bfd_vma
-_bfd_get_gp_value (abfd)
- bfd *abfd;
-{
- if (abfd->format == bfd_object)
- {
- if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
- return ecoff_data (abfd)->gp;
- else if (abfd->xvec->flavour == bfd_target_elf_flavour)
- return elf_gp (abfd);
- }
- return 0;
-}
-
-/* Set the GP value. */
-
-void
-_bfd_set_gp_value (abfd, v)
- bfd *abfd;
- bfd_vma v;
-{
- if (abfd->format != bfd_object)
- return;
- if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
- ecoff_data (abfd)->gp = v;
- else if (abfd->xvec->flavour == bfd_target_elf_flavour)
- elf_gp (abfd) = v;
-}
-
-/*
-FUNCTION
- bfd_scan_vma
-
-SYNOPSIS
- bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base);
-
-DESCRIPTION
- Convert, like <<strtoul>>, a numerical expression
- @var{string} into a <<bfd_vma>> integer, and return that integer.
- (Though without as many bells and whistles as <<strtoul>>.)
- The expression is assumed to be unsigned (i.e., positive).
- If given a @var{base}, it is used as the base for conversion.
- A base of 0 causes the function to interpret the string
- in hex if a leading "0x" or "0X" is found, otherwise
- in octal if a leading zero is found, otherwise in decimal.
-
- Overflow is not detected.
-*/
-
-bfd_vma
-bfd_scan_vma (string, end, base)
- CONST char *string;
- CONST char **end;
- int base;
-{
- bfd_vma value;
- int digit;
-
- /* Let the host do it if possible. */
- if (sizeof(bfd_vma) <= sizeof(unsigned long))
- return (bfd_vma) strtoul (string, (char **) end, base);
-
- /* A negative base makes no sense, and we only need to go as high as hex. */
- if ((base < 0) || (base > 16))
- return (bfd_vma) 0;
-
- if (base == 0)
- {
- if (string[0] == '0')
- {
- if ((string[1] == 'x') || (string[1] == 'X'))
- base = 16;
- /* XXX should we also allow "0b" or "0B" to set base to 2? */
- else
- base = 8;
- }
- else
- base = 10;
- }
- if ((base == 16) &&
- (string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X')))
- string += 2;
- /* XXX should we also skip over "0b" or "0B" if base is 2? */
-
-/* Speed could be improved with a table like hex_value[] in gas. */
-#define HEX_VALUE(c) \
- (isxdigit(c) ? \
- (isdigit(c) ? \
- (c - '0') : \
- (10 + c - (islower(c) ? 'a' : 'A'))) : \
- 42)
-
- for (value = 0; (digit = HEX_VALUE(*string)) < base; string++)
- {
- value = value * base + digit;
- }
-
- if (end)
- *end = string;
-
- return value;
-}
-
-/*
-FUNCTION
- bfd_copy_private_bfd_data
-
-SYNOPSIS
- boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd);
-
-DESCRIPTION
- Copy private BFD information from the BFD @var{ibfd} to the
- the BFD @var{obfd}. Return <<true>> on success, <<false>> on error.
- Possible error returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{obfd}.
-
-.#define bfd_copy_private_bfd_data(ibfd, obfd) \
-. BFD_SEND (ibfd, _bfd_copy_private_bfd_data, \
-. (ibfd, obfd))
-
-*/
-
-/*
-FUNCTION
- bfd_merge_private_bfd_data
-
-SYNOPSIS
- boolean bfd_merge_private_bfd_data(bfd *ibfd, bfd *obfd);
-
-DESCRIPTION
- Merge private BFD information from the BFD @var{ibfd} to the
- the output file BFD @var{obfd} when linking. Return <<true>>
- on success, <<false>> on error. Possible error returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{obfd}.
-
-.#define bfd_merge_private_bfd_data(ibfd, obfd) \
-. BFD_SEND (ibfd, _bfd_merge_private_bfd_data, \
-. (ibfd, obfd))
-
-*/
-
-/*
-FUNCTION
- bfd_set_private_flags
-
-SYNOPSIS
- boolean bfd_set_private_flags(bfd *abfd, flagword flags);
-
-DESCRIPTION
- Set private BFD flag information in the BFD @var{abfd}.
- Return <<true>> on success, <<false>> on error. Possible error
- returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{obfd}.
-
-.#define bfd_set_private_flags(abfd, flags) \
-. BFD_SEND (abfd, _bfd_set_private_flags, \
-. (abfd, flags))
-
-*/
-
-/*
-FUNCTION
- stuff
-
-DESCRIPTION
- Stuff which should be documented:
-
-.#define bfd_sizeof_headers(abfd, reloc) \
-. BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
-.
-.#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
-. BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line))
-.
-. {* Do these three do anything useful at all, for any back end? *}
-.#define bfd_debug_info_start(abfd) \
-. BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
-.
-.#define bfd_debug_info_end(abfd) \
-. BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
-.
-.#define bfd_debug_info_accumulate(abfd, section) \
-. BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
-.
-.
-.#define bfd_stat_arch_elt(abfd, stat) \
-. BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
-.
-.#define bfd_update_armap_timestamp(abfd) \
-. BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
-.
-.#define bfd_set_arch_mach(abfd, arch, mach)\
-. BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
-.
-.#define bfd_relax_section(abfd, section, link_info, again) \
-. BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
-.
-.#define bfd_link_hash_table_create(abfd) \
-. BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
-.
-.#define bfd_link_add_symbols(abfd, info) \
-. BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
-.
-.#define bfd_final_link(abfd, info) \
-. BFD_SEND (abfd, _bfd_final_link, (abfd, info))
-.
-.#define bfd_free_cached_info(abfd) \
-. BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
-.
-.#define bfd_get_dynamic_symtab_upper_bound(abfd) \
-. BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
-.
-.#define bfd_print_private_bfd_data(abfd, file)\
-. BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
-.
-.#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
-. BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
-.
-.#define bfd_get_dynamic_reloc_upper_bound(abfd) \
-. BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
-.
-.#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
-. BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
-.
-.extern bfd_byte *bfd_get_relocated_section_contents
-. PARAMS ((bfd *, struct bfd_link_info *,
-. struct bfd_link_order *, bfd_byte *,
-. boolean, asymbol **));
-.
-
-*/
-
-bfd_byte *
-bfd_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 *abfd2;
- bfd_byte *(*fn) PARAMS ((bfd *, struct bfd_link_info *,
- struct bfd_link_order *, bfd_byte *, boolean,
- asymbol **));
-
- if (link_order->type == bfd_indirect_link_order)
- {
- abfd2 = link_order->u.indirect.section->owner;
- if (abfd2 == 0)
- abfd2 = abfd;
- }
- else
- abfd2 = abfd;
- fn = abfd2->xvec->_bfd_get_relocated_section_contents;
-
- return (*fn) (abfd, link_info, link_order, data, relocateable, symbols);
-}
-
-/* Record information about an ELF program header. */
-
-boolean
-bfd_record_phdr (abfd, type, flags_valid, flags, at_valid, at,
- includes_filehdr, includes_phdrs, count, secs)
- bfd *abfd;
- unsigned long type;
- boolean flags_valid;
- flagword flags;
- boolean at_valid;
- bfd_vma at;
- boolean includes_filehdr;
- boolean includes_phdrs;
- unsigned int count;
- asection **secs;
-{
- struct elf_segment_map *m, **pm;
-
- if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
- return true;
-
- m = ((struct elf_segment_map *)
- bfd_alloc (abfd,
- (sizeof (struct elf_segment_map)
- + (count - 1) * sizeof (asection *))));
- if (m == NULL)
- return false;
-
- m->next = NULL;
- m->p_type = type;
- m->p_flags = flags;
- m->p_paddr = at;
- m->p_flags_valid = flags_valid;
- m->p_paddr_valid = at_valid;
- m->includes_filehdr = includes_filehdr;
- m->includes_phdrs = includes_phdrs;
- m->count = count;
- if (count > 0)
- memcpy (m->sections, secs, count * sizeof (asection *));
-
- for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next)
- ;
- *pm = m;
-
- return true;
-}
diff --git a/contrib/gdb/bfd/binary.c b/contrib/gdb/bfd/binary.c
deleted file mode 100644
index a480e464e96b..000000000000
--- a/contrib/gdb/bfd/binary.c
+++ /dev/null
@@ -1,348 +0,0 @@
-/* BFD back-end for binary objects.
- Copyright 1994 Free Software Foundation, Inc.
- Written 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 is a BFD backend which may be used to write binary objects.
- It may only be used for output, not input. The intention is that
- this may be used as an output format for objcopy in order to
- generate raw binary data.
-
- This is very simple. The only complication is that the real data
- will start at some address X, and in some cases we will not want to
- include X zeroes just to get to that point. Since the start
- address is not meaningful for this object file format, we use it
- instead to indicate the number of zeroes to skip at the start of
- the file. objcopy cooperates by specially setting the start
- address to zero by default. */
-
-#include <ctype.h>
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/* Any bfd we create by reading a binary file has three symbols:
- a start symbol, an end symbol, and an absolute length symbol. */
-#define BIN_SYMS 3
-
-static boolean binary_mkobject PARAMS ((bfd *));
-static const bfd_target *binary_object_p PARAMS ((bfd *));
-static boolean binary_get_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static long binary_get_symtab_upper_bound PARAMS ((bfd *));
-static char *mangle_name PARAMS ((bfd *, char *));
-static long binary_get_symtab PARAMS ((bfd *, asymbol **));
-static asymbol *binary_make_empty_symbol PARAMS ((bfd *));
-static void binary_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
-static boolean binary_set_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static int binary_sizeof_headers PARAMS ((bfd *, boolean));
-
-/* Create a binary object. Invoked via bfd_set_format. */
-
-static boolean
-binary_mkobject (abfd)
- bfd *abfd;
-{
- return true;
-}
-
-/* Any file may be considered to be a binary file, provided the target
- was not defaulted. That is, it must be explicitly specified as
- being binary. */
-
-static const bfd_target *
-binary_object_p (abfd)
- bfd *abfd;
-{
- struct stat statbuf;
- asection *sec;
-
- if (abfd->target_defaulted)
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- abfd->symcount = BIN_SYMS;
-
- /* Find the file size. */
- if (bfd_stat (abfd, &statbuf) < 0)
- {
- bfd_set_error (bfd_error_system_call);
- return NULL;
- }
-
- /* One data section. */
- sec = bfd_make_section (abfd, ".data");
- if (sec == NULL)
- return NULL;
- sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
- sec->vma = 0;
- sec->_raw_size = statbuf.st_size;
- sec->filepos = 0;
-
- abfd->tdata.any = (PTR) sec;
-
- return abfd->xvec;
-}
-
-#define binary_close_and_cleanup _bfd_generic_close_and_cleanup
-#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define binary_new_section_hook _bfd_generic_new_section_hook
-
-/* Get contents of the only section. */
-
-static boolean
-binary_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (bfd_seek (abfd, offset, SEEK_SET) != 0
- || bfd_read (location, 1, count, abfd) != count)
- return false;
- return true;
-}
-
-/* Return the amount of memory needed to read the symbol table. */
-
-static long
-binary_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- return (BIN_SYMS + 1) * sizeof (asymbol *);
-}
-
-/* Create a symbol name based on the bfd's filename. */
-
-static char *
-mangle_name (abfd, suffix)
- bfd *abfd;
- char *suffix;
-{
- int size;
- char *buf;
- char *p;
-
- size = (strlen (bfd_get_filename (abfd))
- + strlen (suffix)
- + sizeof "_binary__");
-
- buf = (char *) bfd_alloc (abfd, size);
- if (buf == NULL)
- return "";
-
- sprintf (buf, "_binary_%s_%s", bfd_get_filename (abfd), suffix);
-
- /* Change any non-alphanumeric characters to underscores. */
- for (p = buf; *p; p++)
- if (! isalnum (*p))
- *p = '_';
-
- return buf;
-}
-
-/* Return the symbol table. */
-
-static long
-binary_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- asection *sec = (asection *) abfd->tdata.any;
- asymbol *syms;
- unsigned int i;
-
- syms = (asymbol *) bfd_alloc (abfd, BIN_SYMS * sizeof (asymbol));
- if (syms == NULL)
- return false;
-
- /* Start symbol. */
- syms[0].the_bfd = abfd;
- syms[0].name = mangle_name (abfd, "start");
- syms[0].value = 0;
- syms[0].flags = BSF_GLOBAL;
- syms[0].section = sec;
- syms[0].udata.p = NULL;
-
- /* End symbol. */
- syms[1].the_bfd = abfd;
- syms[1].name = mangle_name (abfd, "end");
- syms[1].value = sec->_raw_size;
- syms[1].flags = BSF_GLOBAL;
- syms[1].section = sec;
- syms[1].udata.p = NULL;
-
- /* Size symbol. */
- syms[2].the_bfd = abfd;
- syms[2].name = mangle_name (abfd, "size");
- syms[2].value = sec->_raw_size;
- syms[2].flags = BSF_GLOBAL;
- syms[2].section = bfd_abs_section_ptr;
- syms[2].udata.p = NULL;
-
- for (i = 0; i < BIN_SYMS; i++)
- *alocation++ = syms++;
- *alocation = NULL;
-
- return BIN_SYMS;
-}
-
-/* Make an empty symbol. */
-
-static asymbol *
-binary_make_empty_symbol (abfd)
- bfd *abfd;
-{
- return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
-}
-
-#define binary_print_symbol _bfd_nosymbols_print_symbol
-
-/* Get information about a symbol. */
-
-static void
-binary_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-#define binary_bfd_is_local_label bfd_generic_is_local_label
-#define binary_get_lineno _bfd_nosymbols_get_lineno
-#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define binary_read_minisymbols _bfd_generic_read_minisymbols
-#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define binary_get_reloc_upper_bound \
- ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
-#define binary_canonicalize_reloc \
- ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
-#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-/* Set the architecture of a binary file. */
-#define binary_set_arch_mach _bfd_generic_set_arch_mach
-
-/* Write section contents of a binary file. */
-
-static boolean
-binary_set_section_contents (abfd, sec, data, offset, size)
- bfd *abfd;
- asection *sec;
- PTR data;
- file_ptr offset;
- bfd_size_type size;
-{
- if (! abfd->output_has_begun)
- {
- bfd_vma low;
- asection *s;
-
- /* The lowest section VMA sets the virtual address of the start
- of the file. We use the set the file position of all the
- sections. */
- low = abfd->sections->vma;
- for (s = abfd->sections->next; s != NULL; s = s->next)
- if (s->vma < low)
- low = s->vma;
-
- for (s = abfd->sections; s != NULL; s = s->next)
- s->filepos = s->vma - low;
-
- abfd->output_has_begun = true;
- }
-
- return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
-}
-
-/* No space is required for header information. */
-
-static int
-binary_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-{
- return 0;
-}
-
-#define binary_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define binary_bfd_relax_section bfd_generic_relax_section
-#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define binary_bfd_final_link _bfd_generic_final_link
-#define binary_bfd_link_split_section _bfd_generic_link_split_section
-#define binary_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-const bfd_target binary_vec =
-{
- "binary", /* name */
- bfd_target_unknown_flavour, /* flavour */
- BFD_ENDIAN_UNKNOWN, /* byteorder */
- BFD_ENDIAN_UNKNOWN, /* header_byteorder */
- EXEC_P, /* object_flags */
- (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
- | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
- 0, /* 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_check_format */
- _bfd_dummy_target,
- binary_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- { /* bfd_set_format */
- bfd_false,
- binary_mkobject,
- bfd_false,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- bfd_true,
- bfd_false,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (binary),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (binary),
- BFD_JUMP_TABLE_RELOCS (binary),
- BFD_JUMP_TABLE_WRITE (binary),
- BFD_JUMP_TABLE_LINK (binary),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- NULL
-};
diff --git a/contrib/gdb/bfd/bout.c b/contrib/gdb/bfd/bout.c
deleted file mode 100644
index 9da4b825b02a..000000000000
--- 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/cache.c b/contrib/gdb/bfd/cache.c
deleted file mode 100644
index ef15877ccd57..000000000000
--- a/contrib/gdb/bfd/cache.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/* BFD library -- caching of file descriptors.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SECTION
- File caching
-
- The file caching mechanism is embedded within BFD and allows
- the application to open as many BFDs as it wants without
- regard to the underlying operating system's file descriptor
- limit (often as low as 20 open files). The module in
- <<cache.c>> maintains a least recently used list of
- <<BFD_CACHE_MAX_OPEN>> files, and exports the name
- <<bfd_cache_lookup>>, which runs around and makes sure that
- the required BFD is open. If not, then it chooses a file to
- close, closes it and opens the one wanted, returning its file
- handle.
-
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-static void insert PARAMS ((bfd *));
-static void snip PARAMS ((bfd *));
-static boolean close_one PARAMS ((void));
-static boolean bfd_cache_delete PARAMS ((bfd *));
-
-/*
-INTERNAL_FUNCTION
- BFD_CACHE_MAX_OPEN macro
-
-DESCRIPTION
- The maximum number of files which the cache will keep open at
- one time.
-
-.#define BFD_CACHE_MAX_OPEN 10
-
-*/
-
-/* The number of BFD files we have open. */
-
-static int open_files;
-
-/*
-INTERNAL_FUNCTION
- bfd_last_cache
-
-SYNOPSIS
- extern bfd *bfd_last_cache;
-
-DESCRIPTION
- Zero, or a pointer to the topmost BFD on the chain. This is
- used by the <<bfd_cache_lookup>> macro in @file{libbfd.h} to
- determine when it can avoid a function call.
-*/
-
-bfd *bfd_last_cache;
-
-/*
- INTERNAL_FUNCTION
- bfd_cache_lookup
-
- DESCRIPTION
- Check to see if the required BFD is the same as the last one
- looked up. If so, then it can use the stream in the BFD with
- impunity, since it can't have changed since the last lookup;
- otherwise, it has to perform the complicated lookup function.
-
- .#define bfd_cache_lookup(x) \
- . ((x)==bfd_last_cache? \
- . (FILE*)(bfd_last_cache->iostream): \
- . bfd_cache_lookup_worker(x))
-
-
- */
-
-/* Insert a BFD into the cache. */
-
-static INLINE void
-insert (abfd)
- bfd *abfd;
-{
- if (bfd_last_cache == NULL)
- {
- abfd->lru_next = abfd;
- abfd->lru_prev = abfd;
- }
- else
- {
- abfd->lru_next = bfd_last_cache;
- abfd->lru_prev = bfd_last_cache->lru_prev;
- abfd->lru_prev->lru_next = abfd;
- abfd->lru_next->lru_prev = abfd;
- }
- bfd_last_cache = abfd;
-}
-
-/* Remove a BFD from the cache. */
-
-static INLINE void
-snip (abfd)
- bfd *abfd;
-{
- abfd->lru_prev->lru_next = abfd->lru_next;
- abfd->lru_next->lru_prev = abfd->lru_prev;
- if (abfd == bfd_last_cache)
- {
- bfd_last_cache = abfd->lru_next;
- if (abfd == bfd_last_cache)
- bfd_last_cache = NULL;
- }
-}
-
-/* We need to open a new file, and the cache is full. Find the least
- recently used cacheable BFD and close it. */
-
-static boolean
-close_one ()
-{
- register bfd *kill;
-
- if (bfd_last_cache == NULL)
- kill = NULL;
- else
- {
- for (kill = bfd_last_cache->lru_prev;
- ! kill->cacheable;
- kill = kill->lru_prev)
- {
- if (kill == bfd_last_cache)
- {
- kill = NULL;
- break;
- }
- }
- }
-
- if (kill == NULL)
- {
- /* There are no open cacheable BFD's. */
- return true;
- }
-
- kill->where = ftell ((FILE *) kill->iostream);
-
- return bfd_cache_delete (kill);
-}
-
-/* Close a BFD and remove it from the cache. */
-
-static boolean
-bfd_cache_delete (abfd)
- bfd *abfd;
-{
- boolean ret;
-
- if (fclose ((FILE *) abfd->iostream) == 0)
- ret = true;
- else
- {
- ret = false;
- bfd_set_error (bfd_error_system_call);
- }
-
- snip (abfd);
-
- abfd->iostream = NULL;
- --open_files;
-
- return ret;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_cache_init
-
-SYNOPSIS
- boolean bfd_cache_init (bfd *abfd);
-
-DESCRIPTION
- Add a newly opened BFD to the cache.
-*/
-
-boolean
-bfd_cache_init (abfd)
- bfd *abfd;
-{
- BFD_ASSERT (abfd->iostream != NULL);
- if (open_files >= BFD_CACHE_MAX_OPEN)
- {
- if (! close_one ())
- return false;
- }
- insert (abfd);
- ++open_files;
- return true;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_cache_close
-
-SYNOPSIS
- boolean bfd_cache_close (bfd *abfd);
-
-DESCRIPTION
- Remove the BFD @var{abfd} from the cache. If the attached file is open,
- then close it too.
-
-RETURNS
- <<false>> is returned if closing the file fails, <<true>> is
- returned if all is well.
-*/
-
-boolean
-bfd_cache_close (abfd)
- bfd *abfd;
-{
- if (abfd->iostream == NULL
- || (abfd->flags & BFD_IN_MEMORY) != 0)
- return true;
-
- return bfd_cache_delete (abfd);
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_open_file
-
-SYNOPSIS
- FILE* bfd_open_file(bfd *abfd);
-
-DESCRIPTION
- Call the OS to open a file for @var{abfd}. Return the <<FILE *>>
- (possibly <<NULL>>) that results from this operation. Set up the
- BFD so that future accesses know the file is open. If the <<FILE *>>
- returned is <<NULL>>, then it won't have been put in the
- cache, so it won't have to be removed from it.
-*/
-
-FILE *
-bfd_open_file (abfd)
- bfd *abfd;
-{
- abfd->cacheable = true; /* Allow it to be closed later. */
-
- if (open_files >= BFD_CACHE_MAX_OPEN)
- {
- if (! close_one ())
- return NULL;
- }
-
- switch (abfd->direction)
- {
- case read_direction:
- case no_direction:
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RB);
- break;
- case both_direction:
- case write_direction:
- if (abfd->opened_once == true)
- {
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RUB);
- if (abfd->iostream == NULL)
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
- }
- else
- {
- /*open for creat */
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WB);
- abfd->opened_once = true;
- }
- break;
- }
-
- if (abfd->iostream != NULL)
- {
- if (! bfd_cache_init (abfd))
- return NULL;
- }
-
- return (FILE *) abfd->iostream;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_cache_lookup_worker
-
-SYNOPSIS
- FILE *bfd_cache_lookup_worker(bfd *abfd);
-
-DESCRIPTION
- Called when the macro <<bfd_cache_lookup>> fails to find a
- quick answer. Find a file descriptor for @var{abfd}. If
- necessary, it open it. If there are already more than
- <<BFD_CACHE_MAX_OPEN>> files open, it tries to close one first, to
- avoid running out of file descriptors.
-*/
-
-FILE *
-bfd_cache_lookup_worker (abfd)
- bfd *abfd;
-{
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- abort ();
-
- if (abfd->my_archive)
- abfd = abfd->my_archive;
-
- if (abfd->iostream != NULL)
- {
- /* Move the file to the start of the cache. */
- if (abfd != bfd_last_cache)
- {
- snip (abfd);
- insert (abfd);
- }
- }
- else
- {
- if (bfd_open_file (abfd) == NULL)
- return NULL;
- if (fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
- return NULL;
- }
-
- return (FILE *) abfd->iostream;
-}
diff --git a/contrib/gdb/bfd/cf-i386lynx.c b/contrib/gdb/bfd/cf-i386lynx.c
deleted file mode 100644
index 2a14bde8f12d..000000000000
--- 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 8149dc68319a..000000000000
--- 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 774a099fefbc..000000000000
--- 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 a25115cc5238..000000000000
--- 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 3ceabfba5c46..000000000000
--- 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 b14f3ef207b6..000000000000
--- 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 561b1c7ab62f..000000000000
--- 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 bb16b046ae14..000000000000
--- 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 1dba9d5c465a..000000000000
--- 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 be4adb24f529..000000000000
--- 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 48d0d5a213b7..000000000000
--- 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 f416f8fa2825..000000000000
--- 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-i386.c b/contrib/gdb/bfd/coff-i386.c
deleted file mode 100644
index d905b53cda83..000000000000
--- a/contrib/gdb/bfd/coff-i386.c
+++ /dev/null
@@ -1,493 +0,0 @@
-/* BFD back-end for Intel 386 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/i386.h"
-
-#include "coff/internal.h"
-
-#ifdef COFF_WITH_PE
-#include "coff/pe.h"
-#endif
-
-#include "libcoff.h"
-
-static bfd_reloc_status_type coff_i386_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static reloc_howto_type *coff_i386_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 i386 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_i386_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 386
- COFF, so we handle the addend here instead. */
- diff = reloc_entry->addend;
- }
-
-
-#ifdef COFF_WITH_PE
- if (reloc_entry->howto->type == 7)
- {
-/* diff -= coff_data(output_bfd)->link_info->pe_info.image_base.value;*/
- exit(1);
- }
-#endif
-
-#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;
-}
-
-#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 != R_IMAGEBASE;
-}
-#endif
-
-#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_i386_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_i386_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_i386_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_i386_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_i386_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_i386_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_i386_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_i386_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) I386BADMAG(x)
-#define I386 1 /* Customize coffcode.h */
-
-#define RTYPE2HOWTO(cache_ptr, dst) \
- (cache_ptr)->howto = howto_table + (dst)->r_type;
-
-/* For 386 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_i386_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;
-
-#ifdef COFF_WITH_PE
- *addendp = 0;
-#endif
-
- 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);
-
-
-#ifndef COFF_WITH_PE
- /* 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;
-#endif
- }
-
- /* 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;
-
-
-#ifdef COFF_WITH_PE
- if (howto->pc_relative)
- *addendp -= 4;
-
- if (rel->r_type == R_IMAGEBASE)
- {
- *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
- }
-#endif
-
- return howto;
-}
-
-
-#define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
-
-
-static reloc_howto_type *
-coff_i386_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- switch (code)
- {
- case BFD_RELOC_RVA:
- return howto_table +R_IMAGEBASE;
- case BFD_RELOC_32:
- return howto_table + R_DIR32;
- case BFD_RELOC_32_PCREL:
- return howto_table + R_PCRLONG;
- default:
- BFD_FAIL ();
- return 0;
- }
-}
-
-
-
-#define coff_rtype_to_howto coff_i386_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
- i386coff_vec =
-#endif
-{
-#ifdef TARGET_NAME
- TARGET_NAME,
-#else
- "coff-i386", /* 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 */
-#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, 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-i860.c b/contrib/gdb/bfd/coff-i860.c
deleted file mode 100644
index 9605cdf0b852..000000000000
--- 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 ed30125f0fa4..000000000000
--- 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 77fb45b6d640..000000000000
--- 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 414106d7bcb0..000000000000
--- 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 c860f9a4d539..000000000000
--- 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 f3332d98959b..000000000000
--- 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 4caf3d8dc01d..000000000000
--- 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 c065bd4f0054..000000000000
--- 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 17bb4b17d817..000000000000
--- 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 b9bc595dc5ab..000000000000
--- 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 97ea73fa9c62..000000000000
--- 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 a02243f1d1b9..000000000000
--- 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 36f1fa17fded..000000000000
--- 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 5609d35d0f22..000000000000
--- 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/coffcode.h b/contrib/gdb/bfd/coffcode.h
deleted file mode 100644
index 22babd0d0c7f..000000000000
--- a/contrib/gdb/bfd/coffcode.h
+++ /dev/null
@@ -1,3612 +0,0 @@
-/* Support for the generic parts of most COFF variants, for BFD.
- 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. */
-
-/*
-Most of this hacked by Steve Chamberlain,
- sac@cygnus.com
-*/
-/*
-
-SECTION
- coff backends
-
- BFD supports a number of different flavours of coff format.
- The major differences between formats are the sizes and
- alignments of fields in structures on disk, and the occasional
- extra field.
-
- Coff in all its varieties is implemented with a few common
- files and a number of implementation specific files. For
- example, The 88k bcs coff format is implemented in the file
- @file{coff-m88k.c}. This file @code{#include}s
- @file{coff/m88k.h} which defines the external structure of the
- coff format for the 88k, and @file{coff/internal.h} which
- defines the internal structure. @file{coff-m88k.c} also
- defines the relocations used by the 88k format
- @xref{Relocations}.
-
- The Intel i960 processor version of coff is implemented in
- @file{coff-i960.c}. This file has the same structure as
- @file{coff-m88k.c}, except that it includes @file{coff/i960.h}
- rather than @file{coff-m88k.h}.
-
-SUBSECTION
- Porting to a new version of coff
-
- The recommended method is to select from the existing
- implementations the version of coff which is most like the one
- you want to use. For example, we'll say that i386 coff is
- the one you select, and that your coff flavour is called foo.
- Copy @file{i386coff.c} to @file{foocoff.c}, copy
- @file{../include/coff/i386.h} to @file{../include/coff/foo.h},
- and add the lines to @file{targets.c} and @file{Makefile.in}
- so that your new back end is used. Alter the shapes of the
- structures in @file{../include/coff/foo.h} so that they match
- what you need. You will probably also have to add
- @code{#ifdef}s to the code in @file{coff/internal.h} and
- @file{coffcode.h} if your version of coff is too wild.
-
- You can verify that your new BFD backend works quite simply by
- building @file{objdump} from the @file{binutils} directory,
- and making sure that its version of what's going on and your
- host system's idea (assuming it has the pretty standard coff
- dump utility, usually called @code{att-dump} or just
- @code{dump}) are the same. Then clean up your code, and send
- what you've done to Cygnus. Then your stuff will be in the
- next release, and you won't have to keep integrating it.
-
-SUBSECTION
- How the coff backend works
-
-SUBSUBSECTION
- File layout
-
- The Coff backend is split into generic routines that are
- applicable to any Coff target and routines that are specific
- to a particular target. The target-specific routines are
- further split into ones which are basically the same for all
- Coff targets except that they use the external symbol format
- or use different values for certain constants.
-
- The generic routines are in @file{coffgen.c}. These routines
- work for any Coff target. They use some hooks into the target
- specific code; the hooks are in a @code{bfd_coff_backend_data}
- structure, one of which exists for each target.
-
- The essentially similar target-specific routines are in
- @file{coffcode.h}. This header file includes executable C code.
- The various Coff targets first include the appropriate Coff
- header file, make any special defines that are needed, and
- then include @file{coffcode.h}.
-
- Some of the Coff targets then also have additional routines in
- the target source file itself.
-
- For example, @file{coff-i960.c} includes
- @file{coff/internal.h} and @file{coff/i960.h}. It then
- defines a few constants, such as @code{I960}, and includes
- @file{coffcode.h}. Since the i960 has complex relocation
- types, @file{coff-i960.c} also includes some code to
- manipulate the i960 relocs. This code is not in
- @file{coffcode.h} because it would not be used by any other
- target.
-
-SUBSUBSECTION
- Bit twiddling
-
- Each flavour of coff supported in BFD has its own header file
- describing the external layout of the structures. There is also
- an internal description of the coff layout, in
- @file{coff/internal.h}. A major function of the
- coff backend is swapping the bytes and twiddling the bits to
- translate the external form of the structures into the normal
- internal form. This is all performed in the
- @code{bfd_swap}_@i{thing}_@i{direction} routines. Some
- elements are different sizes between different versions of
- coff; it is the duty of the coff version specific include file
- to override the definitions of various packing routines in
- @file{coffcode.h}. E.g., the size of line number entry in coff is
- sometimes 16 bits, and sometimes 32 bits. @code{#define}ing
- @code{PUT_LNSZ_LNNO} and @code{GET_LNSZ_LNNO} will select the
- correct one. No doubt, some day someone will find a version of
- coff which has a varying field size not catered to at the
- moment. To port BFD, that person will have to add more @code{#defines}.
- Three of the bit twiddling routines are exported to
- @code{gdb}; @code{coff_swap_aux_in}, @code{coff_swap_sym_in}
- and @code{coff_swap_linno_in}. @code{GDB} reads the symbol
- table on its own, but uses BFD to fix things up. More of the
- bit twiddlers are exported for @code{gas};
- @code{coff_swap_aux_out}, @code{coff_swap_sym_out},
- @code{coff_swap_lineno_out}, @code{coff_swap_reloc_out},
- @code{coff_swap_filehdr_out}, @code{coff_swap_aouthdr_out},
- @code{coff_swap_scnhdr_out}. @code{Gas} currently keeps track
- of all the symbol table and reloc drudgery itself, thereby
- saving the internal BFD overhead, but uses BFD to swap things
- on the way out, making cross ports much safer. Doing so also
- allows BFD (and thus the linker) to use the same header files
- as @code{gas}, which makes one avenue to disaster disappear.
-
-SUBSUBSECTION
- Symbol reading
-
- The simple canonical form for symbols used by BFD is not rich
- enough to keep all the information available in a coff symbol
- table. The back end gets around this problem by keeping the original
- symbol table around, "behind the scenes".
-
- When a symbol table is requested (through a call to
- @code{bfd_canonicalize_symtab}), a request gets through to
- @code{coff_get_normalized_symtab}. This reads the symbol table from
- the coff file and swaps all the structures inside into the
- internal form. It also fixes up all the pointers in the table
- (represented in the file by offsets from the first symbol in
- the table) into physical pointers to elements in the new
- internal table. This involves some work since the meanings of
- fields change depending upon context: a field that is a
- pointer to another structure in the symbol table at one moment
- may be the size in bytes of a structure at the next. Another
- pass is made over the table. All symbols which mark file names
- (<<C_FILE>> symbols) are modified so that the internal
- string points to the value in the auxent (the real filename)
- rather than the normal text associated with the symbol
- (@code{".file"}).
-
- At this time the symbol names are moved around. Coff stores
- all symbols less than nine characters long physically
- within the symbol table; longer strings are kept at the end of
- the file in the string table. This pass moves all strings
- into memory and replaces them with pointers to the strings.
-
-
- The symbol table is massaged once again, this time to create
- the canonical table used by the BFD application. Each symbol
- is inspected in turn, and a decision made (using the
- @code{sclass} field) about the various flags to set in the
- @code{asymbol}. @xref{Symbols}. The generated canonical table
- shares strings with the hidden internal symbol table.
-
- Any linenumbers are read from the coff file too, and attached
- to the symbols which own the functions the linenumbers belong to.
-
-SUBSUBSECTION
- Symbol writing
-
- Writing a symbol to a coff file which didn't come from a coff
- file will lose any debugging information. The @code{asymbol}
- structure remembers the BFD from which the symbol was taken, and on
- output the back end makes sure that the same destination target as
- source target is present.
-
- When the symbols have come from a coff file then all the
- debugging information is preserved.
-
- Symbol tables are provided for writing to the back end in a
- vector of pointers to pointers. This allows applications like
- the linker to accumulate and output large symbol tables
- without having to do too much byte copying.
-
- This function runs through the provided symbol table and
- patches each symbol marked as a file place holder
- (@code{C_FILE}) to point to the next file place holder in the
- list. It also marks each @code{offset} field in the list with
- the offset from the first symbol of the current symbol.
-
- Another function of this procedure is to turn the canonical
- value form of BFD into the form used by coff. Internally, BFD
- expects symbol values to be offsets from a section base; so a
- symbol physically at 0x120, but in a section starting at
- 0x100, would have the value 0x20. Coff expects symbols to
- contain their final value, so symbols have their values
- changed at this point to reflect their sum with their owning
- section. This transformation uses the
- <<output_section>> field of the @code{asymbol}'s
- @code{asection} @xref{Sections}.
-
- o <<coff_mangle_symbols>>
-
- This routine runs though the provided symbol table and uses
- the offsets generated by the previous pass and the pointers
- generated when the symbol table was read in to create the
- structured hierachy required by coff. It changes each pointer
- to a symbol into the index into the symbol table of the asymbol.
-
- o <<coff_write_symbols>>
-
- This routine runs through the symbol table and patches up the
- symbols from their internal form into the coff way, calls the
- bit twiddlers, and writes out the table to the file.
-
-*/
-
-/*
-INTERNAL_DEFINITION
- coff_symbol_type
-
-DESCRIPTION
- The hidden information for an <<asymbol>> is described in a
- <<combined_entry_type>>:
-
-CODE_FRAGMENT
-.
-.typedef struct coff_ptr_struct
-.{
-.
-. {* Remembers the offset from the first symbol in the file for
-. this symbol. Generated by coff_renumber_symbols. *}
-.unsigned int offset;
-.
-. {* Should the value of this symbol be renumbered. Used for
-. XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. *}
-.unsigned int fix_value : 1;
-.
-. {* Should the tag field of this symbol be renumbered.
-. Created by coff_pointerize_aux. *}
-.unsigned int fix_tag : 1;
-.
-. {* Should the endidx field of this symbol be renumbered.
-. Created by coff_pointerize_aux. *}
-.unsigned int fix_end : 1;
-.
-. {* Should the x_csect.x_scnlen field be renumbered.
-. Created by coff_pointerize_aux. *}
-.unsigned int fix_scnlen : 1;
-.
-. {* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
-. index into the line number entries. Set by
-. coff_slurp_symbol_table. *}
-.unsigned int fix_line : 1;
-.
-. {* The container for the symbol structure as read and translated
-. from the file. *}
-.
-.union {
-. union internal_auxent auxent;
-. struct internal_syment syment;
-. } u;
-.} combined_entry_type;
-.
-.
-.{* Each canonical asymbol really looks like this: *}
-.
-.typedef struct coff_symbol_struct
-.{
-. {* The actual symbol which the rest of BFD works with *}
-.asymbol symbol;
-.
-. {* A pointer to the hidden information for this symbol *}
-.combined_entry_type *native;
-.
-. {* A pointer to the linenumber information for this symbol *}
-.struct lineno_cache_entry *lineno;
-.
-. {* Have the line numbers been relocated yet ? *}
-.boolean done_lineno;
-.} coff_symbol_type;
-
-
-*/
-
-#ifdef COFF_WITH_PE
-#include "peicode.h"
-#else
-#include "coffswap.h"
-#endif
-
-
-/* void warning(); */
-
-/*
- * Return a word with STYP_* (scnhdr.s_flags) flags set to represent the
- * incoming SEC_* flags. The inverse of this function is styp_to_sec_flags().
- * NOTE: If you add to/change this routine, you should mirror the changes
- * in styp_to_sec_flags().
- */
-static long
-sec_to_styp_flags (sec_name, sec_flags)
- CONST char *sec_name;
- flagword sec_flags;
-{
- long styp_flags = 0;
-
- if (!strcmp (sec_name, _TEXT))
- {
- styp_flags = STYP_TEXT;
- }
- else if (!strcmp (sec_name, _DATA))
- {
- styp_flags = STYP_DATA;
- }
- else if (!strcmp (sec_name, _BSS))
- {
- styp_flags = STYP_BSS;
-#ifdef _COMMENT
- }
- else if (!strcmp (sec_name, _COMMENT))
- {
- styp_flags = STYP_INFO;
-#endif /* _COMMENT */
-#ifdef _LIB
- }
- else if (!strcmp (sec_name, _LIB))
- {
- styp_flags = STYP_LIB;
-#endif /* _LIB */
-#ifdef _LIT
- }
- else if (!strcmp (sec_name, _LIT))
- {
- styp_flags = STYP_LIT;
-#endif /* _LIT */
- }
- else if (!strcmp (sec_name, ".debug"))
- {
-#ifdef STYP_DEBUG
- styp_flags = STYP_DEBUG;
-#else
- styp_flags = STYP_INFO;
-#endif
- }
- else if (!strncmp (sec_name, ".stab", 5))
- {
- styp_flags = STYP_INFO;
- }
-#ifdef COFF_WITH_PE
- else if (!strcmp (sec_name, ".edata"))
- {
- styp_flags = STYP_DATA;
- }
-#endif
-#ifdef RS6000COFF_C
- else if (!strcmp (sec_name, _PAD))
- {
- styp_flags = STYP_PAD;
- }
- else if (!strcmp (sec_name, _LOADER))
- {
- styp_flags = STYP_LOADER;
- }
-#endif
- /* Try and figure out what it should be */
- else if (sec_flags & SEC_CODE)
- {
- styp_flags = STYP_TEXT;
- }
- else if (sec_flags & SEC_DATA)
- {
- styp_flags = STYP_DATA;
- }
- else if (sec_flags & SEC_READONLY)
- {
-#ifdef STYP_LIT /* 29k readonly text/data section */
- styp_flags = STYP_LIT;
-#else
- styp_flags = STYP_TEXT;
-#endif /* STYP_LIT */
- }
- else if (sec_flags & SEC_LOAD)
- {
- styp_flags = STYP_TEXT;
- }
- else if (sec_flags & SEC_ALLOC)
- {
- styp_flags = STYP_BSS;
- }
-
-#ifdef STYP_NOLOAD
- if ((sec_flags & (SEC_NEVER_LOAD | SEC_COFF_SHARED_LIBRARY)) != 0)
- styp_flags |= STYP_NOLOAD;
-#endif
-
- return (styp_flags);
-}
-/*
- * Return a word with SEC_* flags set to represent the incoming
- * STYP_* flags (from scnhdr.s_flags). The inverse of this
- * function is sec_to_styp_flags().
- * NOTE: If you add to/change this routine, you should mirror the changes
- * in sec_to_styp_flags().
- */
-static flagword
-styp_to_sec_flags (abfd, hdr, name)
- bfd *abfd;
- PTR hdr;
- const char *name;
-{
- struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
- long styp_flags = internal_s->s_flags;
- flagword sec_flags = 0;
-
-#ifdef STYP_NOLOAD
- if (styp_flags & STYP_NOLOAD)
- {
- sec_flags |= SEC_NEVER_LOAD;
- }
-#endif /* STYP_NOLOAD */
-
- /* For 386 COFF, at least, an unloadable text or data section is
- actually a shared library section. */
- if (styp_flags & STYP_TEXT)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
- }
- else if (styp_flags & STYP_DATA)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
- }
- else if (styp_flags & STYP_BSS)
- {
-#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
- else
-#endif
- sec_flags |= SEC_ALLOC;
- }
- else if (styp_flags & STYP_INFO)
- {
- /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
- defined. coff_compute_section_file_positions uses
- COFF_PAGE_SIZE to ensure that the low order bits of the
- section VMA and the file offset match. If we don't know
- COFF_PAGE_SIZE, we can't ensure the correct correspondence,
- and demand page loading of the file will fail. */
-#ifdef COFF_PAGE_SIZE
- sec_flags |= SEC_DEBUGGING;
-#endif
- }
- else if (styp_flags & STYP_PAD)
- {
- sec_flags = 0;
- }
- else if (strcmp (name, _TEXT) == 0)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
- }
- else if (strcmp (name, _DATA) == 0)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
- }
- else if (strcmp (name, _BSS) == 0)
- {
-#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
- else
-#endif
- sec_flags |= SEC_ALLOC;
- }
- else if (strcmp (name, ".debug") == 0
-#ifdef _COMMENT
- || strcmp (name, _COMMENT) == 0
-#endif
- || strncmp (name, ".stab", 5) == 0)
- {
-#ifdef COFF_PAGE_SIZE
- sec_flags |= SEC_DEBUGGING;
-#endif
- }
-#ifdef _LIB
- else if (strcmp (name, _LIB) == 0)
- ;
-#endif
-#ifdef _LIT
- else if (strcmp (name, _LIT) == 0)
- {
- sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
- }
-#endif
- else
- {
- sec_flags |= SEC_ALLOC | SEC_LOAD;
- }
-
-#ifdef STYP_LIT /* A29k readonly text/data section type */
- if ((styp_flags & STYP_LIT) == STYP_LIT)
- {
- sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
- }
-#endif /* STYP_LIT */
-#ifdef STYP_OTHER_LOAD /* Other loaded sections */
- if (styp_flags & STYP_OTHER_LOAD)
- {
- sec_flags = (SEC_LOAD | SEC_ALLOC);
- }
-#endif /* STYP_SDATA */
-
- return (sec_flags);
-}
-
-#define get_index(symbol) ((symbol)->udata.i)
-
-/*
-INTERNAL_DEFINITION
- bfd_coff_backend_data
-
-CODE_FRAGMENT
-
-Special entry points for gdb to swap in coff symbol table parts:
-.typedef struct
-.{
-. void (*_bfd_coff_swap_aux_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. int type,
-. int class,
-. int indaux,
-. int numaux,
-. PTR in));
-.
-. void (*_bfd_coff_swap_sym_in) PARAMS ((
-. bfd *abfd ,
-. PTR ext,
-. PTR in));
-.
-. void (*_bfd_coff_swap_lineno_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-.
-
-Special entry points for gas to swap out coff parts:
-
-. unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. int type,
-. int class,
-. int indaux,
-. int numaux,
-. PTR ext));
-.
-. unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR ext));
-.
-. unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR ext));
-.
-. unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
-. bfd *abfd,
-. PTR src,
-. PTR dst));
-.
-. unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR out));
-.
-. unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR out));
-.
-. unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR out));
-.
-
-Special entry points for generic COFF routines to call target
-dependent COFF routines:
-
-. unsigned int _bfd_filhsz;
-. unsigned int _bfd_aoutsz;
-. unsigned int _bfd_scnhsz;
-. unsigned int _bfd_symesz;
-. unsigned int _bfd_auxesz;
-. unsigned int _bfd_relsz;
-. unsigned int _bfd_linesz;
-. boolean _bfd_coff_long_filenames;
-. void (*_bfd_coff_swap_filehdr_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. void (*_bfd_coff_swap_reloc_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. boolean (*_bfd_coff_bad_format_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_filehdr));
-. boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_filehdr));
-. PTR (*_bfd_coff_mkobject_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_filehdr,
-. PTR internal_aouthdr));
-. flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_scnhdr,
-. const char *name));
-. void (*_bfd_set_alignment_hook) PARAMS ((
-. bfd *abfd,
-. asection *sec,
-. PTR internal_scnhdr));
-. boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
-. bfd *abfd));
-. boolean (*_bfd_coff_symname_in_debug) PARAMS ((
-. bfd *abfd,
-. struct internal_syment *sym));
-. boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
-. bfd *abfd,
-. combined_entry_type *table_base,
-. combined_entry_type *symbol,
-. unsigned int indaux,
-. combined_entry_type *aux));
-. boolean (*_bfd_coff_print_aux) PARAMS ((
-. bfd *abfd,
-. FILE *file,
-. combined_entry_type *table_base,
-. combined_entry_type *symbol,
-. combined_entry_type *aux,
-. unsigned int indaux));
-. void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
-. bfd *abfd,
-. struct bfd_link_info *link_info,
-. struct bfd_link_order *link_order,
-. arelent *reloc,
-. bfd_byte *data,
-. unsigned int *src_ptr,
-. unsigned int *dst_ptr));
-. int (*_bfd_coff_reloc16_estimate) PARAMS ((
-. bfd *abfd,
-. asection *input_section,
-. arelent *r,
-. unsigned int shrink,
-. struct bfd_link_info *link_info));
-. boolean (*_bfd_coff_sym_is_global) PARAMS ((
-. bfd *abfd,
-. struct internal_syment *));
-. void (*_bfd_coff_compute_section_file_positions) PARAMS ((
-. bfd *abfd));
-. boolean (*_bfd_coff_start_final_link) PARAMS ((
-. bfd *output_bfd,
-. struct bfd_link_info *info));
-. boolean (*_bfd_coff_relocate_section) PARAMS ((
-. bfd *output_bfd,
-. struct bfd_link_info *info,
-. bfd *input_bfd,
-. asection *input_section,
-. bfd_byte *contents,
-. struct internal_reloc *relocs,
-. struct internal_syment *syms,
-. asection **sections));
-. reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
-. bfd *abfd,
-. asection *sec,
-. struct internal_reloc *rel,
-. struct coff_link_hash_entry *h,
-. struct internal_syment *sym,
-. bfd_vma *addendp));
-. boolean (*_bfd_coff_adjust_symndx) PARAMS ((
-. bfd *obfd,
-. struct bfd_link_info *info,
-. bfd *ibfd,
-. asection *sec,
-. struct internal_reloc *reloc,
-. boolean *adjustedp));
-. boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
-. struct bfd_link_info *info,
-. bfd *abfd,
-. const char *name,
-. flagword flags,
-. asection *section,
-. bfd_vma value,
-. const char *string,
-. boolean copy,
-. boolean collect,
-. struct bfd_link_hash_entry **hashp));
-.
-.} bfd_coff_backend_data;
-.
-.#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
-.
-.#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
-. ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
-.
-.#define bfd_coff_swap_sym_in(a,e,i) \
-. ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
-.
-.#define bfd_coff_swap_lineno_in(a,e,i) \
-. ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
-.
-.#define bfd_coff_swap_reloc_out(abfd, i, o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_lineno_out(abfd, i, o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
-. ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
-.
-.#define bfd_coff_swap_sym_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_filehdr_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
-.
-.#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
-.#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
-.#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
-.#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
-.#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
-.#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
-.#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
-.#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
-.#define bfd_coff_swap_filehdr_in(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
-.
-.#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
-.
-.#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
-.
-.#define bfd_coff_swap_reloc_in(abfd, i, o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
-.
-.#define bfd_coff_bad_format_hook(abfd, filehdr) \
-. ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
-.
-.#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
-. ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
-.#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
-. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
-.
-.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
-. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
-.
-.#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
-. ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
-.
-.#define bfd_coff_slurp_symbol_table(abfd)\
-. ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
-.
-.#define bfd_coff_symname_in_debug(abfd, sym)\
-. ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
-.
-.#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
-. ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
-. (abfd, file, base, symbol, aux, indaux))
-.
-.#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
-. ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
-. (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
-.
-.#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
-. ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
-. (abfd, section, reloc, shrink, link_info))
-.
-.#define bfd_coff_sym_is_global(abfd, sym)\
-. ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\
-. (abfd, sym))
-.
-.#define bfd_coff_compute_section_file_positions(abfd)\
-. ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
-. (abfd))
-.
-.#define bfd_coff_start_final_link(obfd, info)\
-. ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
-. (obfd, info))
-.#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
-. ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
-. (obfd, info, ibfd, o, con, rel, isyms, secs))
-.#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
-. ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
-. (abfd, sec, rel, h, sym, addendp))
-.#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
-. ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
-. (obfd, info, ibfd, sec, rel, adjustedp))
-.#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
-. ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
-. (info, abfd, name, flags, section, value, string, cp, coll, hashp))
-.
-*/
-
-/* See whether the magic number matches. */
-
-static boolean
-coff_bad_format_hook (abfd, filehdr)
- bfd * abfd;
- PTR filehdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
-
- if (BADMAG (*internal_f))
- return false;
-
- /* if the optional header is NULL or not the correct size then
- quit; the only difference I can see between m88k dgux headers (MC88DMAGIC)
- and Intel 960 readwrite headers (I960WRMAGIC) is that the
- optional header is of a different size.
-
- But the mips keeps extra stuff in it's opthdr, so dont check
- when doing that
- */
-
-#if defined(M88) || defined(I960)
- if (internal_f->f_opthdr != 0 && AOUTSZ != internal_f->f_opthdr)
- return false;
-#endif
-
- return true;
-}
-
-/*
- initialize a section structure with information peculiar to this
- particular implementation of coff
-*/
-
-static boolean
-coff_new_section_hook (abfd, section)
- bfd * abfd;
- asection * section;
-{
- section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
-
-#ifdef RS6000COFF_C
- if (xcoff_data (abfd)->text_align_power != 0
- && strcmp (bfd_get_section_name (abfd, section), ".text") == 0)
- section->alignment_power = xcoff_data (abfd)->text_align_power;
- if (xcoff_data (abfd)->data_align_power != 0
- && strcmp (bfd_get_section_name (abfd, section), ".data") == 0)
- section->alignment_power = xcoff_data (abfd)->data_align_power;
-#endif
-
- /* Allocate aux records for section symbols, to store size and
- related info.
-
- @@ Shouldn't use constant multiplier here! */
- coffsymbol (section->symbol)->native =
- (combined_entry_type *) bfd_zalloc (abfd,
- sizeof (combined_entry_type) * 10);
-
- /* The .stab section must be aligned to 2**2 at most, because
- otherwise there may be gaps in the section which gdb will not
- know how to interpret. Examining the section name is a hack, but
- that is also how gdb locates the section.
- We need to handle the .ctors and .dtors sections similarly, to
- avoid introducing null words in the tables. */
- if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 2
- && (strncmp (section->name, ".stab", 5) == 0
- || strcmp (section->name, ".ctors") == 0
- || strcmp (section->name, ".dtors") == 0))
- section->alignment_power = 2;
-
- /* Similarly, the .stabstr section must be aligned to 2**0 at most. */
- if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 0
- && strncmp (section->name, ".stabstr", 8) == 0)
- section->alignment_power = 0;
-
- return true;
-}
-
-#ifdef I960
-
-/* Set the alignment of a BFD section. */
-
-static void
-coff_set_alignment_hook (abfd, section, scnhdr)
- bfd * abfd;
- asection * section;
- PTR scnhdr;
-{
- struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
- unsigned int i;
-
- for (i = 0; i < 32; i++)
- if ((1 << i) >= hdr->s_align)
- break;
- section->alignment_power = i;
-}
-
-#else /* ! I960 */
-#ifdef COFF_WITH_PE
-
-/* a couple of macros to help setting the alignment power field */
-#define ALIGN_SET(field,x,y) \
- if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x )\
- {\
- section->alignment_power = y;\
- }
-
-#define ELIFALIGN_SET(field,x,y) \
- else if (( (field) & IMAGE_SCN_ALIGN_64BYTES) == x ) \
- {\
- section->alignment_power = y;\
- }
-
-static void
-coff_set_alignment_hook (abfd, section, scnhdr)
- bfd * abfd;
- asection * section;
- PTR scnhdr;
-{
- struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
-
- ALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_64BYTES, 6)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_32BYTES, 5)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_16BYTES, 4)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_8BYTES, 3)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_4BYTES, 2)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_2BYTES, 1)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_1BYTES, 0)
-
-#ifdef POWERPC_LE_PE
- if (strcmp (section->name, ".idata$2") == 0)
- {
- section->alignment_power = 0;
- }
- else if (strcmp (section->name, ".idata$3") == 0)
- {
- section->alignment_power = 0;
- }
- else if (strcmp (section->name, ".idata$4") == 0)
- {
- section->alignment_power = 2;
- }
- else if (strcmp (section->name, ".idata$5") == 0)
- {
- section->alignment_power = 2;
- }
- else if (strcmp (section->name, ".idata$6") == 0)
- {
- section->alignment_power = 1;
- }
- else if (strcmp (section->name, ".reloc") == 0)
- {
- section->alignment_power = 1;
- }
- else if (strncmp (section->name, ".stab", 5) == 0)
- {
- section->alignment_power = 2;
- }
-#endif
-}
-#undef ALIGN_SET
-#undef ELIFALIGN_SET
-
-#else /* ! COFF_WITH_PE */
-#ifdef RS6000COFF_C
-
-/* We grossly abuse this function to handle XCOFF overflow headers.
- When we see one, we correct the reloc and line number counts in the
- real header, and remove the section we just created. */
-
-static void
-coff_set_alignment_hook (abfd, section, scnhdr)
- bfd *abfd;
- asection *section;
- PTR scnhdr;
-{
- struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
- asection *real_sec;
- asection **ps;
-
- if ((hdr->s_flags & STYP_OVRFLO) == 0)
- return;
-
- real_sec = coff_section_from_bfd_index (abfd, hdr->s_nreloc);
- if (real_sec == NULL)
- return;
-
- real_sec->reloc_count = hdr->s_paddr;
- real_sec->lineno_count = hdr->s_vaddr;
-
- for (ps = &abfd->sections; *ps != NULL; ps = &(*ps)->next)
- {
- if (*ps == section)
- {
- *ps = (*ps)->next;
- --abfd->section_count;
- break;
- }
- }
-}
-
-#else /* ! RS6000COFF_C */
-
-#define coff_set_alignment_hook \
- ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
-
-#endif /* ! RS6000COFF_C */
-#endif /* ! COFF_WITH_PE */
-#endif /* ! I960 */
-
-#ifndef coff_mkobject
-static boolean
-coff_mkobject (abfd)
- bfd * abfd;
-{
- coff_data_type *coff;
-
- abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, sizeof (coff_data_type));
- if (abfd->tdata.coff_obj_data == 0)
- 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;
- coff->local_toc_sym_map = 0;
-
-/* make_abs_section(abfd);*/
-
- return true;
-}
-#endif
-
-/* Create the COFF backend specific information. */
-#ifndef coff_mkobject_hook
-static PTR
-coff_mkobject_hook (abfd, filehdr, aouthdr)
- bfd * abfd;
- PTR filehdr;
- PTR aouthdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
- coff_data_type *coff;
-
- if (coff_mkobject (abfd) == false)
- return NULL;
-
- coff = coff_data (abfd);
-
- 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... */
- coff->local_n_btmask = N_BTMASK;
- coff->local_n_btshft = N_BTSHFT;
- coff->local_n_tmask = N_TMASK;
- coff->local_n_tshift = N_TSHIFT;
- coff->local_symesz = SYMESZ;
- coff->local_auxesz = AUXESZ;
- coff->local_linesz = LINESZ;
-
- obj_raw_syment_count (abfd) =
- obj_conv_table_size (abfd) =
- internal_f->f_nsyms;
-
-#ifdef RS6000COFF_C
- if ((internal_f->f_flags & F_SHROBJ) != 0)
- abfd->flags |= DYNAMIC;
- if (aouthdr != NULL && internal_f->f_opthdr >= AOUTSZ)
- {
- struct internal_aouthdr *internal_a =
- (struct internal_aouthdr *) aouthdr;
- struct xcoff_tdata *xcoff;
-
- xcoff = xcoff_data (abfd);
- xcoff->full_aouthdr = true;
- xcoff->toc = internal_a->o_toc;
- xcoff->sntoc = internal_a->o_sntoc;
- xcoff->snentry = internal_a->o_snentry;
- xcoff->text_align_power = internal_a->o_algntext;
- xcoff->data_align_power = internal_a->o_algndata;
- xcoff->modtype = internal_a->o_modtype;
- xcoff->cputype = internal_a->o_cputype;
- xcoff->maxdata = internal_a->o_maxdata;
- xcoff->maxstack = internal_a->o_maxstack;
- }
-#endif
-
- return (PTR) coff;
-}
-#endif
-
-/* Determine the machine architecture and type. FIXME: This is target
- dependent because the magic numbers are defined in the target
- dependent header files. But there is no particular need for this.
- If the magic numbers were moved to a separate file, this function
- would be target independent and would also be much more successful
- at linking together COFF files for different architectures. */
-
-static boolean
-coff_set_arch_mach_hook (abfd, filehdr)
- bfd *abfd;
- PTR filehdr;
-{
- long machine;
- enum bfd_architecture arch;
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
-
- machine = 0;
- switch (internal_f->f_magic)
- {
-#ifdef PPCMAGIC
- case PPCMAGIC:
- arch = bfd_arch_powerpc;
- machine = 0; /* what does this mean? (krk) */
- break;
-#endif
-#ifdef I386MAGIC
- case I386MAGIC:
- case I386PTXMAGIC:
- case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler */
- case LYNXCOFFMAGIC: /* shadows the m68k Lynx number below, sigh */
- arch = bfd_arch_i386;
- machine = 0;
- break;
-#endif
-#ifdef A29K_MAGIC_BIG
- case A29K_MAGIC_BIG:
- case A29K_MAGIC_LITTLE:
- arch = bfd_arch_a29k;
- machine = 0;
- break;
-#endif
-#ifdef ARMMAGIC
- case ARMMAGIC:
- arch = bfd_arch_arm;
- machine =0;
- break;
-#endif
-#ifdef MC68MAGIC
- case MC68MAGIC:
- case M68MAGIC:
-#ifdef MC68KBCSMAGIC
- case MC68KBCSMAGIC:
-#endif
-#ifdef APOLLOM68KMAGIC
- case APOLLOM68KMAGIC:
-#endif
-#ifdef LYNXCOFFMAGIC
- case LYNXCOFFMAGIC:
-#endif
- arch = bfd_arch_m68k;
- machine = 68020;
- break;
-#endif
-#ifdef MC88MAGIC
- case MC88MAGIC:
- case MC88DMAGIC:
- case MC88OMAGIC:
- arch = bfd_arch_m88k;
- machine = 88100;
- break;
-#endif
-#ifdef Z8KMAGIC
- case Z8KMAGIC:
- arch = bfd_arch_z8k;
- switch (internal_f->f_flags & F_MACHMASK)
- {
- case F_Z8001:
- machine = bfd_mach_z8001;
- break;
- case F_Z8002:
- machine = bfd_mach_z8002;
- break;
- default:
- return false;
- }
- break;
-#endif
-#ifdef I860
- case I860MAGIC:
- arch = bfd_arch_i860;
- break;
-#endif
-#ifdef I960
-#ifdef I960ROMAGIC
- case I960ROMAGIC:
- case I960RWMAGIC:
- arch = bfd_arch_i960;
- switch (F_I960TYPE & internal_f->f_flags)
- {
- default:
- case F_I960CORE:
- machine = bfd_mach_i960_core;
- break;
- case F_I960KB:
- machine = bfd_mach_i960_kb_sb;
- break;
- case F_I960MC:
- machine = bfd_mach_i960_mc;
- break;
- case F_I960XA:
- machine = bfd_mach_i960_xa;
- break;
- case F_I960CA:
- machine = bfd_mach_i960_ca;
- break;
- case F_I960KA:
- machine = bfd_mach_i960_ka_sa;
- break;
- case F_I960JX:
- machine = bfd_mach_i960_jx;
- break;
- case F_I960HX:
- machine = bfd_mach_i960_hx;
- break;
- }
- break;
-#endif
-#endif
-
-#ifdef RS6000COFF_C
- case U802ROMAGIC:
- case U802WRMAGIC:
- case U802TOCMAGIC:
- {
- int cputype;
-
- if (xcoff_data (abfd)->cputype != -1)
- cputype = xcoff_data (abfd)->cputype & 0xff;
- else
- {
- /* We did not get a value from the a.out header. If the
- file has not been stripped, we may be able to get the
- architecture information from the first symbol, if it
- is a .file symbol. */
- if (obj_raw_syment_count (abfd) == 0)
- cputype = 0;
- else
- {
- bfd_byte buf[SYMESZ];
- struct internal_syment sym;
-
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || bfd_read (buf, 1, SYMESZ, abfd) != SYMESZ)
- return false;
- coff_swap_sym_in (abfd, (PTR) buf, (PTR) &sym);
- if (sym.n_sclass == C_FILE)
- cputype = sym.n_type & 0xff;
- else
- cputype = 0;
- }
- }
-
- /* FIXME: We don't handle all cases here. */
- switch (cputype)
- {
- default:
- case 0:
-#ifdef POWERMAC
- /* PowerPC Macs use the same magic numbers as RS/6000
- (because that's how they were bootstrapped originally),
- but they are always PowerPC architecture. */
- arch = bfd_arch_powerpc;
- machine = 0;
-#else
- arch = bfd_arch_rs6000;
- machine = 6000;
-#endif /* POWERMAC */
- break;
-
- case 1:
- arch = bfd_arch_powerpc;
- machine = 601;
- break;
- case 2: /* 64 bit PowerPC */
- arch = bfd_arch_powerpc;
- machine = 620;
- break;
- case 3:
- arch = bfd_arch_powerpc;
- machine = 0;
- break;
- case 4:
- arch = bfd_arch_rs6000;
- machine = 6000;
- break;
- }
- }
- break;
-#endif
-
-#ifdef WE32KMAGIC
- case WE32KMAGIC:
- arch = bfd_arch_we32k;
- machine = 0;
- break;
-#endif
-
-#ifdef H8300MAGIC
- case H8300MAGIC:
- arch = bfd_arch_h8300;
- machine = bfd_mach_h8300;
- /* !! FIXME this probably isn't the right place for this */
- abfd->flags |= BFD_IS_RELAXABLE;
- break;
-#endif
-
-#ifdef H8300HMAGIC
- case H8300HMAGIC:
- arch = bfd_arch_h8300;
- machine = bfd_mach_h8300h;
- /* !! FIXME this probably isn't the right place for this */
- abfd->flags |= BFD_IS_RELAXABLE;
- break;
-#endif
-
-#ifdef SH_ARCH_MAGIC_BIG
- case SH_ARCH_MAGIC_BIG:
- case SH_ARCH_MAGIC_LITTLE:
- arch = bfd_arch_sh;
- machine = 0;
- break;
-#endif
-
-#ifdef H8500MAGIC
- case H8500MAGIC:
- arch = bfd_arch_h8500;
- machine = 0;
- break;
-#endif
-
-#ifdef SPARCMAGIC
- case SPARCMAGIC:
-#ifdef LYNXCOFFMAGIC
- case LYNXCOFFMAGIC:
-#endif
- arch = bfd_arch_sparc;
- machine = 0;
- break;
-#endif
-
- default: /* Unreadable input file type */
- arch = bfd_arch_obscure;
- break;
- }
-
- bfd_default_set_arch_mach (abfd, arch, machine);
- return true;
-}
-
-#ifdef SYMNAME_IN_DEBUG
-
-static boolean
-symname_in_debug_hook (abfd, sym)
- bfd * abfd;
- struct internal_syment *sym;
-{
- return SYMNAME_IN_DEBUG (sym) ? true : false;
-}
-
-#else
-
-#define symname_in_debug_hook \
- (boolean (*) PARAMS ((bfd *, struct internal_syment *))) bfd_false
-
-#endif
-
-#ifdef RS6000COFF_C
-
-/* Handle the csect auxent of a C_EXT or C_HIDEXT symbol. */
-
-static boolean coff_pointerize_aux_hook
- PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
- unsigned int, combined_entry_type *));
-
-/*ARGSUSED*/
-static boolean
-coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
- bfd *abfd;
- combined_entry_type *table_base;
- combined_entry_type *symbol;
- unsigned int indaux;
- combined_entry_type *aux;
-{
- int class = symbol->u.syment.n_sclass;
-
- if ((class == C_EXT || class == C_HIDEXT)
- && indaux + 1 == symbol->u.syment.n_numaux)
- {
- if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD)
- {
- aux->u.auxent.x_csect.x_scnlen.p =
- table_base + aux->u.auxent.x_csect.x_scnlen.l;
- aux->fix_scnlen = 1;
- }
-
- /* Return true to indicate that the caller should not do any
- further work on this auxent. */
- return true;
- }
-
- /* Return false to indicate that this auxent should be handled by
- the caller. */
- return false;
-}
-
-#else
-#ifdef I960
-
-/* We don't want to pointerize bal entries. */
-
-static boolean coff_pointerize_aux_hook
- PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
- unsigned int, combined_entry_type *));
-
-/*ARGSUSED*/
-static boolean
-coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
- bfd *abfd;
- combined_entry_type *table_base;
- combined_entry_type *symbol;
- unsigned int indaux;
- combined_entry_type *aux;
-{
- /* Return true if we don't want to pointerize this aux entry, which
- is the case for the lastfirst aux entry for a C_LEAFPROC symbol. */
- return (indaux == 1
- && (symbol->u.syment.n_sclass == C_LEAFPROC
- || symbol->u.syment.n_sclass == C_LEAFSTAT
- || symbol->u.syment.n_sclass == C_LEAFEXT));
-}
-
-#else /* ! I960 */
-
-#define coff_pointerize_aux_hook 0
-
-#endif /* ! I960 */
-#endif /* ! RS6000COFF_C */
-
-/* Print an aux entry. This returns true if it has printed it. */
-
-static boolean coff_print_aux
- PARAMS ((bfd *, FILE *, combined_entry_type *, combined_entry_type *,
- combined_entry_type *, unsigned int));
-
-static boolean
-coff_print_aux (abfd, file, table_base, symbol, aux, indaux)
- bfd *abfd;
- FILE *file;
- combined_entry_type *table_base;
- combined_entry_type *symbol;
- combined_entry_type *aux;
- unsigned int indaux;
-{
-#ifdef RS6000COFF_C
- if ((symbol->u.syment.n_sclass == C_EXT
- || symbol->u.syment.n_sclass == C_HIDEXT)
- && indaux + 1 == symbol->u.syment.n_numaux)
- {
- /* This is a csect entry. */
- fprintf (file, "AUX ");
- if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) != XTY_LD)
- {
- BFD_ASSERT (! aux->fix_scnlen);
- fprintf (file, "val %5ld", aux->u.auxent.x_csect.x_scnlen.l);
- }
- else
- {
- fprintf (file, "indx ");
- if (! aux->fix_scnlen)
- fprintf (file, "%4ld", aux->u.auxent.x_csect.x_scnlen.l);
- else
- fprintf (file, "%4ld",
- (long) (aux->u.auxent.x_csect.x_scnlen.p - table_base));
- }
- fprintf (file,
- " prmhsh %ld snhsh %u typ %d algn %d clss %u stb %ld snstb %u",
- aux->u.auxent.x_csect.x_parmhash,
- (unsigned int) aux->u.auxent.x_csect.x_snhash,
- SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp),
- SMTYP_ALIGN (aux->u.auxent.x_csect.x_smtyp),
- (unsigned int) aux->u.auxent.x_csect.x_smclas,
- aux->u.auxent.x_csect.x_stab,
- (unsigned int) aux->u.auxent.x_csect.x_snstab);
- return true;
- }
-#endif
-
- /* Return false to indicate that no special action was taken. */
- return false;
-}
-
-/*
-SUBSUBSECTION
- Writing relocations
-
- To write relocations, the back end steps though the
- canonical relocation table and create an
- @code{internal_reloc}. The symbol index to use is removed from
- the @code{offset} field in the symbol table supplied. The
- address comes directly from the sum of the section base
- address and the relocation offset; the type is dug directly
- from the howto field. Then the @code{internal_reloc} is
- swapped into the shape of an @code{external_reloc} and written
- out to disk.
-
-*/
-
-#ifdef TARG_AUX
-
-static int compare_arelent_ptr PARAMS ((const PTR, const PTR));
-
-/* AUX's ld wants relocations to be sorted */
-static int
-compare_arelent_ptr (x, y)
- const PTR x;
- const PTR y;
-{
- const arelent **a = (const arelent **) x;
- const arelent **b = (const arelent **) y;
- bfd_size_type aadr = (*a)->address;
- bfd_size_type badr = (*b)->address;
-
- return (aadr < badr ? -1 : badr < aadr ? 1 : 0);
-}
-
-#endif /* TARG_AUX */
-
-static boolean
-coff_write_relocs (abfd, first_undef)
- bfd * abfd;
- int first_undef;
-{
- asection *s;
-
- for (s = abfd->sections; s != (asection *) NULL; s = s->next)
- {
- unsigned int i;
- struct external_reloc dst;
- arelent **p;
-
-#ifndef TARG_AUX
- p = s->orelocation;
-#else
- /* sort relocations before we write them out */
- p = (arelent **) bfd_malloc (s->reloc_count * sizeof (arelent *));
- if (p == NULL && s->reloc_count > 0)
- return false;
- memcpy (p, s->orelocation, s->reloc_count * sizeof (arelent *));
- qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr);
-#endif
-
- if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0)
- return false;
- for (i = 0; i < s->reloc_count; i++)
- {
- struct internal_reloc n;
- arelent *q = p[i];
- memset ((PTR) & n, 0, sizeof (n));
-
- /* Now we've renumbered the symbols we know where the
- undefined symbols live in the table. Check the reloc
- entries for symbols who's output bfd isn't the right one.
- This is because the symbol was undefined (which means
- that all the pointers are never made to point to the same
- place). This is a bad thing,'cause the symbols attached
- to the output bfd are indexed, so that the relocation
- entries know which symbol index they point to. So we
- have to look up the output symbol here. */
-
- if (q->sym_ptr_ptr[0]->the_bfd != abfd)
- {
- int i;
- const char *sname = q->sym_ptr_ptr[0]->name;
- asymbol **outsyms = abfd->outsymbols;
- for (i = first_undef; outsyms[i]; i++)
- {
- const char *intable = outsyms[i]->name;
- if (strcmp (intable, sname) == 0) {
- /* got a hit, so repoint the reloc */
- q->sym_ptr_ptr = outsyms + i;
- break;
- }
- }
- }
-
- n.r_vaddr = q->address + s->vma;
-
-#ifdef R_IHCONST
- /* The 29k const/consth reloc pair is a real kludge. The consth
- part doesn't have a symbol; it has an offset. So rebuilt
- that here. */
- if (q->howto->type == R_IHCONST)
- n.r_symndx = q->addend;
- else
-#endif
- if (q->sym_ptr_ptr)
- {
- if (q->sym_ptr_ptr == bfd_abs_section_ptr->symbol_ptr_ptr)
- /* This is a relocation relative to the absolute symbol. */
- n.r_symndx = -1;
- else
- {
- n.r_symndx = get_index ((*(q->sym_ptr_ptr)));
- /* Take notice if the symbol reloc points to a symbol
- we don't have in our symbol table. What should we
- do for this?? */
- if (n.r_symndx > obj_conv_table_size (abfd))
- abort ();
- }
- }
-
-#ifdef SWAP_OUT_RELOC_OFFSET
- n.r_offset = q->addend;
-#endif
-
-#ifdef SELECT_RELOC
- /* Work out reloc type from what is required */
- SELECT_RELOC (n, q->howto);
-#else
- n.r_type = q->howto->type;
-#endif
- coff_swap_reloc_out (abfd, &n, &dst);
- if (bfd_write ((PTR) & dst, 1, RELSZ, abfd) != RELSZ)
- return false;
- }
-
-#ifdef TARG_AUX
- if (p != NULL)
- free (p);
-#endif
- }
-
- return true;
-}
-
-/* Set flags and magic number of a coff file from architecture and machine
- type. Result is true if we can represent the arch&type, false if not. */
-
-static boolean
-coff_set_flags (abfd, magicp, flagsp)
- bfd * abfd;
- unsigned *magicp;
- unsigned short *flagsp;
-{
- switch (bfd_get_arch (abfd))
- {
-#ifdef Z8KMAGIC
- case bfd_arch_z8k:
- *magicp = Z8KMAGIC;
- switch (bfd_get_mach (abfd))
- {
- case bfd_mach_z8001:
- *flagsp = F_Z8001;
- break;
- case bfd_mach_z8002:
- *flagsp = F_Z8002;
- break;
- default:
- return false;
- }
- return true;
-#endif
-#ifdef I960ROMAGIC
-
- case bfd_arch_i960:
-
- {
- unsigned flags;
- *magicp = I960ROMAGIC;
- /*
- ((bfd_get_file_flags(abfd) & WP_TEXT) ? I960ROMAGIC :
- I960RWMAGIC); FIXME???
- */
- switch (bfd_get_mach (abfd))
- {
- case bfd_mach_i960_core:
- flags = F_I960CORE;
- break;
- case bfd_mach_i960_kb_sb:
- flags = F_I960KB;
- break;
- case bfd_mach_i960_mc:
- flags = F_I960MC;
- break;
- case bfd_mach_i960_xa:
- flags = F_I960XA;
- break;
- case bfd_mach_i960_ca:
- flags = F_I960CA;
- break;
- case bfd_mach_i960_ka_sa:
- flags = F_I960KA;
- break;
- case bfd_mach_i960_jx:
- flags = F_I960JX;
- break;
- case bfd_mach_i960_hx:
- flags = F_I960HX;
- break;
- default:
- return false;
- }
- *flagsp = flags;
- return true;
- }
- break;
-#endif
-#ifdef ARMMAGIC
- case bfd_arch_arm:
- *magicp = ARMMAGIC;
- return true;
-#endif
-#ifdef PPCMAGIC
- case bfd_arch_powerpc:
- *magicp = PPCMAGIC;
- return true;
- break;
-#endif
-#ifdef I386MAGIC
- case bfd_arch_i386:
- *magicp = I386MAGIC;
-#ifdef LYNXOS
- /* Just overwrite the usual value if we're doing Lynx. */
- *magicp = LYNXCOFFMAGIC;
-#endif
- return true;
- break;
-#endif
-#ifdef I860MAGIC
- case bfd_arch_i860:
- *magicp = I860MAGIC;
- return true;
- break;
-#endif
-#ifdef MC68MAGIC
- case bfd_arch_m68k:
-#ifdef APOLLOM68KMAGIC
- *magicp = APOLLO_COFF_VERSION_NUMBER;
-#else
- *magicp = MC68MAGIC;
-#endif
-#ifdef LYNXOS
- /* Just overwrite the usual value if we're doing Lynx. */
- *magicp = LYNXCOFFMAGIC;
-#endif
- return true;
- break;
-#endif
-
-#ifdef MC88MAGIC
- case bfd_arch_m88k:
- *magicp = MC88OMAGIC;
- return true;
- break;
-#endif
-#ifdef H8300MAGIC
- case bfd_arch_h8300:
- switch (bfd_get_mach (abfd))
- {
- case bfd_mach_h8300:
- *magicp = H8300MAGIC;
- return true;
- case bfd_mach_h8300h:
- *magicp = H8300HMAGIC;
- return true;
- }
- break;
-#endif
-
-#ifdef SH_ARCH_MAGIC_BIG
- case bfd_arch_sh:
- if (bfd_big_endian (abfd))
- *magicp = SH_ARCH_MAGIC_BIG;
- else
- *magicp = SH_ARCH_MAGIC_LITTLE;
- return true;
- break;
-#endif
-
-#ifdef SPARCMAGIC
- case bfd_arch_sparc:
- *magicp = SPARCMAGIC;
-#ifdef LYNXOS
- /* Just overwrite the usual value if we're doing Lynx. */
- *magicp = LYNXCOFFMAGIC;
-#endif
- return true;
- break;
-#endif
-
-#ifdef H8500MAGIC
- case bfd_arch_h8500:
- *magicp = H8500MAGIC;
- return true;
- break;
-#endif
-#ifdef A29K_MAGIC_BIG
- case bfd_arch_a29k:
- if (bfd_big_endian (abfd))
- *magicp = A29K_MAGIC_BIG;
- else
- *magicp = A29K_MAGIC_LITTLE;
- return true;
- break;
-#endif
-
-#ifdef WE32KMAGIC
- case bfd_arch_we32k:
- *magicp = WE32KMAGIC;
- return true;
- break;
-#endif
-
-#ifdef U802TOCMAGIC
- case bfd_arch_rs6000:
-#ifndef PPCMAGIC
- case bfd_arch_powerpc:
-#endif
- *magicp = U802TOCMAGIC;
- return true;
- break;
-#endif
-
- default: /* Unknown architecture */
- /* return false; -- fall through to "return false" below, to avoid
- "statement never reached" errors on the one below. */
- break;
- }
-
- return false;
-}
-
-
-static boolean
-coff_set_arch_mach (abfd, arch, machine)
- bfd * abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- unsigned dummy1;
- unsigned short dummy2;
-
- if (! bfd_default_set_arch_mach (abfd, arch, machine))
- return false;
-
- if (arch != bfd_arch_unknown &&
- coff_set_flags (abfd, &dummy1, &dummy2) != true)
- return false; /* We can't represent this type */
-
- return true; /* We're easy ... */
-}
-
-
-/* Calculate the file position for each section. */
-
-static void
-coff_compute_section_file_positions (abfd)
- bfd * abfd;
-{
- asection *current;
- asection *previous = (asection *) NULL;
- file_ptr sofar = FILHSZ;
-
-#ifndef I960
- file_ptr old_sofar;
-#endif
- unsigned int count;
-
-#ifdef RS6000COFF_C
- /* On XCOFF, if we have symbols, set up the .debug section. */
- if (bfd_get_symcount (abfd) > 0)
- {
- bfd_size_type sz;
- bfd_size_type i, symcount;
- asymbol **symp;
-
- sz = 0;
- symcount = bfd_get_symcount (abfd);
- for (symp = abfd->outsymbols, i = 0; i < symcount; symp++, i++)
- {
- coff_symbol_type *cf;
-
- cf = coff_symbol_from (abfd, *symp);
- if (cf != NULL
- && cf->native != NULL
- && SYMNAME_IN_DEBUG (&cf->native->u.syment))
- {
- size_t len;
-
- len = strlen (bfd_asymbol_name (*symp));
- if (len > SYMNMLEN)
- sz += len + 3;
- }
- }
- if (sz > 0)
- {
- asection *dsec;
-
- dsec = bfd_make_section_old_way (abfd, ".debug");
- if (dsec == NULL)
- abort ();
- dsec->_raw_size = sz;
- dsec->flags |= SEC_HAS_CONTENTS;
- }
- }
-#endif
-
-#ifdef COFF_IMAGE_WITH_PE
- int page_size;
- if (coff_data (abfd)->link_info)
- {
- page_size = pe_data (abfd)->pe_opthdr.FileAlignment;
- }
- else
- page_size = PE_DEF_FILE_ALIGNMENT;
-#else
-#ifdef COFF_PAGE_SIZE
- int page_size = COFF_PAGE_SIZE;
-#endif
-#endif
-
- if (bfd_get_start_address (abfd))
- {
- /* A start address may have been added to the original file. In this
- case it will need an optional header to record it. */
- abfd->flags |= EXEC_P;
- }
-
- if (abfd->flags & EXEC_P)
- sofar += AOUTSZ;
-#ifdef RS6000COFF_C
- else if (xcoff_data (abfd)->full_aouthdr)
- sofar += AOUTSZ;
- else
- sofar += SMALL_AOUTSZ;
-#endif
-
- sofar += abfd->section_count * SCNHSZ;
-
-#ifdef RS6000COFF_C
- /* XCOFF handles overflows in the reloc and line number count fields
- by allocating a new section header to hold the correct counts. */
- for (current = abfd->sections; current != NULL; current = current->next)
- if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
- sofar += SCNHSZ;
-#endif
-
- for (current = abfd->sections, count = 1;
- current != (asection *) NULL;
- current = current->next, ++count)
- {
- current->target_index = count;
-
- /* Only deal with sections which have contents */
- if (!(current->flags & SEC_HAS_CONTENTS))
- continue;
-
-#ifdef COFF_WITH_PE
- /* Do not include the .junk section. This is where we collect section
- data which we don't need. This is mainly the MS .debug$ data which
- stores codeview debug data. */
- if (strcmp (current->name, ".junk") == 0)
- {
- continue;
- }
-#endif
-
- /* Align the sections in the file to the same boundary on
- which they are aligned in virtual memory. I960 doesn't
- do this (FIXME) so we can stay in sync with Intel. 960
- doesn't yet page from files... */
-#ifndef I960
- if ((abfd->flags & EXEC_P) != 0)
- {
- /* make sure this section is aligned on the right boundary - by
- padding the previous section up if necessary */
-
- old_sofar = sofar;
- sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
- if (previous != (asection *) NULL)
- {
- previous->_raw_size += sofar - old_sofar;
- }
- }
-
-#endif
-
- /* In demand paged files the low order bits of the file offset
- must match the low order bits of the virtual address. */
-#ifdef COFF_PAGE_SIZE
- if ((abfd->flags & D_PAGED) != 0
- && (current->flags & SEC_ALLOC) != 0)
- sofar += (current->vma - sofar) % page_size;
-#endif
- current->filepos = sofar;
-
-#ifdef COFF_IMAGE_WITH_PE
- /* With PE we have to pad each section to be a multiple of its page size
- too, and remember both sizes. Cooked_size becomes very useful. */
- current->_cooked_size = current->_raw_size;
- current->_raw_size = (current->_raw_size + page_size -1) & -page_size;
-#endif
-
- sofar += current->_raw_size;
-
-#ifndef I960
- /* make sure that this section is of the right size too */
- old_sofar = sofar;
- sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
- current->_raw_size += sofar - old_sofar;
-#endif
-
-#ifdef _LIB
- /* Force .lib sections to start at zero. The vma is then
- incremented in coff_set_section_contents. This is right for
- SVR3.2. */
- if (strcmp (current->name, _LIB) == 0)
- bfd_set_section_vma (abfd, current, 0);
-#endif
-
- previous = current;
- }
-
- obj_relocbase (abfd) = sofar;
- abfd->output_has_begun = true;
-
-}
-
-#if 0
-
-/* This can never work, because it is called too late--after the
- section positions have been set. I can't figure out what it is
- for, so I am going to disable it--Ian Taylor 20 March 1996. */
-
-/* If .file, .text, .data, .bss symbols are missing, add them. */
-/* @@ Should we only be adding missing symbols, or overriding the aux
- values for existing section symbols? */
-static boolean
-coff_add_missing_symbols (abfd)
- bfd *abfd;
-{
- unsigned int nsyms = bfd_get_symcount (abfd);
- asymbol **sympp = abfd->outsymbols;
- asymbol **sympp2;
- unsigned int i;
- int need_text = 1, need_data = 1, need_bss = 1, need_file = 1;
-
- for (i = 0; i < nsyms; i++)
- {
- coff_symbol_type *csym = coff_symbol_from (abfd, sympp[i]);
- CONST char *name;
- if (csym)
- {
- /* only do this if there is a coff representation of the input
- symbol */
- if (csym->native && csym->native->u.syment.n_sclass == C_FILE)
- {
- need_file = 0;
- continue;
- }
- name = csym->symbol.name;
- if (!name)
- continue;
- if (!strcmp (name, _TEXT))
- need_text = 0;
-#ifdef APOLLO_M68
- else if (!strcmp (name, ".wtext"))
- need_text = 0;
-#endif
- else if (!strcmp (name, _DATA))
- need_data = 0;
- else if (!strcmp (name, _BSS))
- need_bss = 0;
- }
- }
- /* Now i == bfd_get_symcount (abfd). */
- /* @@ For now, don't deal with .file symbol. */
- need_file = 0;
-
- if (!need_text && !need_data && !need_bss && !need_file)
- return true;
- nsyms += need_text + need_data + need_bss + need_file;
- sympp2 = (asymbol **) bfd_alloc_by_size_t (abfd, nsyms * sizeof (asymbol *));
- if (!sympp2)
- return false;
- memcpy (sympp2, sympp, i * sizeof (asymbol *));
- if (need_file)
- {
- /* @@ Generate fake .file symbol, in sympp2[i], and increment i. */
- abort ();
- }
- if (need_text)
- sympp2[i++] = coff_section_symbol (abfd, _TEXT);
- if (need_data)
- sympp2[i++] = coff_section_symbol (abfd, _DATA);
- if (need_bss)
- sympp2[i++] = coff_section_symbol (abfd, _BSS);
- BFD_ASSERT (i == nsyms);
- bfd_set_symtab (abfd, sympp2, nsyms);
- return true;
-}
-
-#endif /* 0 */
-
-/* SUPPRESS 558 */
-/* SUPPRESS 529 */
-static boolean
-coff_write_object_contents (abfd)
- bfd * abfd;
-{
- asection *current;
- boolean hasrelocs = false;
- boolean haslinno = false;
- file_ptr scn_base;
- file_ptr reloc_base;
- file_ptr lineno_base;
- file_ptr sym_base;
- unsigned long reloc_size = 0;
- unsigned long lnno_size = 0;
- asection *text_sec = NULL;
- asection *data_sec = NULL;
- asection *bss_sec = NULL;
-
- struct internal_filehdr internal_f;
- struct internal_aouthdr internal_a;
-
- bfd_set_error (bfd_error_system_call);
-
- /* Make a pass through the symbol table to count line number entries and
- put them into the correct asections */
-
- lnno_size = coff_count_linenumbers (abfd) * LINESZ;
-
- if (abfd->output_has_begun == false)
- coff_compute_section_file_positions (abfd);
-
- reloc_base = obj_relocbase (abfd);
-
- /* Work out the size of the reloc and linno areas */
-
- for (current = abfd->sections; current != NULL; current =
- current->next)
- reloc_size += current->reloc_count * RELSZ;
-
- lineno_base = reloc_base + reloc_size;
- sym_base = lineno_base + lnno_size;
-
- /* Indicate in each section->line_filepos its actual file address */
- for (current = abfd->sections; current != NULL; current =
- current->next)
- {
- if (current->lineno_count)
- {
- current->line_filepos = lineno_base;
- current->moving_line_filepos = lineno_base;
- lineno_base += current->lineno_count * LINESZ;
- }
- else
- {
- current->line_filepos = 0;
- }
- if (current->reloc_count)
- {
- current->rel_filepos = reloc_base;
- reloc_base += current->reloc_count * RELSZ;
- }
- else
- {
- current->rel_filepos = 0;
- }
- }
-
- /* Write section headers to the file. */
- internal_f.f_nscns = 0;
-
- if ((abfd->flags & EXEC_P) != 0)
- scn_base = FILHSZ + AOUTSZ;
- else
- {
- scn_base = FILHSZ;
-#ifdef RS6000COFF_C
- if (xcoff_data (abfd)->full_aouthdr)
- scn_base += AOUTSZ;
- else
- scn_base += SMALL_AOUTSZ;
-#endif
- }
-
- if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
- return false;
-
- for (current = abfd->sections;
- current != NULL;
- current = current->next)
- {
- struct internal_scnhdr section;
-
-#ifdef COFF_WITH_PE
- /* Do not include the .junk section. This is where we collect section
- data which we don't need. This is mainly the MS .debug$ data which
- stores codeview debug data. */
- if (strcmp (current->name, ".junk") == 0)
- {
- continue;
- }
-
- /* If we've got a .reloc section, remember. */
-
-#ifdef COFF_IMAGE_WITH_PE
- if (strcmp (current->name, ".reloc") == 0)
- {
- pe_data (abfd)->has_reloc_section = 1;
- }
-#endif
-
-#endif
- internal_f.f_nscns++;
- strncpy (&(section.s_name[0]), current->name, 8);
-#ifdef _LIB
- /* Always set s_vaddr of .lib to 0. This is right for SVR3.2
- Ian Taylor <ian@cygnus.com>. */
- if (strcmp (current->name, _LIB) == 0)
- section.s_vaddr = 0;
- else
-#endif
- section.s_vaddr = current->vma;
- section.s_paddr = current->lma;
- section.s_size = current->_raw_size;
-
-#ifdef COFF_WITH_PE
- section.s_paddr = current->_cooked_size;
-#endif
-
- /*
- If this section has no size or is unloadable then the scnptr
- will be 0 too
- */
- if (current->_raw_size == 0 ||
- (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
- {
- section.s_scnptr = 0;
- }
- else
- {
- section.s_scnptr = current->filepos;
- }
- section.s_relptr = current->rel_filepos;
- section.s_lnnoptr = current->line_filepos;
- section.s_nreloc = current->reloc_count;
- section.s_nlnno = current->lineno_count;
- if (current->reloc_count != 0)
- hasrelocs = true;
- if (current->lineno_count != 0)
- haslinno = true;
-
-#ifdef RS6000COFF_C
- /* Indicate the use of an XCOFF overflow section header. */
- if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
- {
- section.s_nreloc = 0xffff;
- section.s_nlnno = 0xffff;
- }
-#endif
-
- section.s_flags = sec_to_styp_flags (current->name, current->flags);
-
- if (!strcmp (current->name, _TEXT))
- {
- text_sec = current;
- }
- else if (!strcmp (current->name, _DATA))
- {
- data_sec = current;
- }
- else if (!strcmp (current->name, _BSS))
- {
- bss_sec = current;
- }
-
-#ifdef I960
- section.s_align = (current->alignment_power
- ? 1 << current->alignment_power
- : 0);
-
-#endif
-
-#ifdef COFF_IMAGE_WITH_PE
- /* suppress output of the sections if they are null. ld includes
- the bss and data sections even if there is no size assigned
- to them. NT loader doesn't like it if these section headers are
- included if the sections themselves are not needed */
- if (section.s_size == 0)
- internal_f.f_nscns--;
- else
-#endif
- {
- SCNHDR buff;
- if (coff_swap_scnhdr_out (abfd, &section, &buff) == 0
- || bfd_write ((PTR) (&buff), 1, SCNHSZ, abfd) != SCNHSZ)
- return false;
- }
- }
-
-#ifdef RS6000COFF_C
- /* XCOFF handles overflows in the reloc and line number count fields
- by creating a new section header to hold the correct values. */
- for (current = abfd->sections; current != NULL; current = current->next)
- {
- if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
- {
- struct internal_scnhdr scnhdr;
- SCNHDR buff;
-
- internal_f.f_nscns++;
- strncpy (&(scnhdr.s_name[0]), current->name, 8);
- scnhdr.s_paddr = current->reloc_count;
- scnhdr.s_vaddr = current->lineno_count;
- scnhdr.s_size = 0;
- scnhdr.s_scnptr = 0;
- scnhdr.s_relptr = current->rel_filepos;
- scnhdr.s_lnnoptr = current->line_filepos;
- scnhdr.s_nreloc = current->target_index;
- scnhdr.s_nlnno = current->target_index;
- scnhdr.s_flags = STYP_OVRFLO;
- if (coff_swap_scnhdr_out (abfd, &scnhdr, &buff) == 0
- || bfd_write ((PTR) &buff, 1, SCNHSZ, abfd) != SCNHSZ)
- return false;
- }
- }
-#endif
-
- /* OK, now set up the filehdr... */
-
- /* Don't include the internal abs section in the section count */
-
- /*
- We will NOT put a fucking timestamp in the header here. Every time you
- put it back, I will come in and take it out again. I'm sorry. This
- field does not belong here. We fill it with a 0 so it compares the
- same but is not a reasonable time. -- gnu@cygnus.com
- */
- internal_f.f_timdat = 0;
-
- internal_f.f_flags = 0;
-
- if (abfd->flags & EXEC_P)
- internal_f.f_opthdr = AOUTSZ;
- else
- {
- internal_f.f_opthdr = 0;
-#ifdef RS6000COFF_C
- if (xcoff_data (abfd)->full_aouthdr)
- internal_f.f_opthdr = AOUTSZ;
- else
- internal_f.f_opthdr = SMALL_AOUTSZ;
-#endif
- }
-
- if (!hasrelocs)
- internal_f.f_flags |= F_RELFLG;
- if (!haslinno)
- internal_f.f_flags |= F_LNNO;
- if (abfd->flags & EXEC_P)
- internal_f.f_flags |= F_EXEC;
-
- /* FIXME: this is wrong for PPC_PE! */
- if (bfd_little_endian (abfd))
- internal_f.f_flags |= F_AR32WR;
- else
- internal_f.f_flags |= F_AR32W;
-
- /*
- FIXME, should do something about the other byte orders and
- architectures.
- */
-
-#ifdef RS6000COFF_C
- if ((abfd->flags & DYNAMIC) != 0)
- internal_f.f_flags |= F_SHROBJ;
- if (bfd_get_section_by_name (abfd, _LOADER) != NULL)
- internal_f.f_flags |= F_DYNLOAD;
-#endif
-
- memset (&internal_a, 0, sizeof internal_a);
-
- /* Set up architecture-dependent stuff */
-
- {
- unsigned int magic = 0;
- unsigned short flags = 0;
- coff_set_flags (abfd, &magic, &flags);
- internal_f.f_magic = magic;
- internal_f.f_flags |= flags;
- /* ...and the "opt"hdr... */
-
-#ifdef A29K
-#ifdef ULTRA3 /* NYU's machine */
- /* FIXME: This is a bogus check. I really want to see if there
- * is a .shbss or a .shdata section, if so then set the magic
- * number to indicate a shared data executable.
- */
- if (internal_f.f_nscns >= 7)
- internal_a.magic = SHMAGIC; /* Shared magic */
- else
-#endif /* ULTRA3 */
- internal_a.magic = NMAGIC; /* Assume separate i/d */
-#define __A_MAGIC_SET__
-#endif /* A29K */
-#ifdef I860
- /* FIXME: What are the a.out magic numbers for the i860? */
- internal_a.magic = 0;
-#define __A_MAGIC_SET__
-#endif /* I860 */
-#ifdef I960
- internal_a.magic = (magic == I960ROMAGIC ? NMAGIC : OMAGIC);
-#define __A_MAGIC_SET__
-#endif /* I960 */
-#if M88
-#define __A_MAGIC_SET__
- internal_a.magic = PAGEMAGICBCS;
-#endif /* M88 */
-
-#if APOLLO_M68
-#define __A_MAGIC_SET__
- internal_a.magic = APOLLO_COFF_VERSION_NUMBER;
-#endif
-
-#if defined(M68) || defined(WE32K) || defined(M68K)
-#define __A_MAGIC_SET__
-#if defined(LYNXOS)
- internal_a.magic = LYNXCOFFMAGIC;
-#else
-#if defined(TARG_AUX)
- internal_a.magic = (abfd->flags & D_PAGED ? PAGEMAGICPEXECPAGED :
- abfd->flags & WP_TEXT ? PAGEMAGICPEXECSWAPPED :
- PAGEMAGICEXECSWAPPED);
-#else
-#if defined (PAGEMAGICPEXECPAGED)
- internal_a.magic = PAGEMAGICPEXECPAGED;
-#endif
-#endif /* TARG_AUX */
-#endif /* LYNXOS */
-#endif /* M68 || WE32K || M68K */
-
-#if defined(ARM)
-#define __A_MAGIC_SET__
- internal_a.magic = ZMAGIC;
-#endif
-#if defined(PPC)
-#define __A_MAGIC_SET__
- internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
-#endif
-#if defined(I386)
-#define __A_MAGIC_SET__
-#if defined(LYNXOS)
- internal_a.magic = LYNXCOFFMAGIC;
-#else /* LYNXOS */
- internal_a.magic = ZMAGIC;
-#endif /* LYNXOS */
-#endif /* I386 */
-
-#if defined(SPARC)
-#define __A_MAGIC_SET__
-#if defined(LYNXOS)
- internal_a.magic = LYNXCOFFMAGIC;
-#endif /* LYNXOS */
-#endif /* SPARC */
-
-#if RS6000COFF_C
-#define __A_MAGIC_SET__
- internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC :
- (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC :
- RS6K_AOUTHDR_OMAGIC;
-#endif
-
-#ifndef __A_MAGIC_SET__
-#include "Your aouthdr magic number is not being set!"
-#else
-#undef __A_MAGIC_SET__
-#endif
- }
-
- /* FIXME: Does anybody ever set this to another value? */
- internal_a.vstamp = 0;
-
- /* Now should write relocs, strings, syms */
- obj_sym_filepos (abfd) = sym_base;
-
- if (bfd_get_symcount (abfd) != 0)
- {
- int firstundef;
-#if 0
- if (!coff_add_missing_symbols (abfd))
- return false;
-#endif
- if (!coff_renumber_symbols (abfd, &firstundef))
- return false;
- coff_mangle_symbols (abfd);
- if (! coff_write_symbols (abfd))
- return false;
- if (! coff_write_linenumbers (abfd))
- return false;
- if (! coff_write_relocs (abfd, firstundef))
- return false;
- }
-#ifdef COFF_IMAGE_WITH_PE
-#ifdef PPC
- else if ((abfd->flags & EXEC_P) != 0)
- {
- bfd_byte b;
-
- /* PowerPC PE appears to require that all executable files be
- rounded up to the page size. */
- b = 0;
- if (bfd_seek (abfd,
- BFD_ALIGN (sym_base, COFF_PAGE_SIZE) - 1,
- SEEK_SET) != 0
- || bfd_write (&b, 1, 1, abfd) != 1)
- return false;
- }
-#endif
-#endif
-
- /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF
- backend linker, and obj_raw_syment_count is not valid until after
- coff_write_symbols is called. */
- if (obj_raw_syment_count (abfd) != 0)
- {
- internal_f.f_symptr = sym_base;
-#ifdef RS6000COFF_C
- /* AIX appears to require that F_RELFLG not be set if there are
- local symbols but no relocations. */
- internal_f.f_flags &=~ F_RELFLG;
-#endif
- }
- else
- {
- internal_f.f_symptr = 0;
- internal_f.f_flags |= F_LSYMS;
- }
-
- if (text_sec)
- {
- internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
- internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
- }
- if (data_sec)
- {
- internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
- internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
- }
- if (bss_sec)
- {
- internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
- if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
- internal_a.data_start = bss_sec->vma;
- }
-
- internal_a.entry = bfd_get_start_address (abfd);
- internal_f.f_nsyms = obj_raw_syment_count (abfd);
-
-#ifdef RS6000COFF_C
- if (xcoff_data (abfd)->full_aouthdr)
- {
- bfd_vma toc;
- asection *loader_sec;
-
- internal_a.vstamp = 1;
-
- internal_a.o_snentry = xcoff_data (abfd)->snentry;
- if (internal_a.o_snentry == 0)
- internal_a.entry = (bfd_vma) -1;
-
- if (text_sec != NULL)
- {
- internal_a.o_sntext = text_sec->target_index;
- internal_a.o_algntext = bfd_get_section_alignment (abfd, text_sec);
- }
- else
- {
- internal_a.o_sntext = 0;
- internal_a.o_algntext = 0;
- }
- if (data_sec != NULL)
- {
- internal_a.o_sndata = data_sec->target_index;
- internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec);
- }
- else
- {
- internal_a.o_sndata = 0;
- internal_a.o_algndata = 0;
- }
- loader_sec = bfd_get_section_by_name (abfd, ".loader");
- if (loader_sec != NULL)
- internal_a.o_snloader = loader_sec->target_index;
- else
- internal_a.o_snloader = 0;
- if (bss_sec != NULL)
- internal_a.o_snbss = bss_sec->target_index;
- else
- internal_a.o_snbss = 0;
-
- toc = xcoff_data (abfd)->toc;
- internal_a.o_toc = toc;
- internal_a.o_sntoc = xcoff_data (abfd)->sntoc;
-
- internal_a.o_modtype = xcoff_data (abfd)->modtype;
- if (xcoff_data (abfd)->cputype != -1)
- internal_a.o_cputype = xcoff_data (abfd)->cputype;
- else
- {
- switch (bfd_get_arch (abfd))
- {
- case bfd_arch_rs6000:
- internal_a.o_cputype = 4;
- break;
- case bfd_arch_powerpc:
- if (bfd_get_mach (abfd) == 0)
- internal_a.o_cputype = 3;
- else
- internal_a.o_cputype = 1;
- break;
- default:
- abort ();
- }
- }
- internal_a.o_maxstack = xcoff_data (abfd)->maxstack;
- internal_a.o_maxdata = xcoff_data (abfd)->maxdata;
- }
-#endif
-
- /* now write them */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- return false;
- {
- FILHDR buff;
- coff_swap_filehdr_out (abfd, (PTR) & internal_f, (PTR) & buff);
- if (bfd_write ((PTR) & buff, 1, FILHSZ, abfd) != FILHSZ)
- return false;
- }
- if (abfd->flags & EXEC_P)
- {
- AOUTHDR buff;
- coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) & buff);
- if (bfd_write ((PTR) & buff, 1, AOUTSZ, abfd) != AOUTSZ)
- return false;
- }
-#ifdef RS6000COFF_C
- else
- {
- AOUTHDR buff;
- size_t size;
-
- /* XCOFF seems to always write at least a small a.out header. */
- coff_swap_aouthdr_out (abfd, (PTR) &internal_a, (PTR) &buff);
- if (xcoff_data (abfd)->full_aouthdr)
- size = AOUTSZ;
- else
- size = SMALL_AOUTSZ;
- if (bfd_write ((PTR) &buff, 1, size, abfd) != size)
- return false;
- }
-#endif
-
- return true;
-}
-
-static boolean
-coff_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 by bfd.c handler */
- coff_compute_section_file_positions (abfd);
-
-#ifdef _LIB
-
- /* The physical address field of a .lib section is used to hold the
- number of shared libraries in the section. This code counts the
- number of sections being written, and increments the lma field
- with the number.
-
- I have found no documentation on the contents of this section.
- Experimentation indicates that the section contains zero or more
- records, each of which has the following structure:
-
- - a (four byte) word holding the length of this record, in words,
- - a word that always seems to be set to "2",
- - the path to a shared library, null-terminated and then padded
- to a whole word boundary.
-
- bfd_assert calls have been added to alert if an attempt is made
- to write a section which doesn't follow these assumptions. The
- code has been tested on ISC 4.1 by me, and on SCO by Robert Lipe
- <robertl@arnet.com> (Thanks!).
-
- Gvran Uddeborg <gvran@uddeborg.pp.se> */
-
- if (strcmp (section->name, _LIB) == 0)
- {
- bfd_byte *rec, *recend;
-
- rec = (bfd_byte *) location;
- recend = rec + count;
- while (rec < recend)
- {
- ++section->lma;
- rec += bfd_get_32 (abfd, rec) * 4;
- }
-
- BFD_ASSERT (rec == recend);
- }
-
-#endif
-
- /* Don't write out bss sections - one way to do this is to
- see if the filepos has not been set. */
- if (section->filepos == 0)
- return true;
-
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0)
- return false;
-
- if (count != 0)
- {
- return (bfd_write (location, 1, count, abfd) == count) ? true : false;
- }
- return true;
-}
-#if 0
-static boolean
-coff_close_and_cleanup (abfd)
- bfd *abfd;
-{
- if (!bfd_read_p (abfd))
- switch (abfd->format)
- {
- case bfd_archive:
- if (!_bfd_write_archive_contents (abfd))
- return false;
- break;
- case bfd_object:
- if (!coff_write_object_contents (abfd))
- return false;
- break;
- default:
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- /* We depend on bfd_close to free all the memory on the obstack. */
- /* FIXME if bfd_release is not using obstacks! */
- return true;
-}
-
-#endif
-
-static PTR
-buy_and_read (abfd, where, seek_direction, size)
- bfd *abfd;
- file_ptr where;
- int seek_direction;
- size_t size;
-{
- PTR area = (PTR) bfd_alloc (abfd, size);
- if (!area)
- return (NULL);
- if (bfd_seek (abfd, where, seek_direction) != 0
- || bfd_read (area, 1, size, abfd) != size)
- return (NULL);
- return (area);
-} /* buy_and_read() */
-
-/*
-SUBSUBSECTION
- Reading linenumbers
-
- Creating the linenumber table is done by reading in the entire
- coff linenumber table, and creating another table for internal use.
-
- A coff linenumber table is structured so that each function
- is marked as having a line number of 0. Each line within the
- function is an offset from the first line in the function. The
- base of the line number information for the table is stored in
- the symbol associated with the function.
-
- The information is copied from the external to the internal
- table, and each symbol which marks a function is marked by
- pointing its...
-
- How does this work ?
-
-*/
-
-static boolean
-coff_slurp_line_table (abfd, asect)
- bfd *abfd;
- asection *asect;
-{
- LINENO *native_lineno;
- alent *lineno_cache;
-
- BFD_ASSERT (asect->lineno == (alent *) NULL);
-
- native_lineno = (LINENO *) buy_and_read (abfd,
- asect->line_filepos,
- SEEK_SET,
- (size_t) (LINESZ *
- asect->lineno_count));
- lineno_cache =
- (alent *) bfd_alloc (abfd, (size_t) ((asect->lineno_count + 1) * sizeof (alent)));
- if (lineno_cache == NULL)
- return false;
- else
- {
- unsigned int counter = 0;
- alent *cache_ptr = lineno_cache;
- LINENO *src = native_lineno;
-
- while (counter < asect->lineno_count)
- {
- struct internal_lineno dst;
- coff_swap_lineno_in (abfd, src, &dst);
- cache_ptr->line_number = dst.l_lnno;
-
- if (cache_ptr->line_number == 0)
- {
- coff_symbol_type *sym =
- (coff_symbol_type *) (dst.l_addr.l_symndx
- + obj_raw_syments (abfd))->u.syment._n._n_n._n_zeroes;
- cache_ptr->u.sym = (asymbol *) sym;
- if (sym->lineno != NULL)
- {
- (*_bfd_error_handler)
- ("%s: warning: duplicate line number information for `%s'",
- bfd_get_filename (abfd),
- bfd_asymbol_name (&sym->symbol));
- }
- sym->lineno = cache_ptr;
- }
- else
- {
- cache_ptr->u.offset = dst.l_addr.l_paddr
- - bfd_section_vma (abfd, asect);
- } /* If no linenumber expect a symbol index */
-
- cache_ptr++;
- src++;
- counter++;
- }
- cache_ptr->line_number = 0;
-
- }
- asect->lineno = lineno_cache;
- /* FIXME, free native_lineno here, or use alloca or something. */
- return true;
-}
-
-static boolean
-coff_slurp_symbol_table (abfd)
- bfd * abfd;
-{
- combined_entry_type *native_symbols;
- coff_symbol_type *cached_area;
- unsigned int *table_ptr;
-
- unsigned int number_of_symbols = 0;
-
- if (obj_symbols (abfd))
- return true;
-
- /* Read in the symbol table */
- if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
- {
- return (false);
- } /* on error */
-
- /* Allocate enough room for all the symbols in cached form */
- cached_area = ((coff_symbol_type *)
- bfd_alloc (abfd,
- (obj_raw_syment_count (abfd)
- * sizeof (coff_symbol_type))));
-
- if (cached_area == NULL)
- return false;
- table_ptr = ((unsigned int *)
- bfd_alloc (abfd,
- (obj_raw_syment_count (abfd)
- * sizeof (unsigned int))));
-
- if (table_ptr == NULL)
- return false;
- else
- {
- coff_symbol_type *dst = cached_area;
- unsigned int last_native_index = obj_raw_syment_count (abfd);
- unsigned int this_index = 0;
- while (this_index < last_native_index)
- {
- combined_entry_type *src = native_symbols + this_index;
- table_ptr[this_index] = number_of_symbols;
- dst->symbol.the_bfd = abfd;
-
- dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
- /* We use the native name field to point to the cached field. */
- src->u.syment._n._n_n._n_zeroes = (long) dst;
- dst->symbol.section = coff_section_from_bfd_index (abfd,
- src->u.syment.n_scnum);
- dst->symbol.flags = 0;
- dst->done_lineno = false;
-
- switch (src->u.syment.n_sclass)
- {
-#ifdef I960
- case C_LEAFEXT:
-#if 0
- dst->symbol.value = src->u.syment.n_value - dst->symbol.section->vma;
- dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
- dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
-#endif
- /* Fall through to next case */
-
-#endif
-
- case C_EXT:
-#ifdef RS6000COFF_C
- case C_HIDEXT:
-#endif
-#ifdef COFF_WITH_PE
- /* PE uses storage class 0x68 to denote a section symbol */
- case C_SECTION:
- /* PE uses storage class 0x67 for a weak external symbol. */
- case C_NT_WEAK:
-#endif
- if ((src->u.syment.n_scnum) == 0)
- {
- if ((src->u.syment.n_value) == 0)
- {
- dst->symbol.section = bfd_und_section_ptr;
- dst->symbol.value = 0;
- }
- else
- {
- dst->symbol.section = bfd_com_section_ptr;
- dst->symbol.value = (src->u.syment.n_value);
- }
- }
- else
- {
- /* Base the value as an index from the base of the
- section */
-
- dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
- dst->symbol.value = (src->u.syment.n_value
- - dst->symbol.section->vma);
-
- if (ISFCN ((src->u.syment.n_type)))
- {
- /* A function ext does not go at the end of a
- file. */
- dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
- }
- }
-
-#ifdef RS6000COFF_C
- /* A C_HIDEXT symbol is not global. */
- if (src->u.syment.n_sclass == C_HIDEXT)
- dst->symbol.flags = BSF_LOCAL;
- /* A symbol with a csect entry should not go at the end. */
- if (src->u.syment.n_numaux > 0)
- dst->symbol.flags |= BSF_NOT_AT_END;
-#endif
-
-#ifdef COFF_WITH_PE
- if (src->u.syment.n_sclass == C_NT_WEAK)
- dst->symbol.flags = BSF_WEAK;
-#endif
-
- break;
-
- case C_STAT: /* static */
-#ifdef I960
- case C_LEAFSTAT: /* static leaf procedure */
-#endif
- case C_LABEL: /* label */
- if (src->u.syment.n_scnum == -2)
- dst->symbol.flags = BSF_DEBUGGING;
- else
- dst->symbol.flags = BSF_LOCAL;
- /*
- Base the value as an index from the base of the section, if
- there is one
- */
- if (dst->symbol.section)
- dst->symbol.value = (src->u.syment.n_value) -
- dst->symbol.section->vma;
- else
- dst->symbol.value = (src->u.syment.n_value);
- break;
-
- case C_MOS: /* member of structure */
- case C_EOS: /* end of structure */
-#ifdef NOTDEF /* C_AUTOARG has the same value */
-#ifdef C_GLBLREG
- case C_GLBLREG: /* A29k-specific storage class */
-#endif
-#endif
- case C_REGPARM: /* register parameter */
- case C_REG: /* register variable */
-#ifdef C_AUTOARG
- case C_AUTOARG: /* 960-specific storage class */
-#endif
- case C_TPDEF: /* type definition */
- case C_ARG:
- case C_AUTO: /* automatic variable */
- case C_FIELD: /* bit field */
- case C_ENTAG: /* enumeration tag */
- case C_MOE: /* member of enumeration */
- case C_MOU: /* member of union */
- case C_UNTAG: /* union tag */
- dst->symbol.flags = BSF_DEBUGGING;
- dst->symbol.value = (src->u.syment.n_value);
- break;
-
- case C_FILE: /* file name */
- case C_STRTAG: /* structure tag */
-#ifdef RS6000COFF_C
- case C_GSYM:
- case C_LSYM:
- case C_PSYM:
- case C_RSYM:
- case C_RPSYM:
- case C_STSYM:
- case C_BCOMM:
- case C_ECOMM:
- case C_DECL:
- case C_ENTRY:
- case C_FUN:
- case C_ESTAT:
-#endif
- dst->symbol.flags = BSF_DEBUGGING;
- dst->symbol.value = (src->u.syment.n_value);
- break;
-
-#ifdef RS6000COFF_C
- case C_BINCL: /* beginning of include file */
- case C_EINCL: /* ending of include file */
- /* The value is actually a pointer into the line numbers
- of the file. We locate the line number entry, and
- set the section to the section which contains it, and
- the value to the index in that section. */
- {
- asection *sec;
-
- dst->symbol.flags = BSF_DEBUGGING;
- for (sec = abfd->sections; sec != NULL; sec = sec->next)
- if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
- && ((file_ptr) (sec->line_filepos
- + sec->lineno_count * LINESZ)
- > (file_ptr) src->u.syment.n_value))
- break;
- if (sec == NULL)
- dst->symbol.value = 0;
- else
- {
- dst->symbol.section = sec;
- dst->symbol.value = ((src->u.syment.n_value
- - sec->line_filepos)
- / LINESZ);
- src->fix_line = 1;
- }
- }
- break;
-
- case C_BSTAT:
- dst->symbol.flags = BSF_DEBUGGING;
-
- /* The value is actually a symbol index. Save a pointer
- to the symbol instead of the index. FIXME: This
- should use a union. */
- src->u.syment.n_value =
- (long) (native_symbols + src->u.syment.n_value);
- dst->symbol.value = src->u.syment.n_value;
- src->fix_value = 1;
- break;
-#endif
-
- case C_BLOCK: /* ".bb" or ".eb" */
- case C_FCN: /* ".bf" or ".ef" */
- case C_EFCN: /* physical end of function */
- dst->symbol.flags = BSF_LOCAL;
- /*
- Base the value as an index from the base of the section
- */
- dst->symbol.value = (src->u.syment.n_value) - dst->symbol.section->vma;
- break;
-
- case C_NULL:
- case C_EXTDEF: /* external definition */
- case C_ULABEL: /* undefined label */
- case C_USTATIC: /* undefined static */
-#ifndef COFF_WITH_PE
- /* C_LINE in regular coff is 0x68. NT has taken over this storage
- class to represent a section symbol */
- case C_LINE: /* line # reformatted as symbol table entry */
- /* NT uses 0x67 for a weak symbol, not C_ALIAS. */
- case C_ALIAS: /* duplicate tag */
-#endif
- case C_HIDDEN: /* ext symbol in dmert public lib */
- default:
- (*_bfd_error_handler)
- ("%s: Unrecognized storage class %d for %s symbol `%s'",
- bfd_get_filename (abfd), src->u.syment.n_sclass,
- dst->symbol.section->name, dst->symbol.name);
- dst->symbol.flags = BSF_DEBUGGING;
- dst->symbol.value = (src->u.syment.n_value);
- break;
- }
-
-/* BFD_ASSERT(dst->symbol.flags != 0);*/
-
- dst->native = src;
-
- dst->symbol.udata.i = 0;
- dst->lineno = (alent *) NULL;
- this_index += (src->u.syment.n_numaux) + 1;
- dst++;
- number_of_symbols++;
- } /* walk the native symtab */
- } /* bfdize the native symtab */
-
- obj_symbols (abfd) = cached_area;
- obj_raw_syments (abfd) = native_symbols;
-
- bfd_get_symcount (abfd) = number_of_symbols;
- obj_convert (abfd) = table_ptr;
- /* Slurp the line tables for each section too */
- {
- asection *p;
- p = abfd->sections;
- while (p)
- {
- coff_slurp_line_table (abfd, p);
- p = p->next;
- }
- }
- return true;
-} /* coff_slurp_symbol_table() */
-
-/* Check whether a symbol is globally visible. This is used by the
- COFF backend linker code in cofflink.c, since a couple of targets
- have globally visible symbols which are not class C_EXT. This
- function need not handle the case of n_class == C_EXT. */
-
-#undef OTHER_GLOBAL_CLASS
-
-#ifdef I960
-#define OTHER_GLOBAL_CLASS C_LEAFEXT
-#endif
-
-#ifdef COFF_WITH_PE
-#define OTHER_GLOBAL_CLASS C_SECTION
-#endif
-
-#ifdef OTHER_GLOBAL_CLASS
-
-static boolean
-coff_sym_is_global (abfd, syment)
- bfd *abfd;
- struct internal_syment *syment;
-{
- if (syment->n_sclass == OTHER_GLOBAL_CLASS)
- return true;
- return false;
-}
-
-#undef OTHER_GLOBAL_CLASS
-
-#else /* ! defined (OTHER_GLOBAL_CLASS) */
-
-/* sym_is_global should not be defined if it has nothing to do. */
-
-#define coff_sym_is_global 0
-
-#endif /* ! defined (OTHER_GLOBAL_CLASS) */
-
-/*
-SUBSUBSECTION
- Reading relocations
-
- Coff relocations are easily transformed into the internal BFD form
- (@code{arelent}).
-
- Reading a coff relocation table is done in the following stages:
-
- o Read the entire coff relocation table into memory.
-
- o Process each relocation in turn; first swap it from the
- external to the internal form.
-
- o Turn the symbol referenced in the relocation's symbol index
- into a pointer into the canonical symbol table.
- This table is the same as the one returned by a call to
- @code{bfd_canonicalize_symtab}. The back end will call that
- routine and save the result if a canonicalization hasn't been done.
-
- o The reloc index is turned into a pointer to a howto
- structure, in a back end specific way. For instance, the 386
- and 960 use the @code{r_type} to directly produce an index
- into a howto table vector; the 88k subtracts a number from the
- @code{r_type} field and creates an addend field.
-
-
-*/
-
-#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; \
- }
-#endif
-
-static boolean
-coff_slurp_reloc_table (abfd, asect, symbols)
- bfd * abfd;
- sec_ptr asect;
- asymbol ** symbols;
-{
- RELOC *native_relocs;
- arelent *reloc_cache;
- arelent *cache_ptr;
-
- unsigned int idx;
-
- if (asect->relocation)
- return true;
- if (asect->reloc_count == 0)
- return true;
- if (asect->flags & SEC_CONSTRUCTOR)
- return true;
- if (!coff_slurp_symbol_table (abfd))
- return false;
- native_relocs =
- (RELOC *) buy_and_read (abfd,
- asect->rel_filepos,
- SEEK_SET,
- (size_t) (RELSZ *
- asect->reloc_count));
- reloc_cache = (arelent *)
- bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent)));
-
- if (reloc_cache == NULL)
- return false;
-
-
- for (idx = 0; idx < asect->reloc_count; idx++)
- {
-#ifdef RELOC_PROCESSING
- struct internal_reloc dst;
- struct external_reloc *src;
-
- cache_ptr = reloc_cache + idx;
- src = native_relocs + idx;
- coff_swap_reloc_in (abfd, src, &dst);
-
- RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
-#else
- struct internal_reloc dst;
- asymbol *ptr;
- struct external_reloc *src;
-
- cache_ptr = reloc_cache + idx;
- src = native_relocs + idx;
-
- coff_swap_reloc_in (abfd, src, &dst);
-
-
- cache_ptr->address = dst.r_vaddr;
-
- if (dst.r_symndx != -1)
- {
- /* @@ Should never be greater than count of symbols! */
- if (dst.r_symndx >= obj_conv_table_size (abfd))
- abort ();
- cache_ptr->sym_ptr_ptr = symbols + obj_convert (abfd)[dst.r_symndx];
- ptr = *(cache_ptr->sym_ptr_ptr);
- }
- else
- {
- cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- ptr = 0;
- }
-
- /* The symbols definitions that we have read in have been
- relocated as if their sections started at 0. But the offsets
- refering to the symbols in the raw data have not been
- modified, so we have to have a negative addend to compensate.
-
- Note that symbols which used to be common must be left alone */
-
- /* Calculate any reloc addend by looking at the symbol */
- CALC_ADDEND (abfd, ptr, dst, cache_ptr);
-
- cache_ptr->address -= asect->vma;
-/* !! cache_ptr->section = (asection *) NULL;*/
-
- /* Fill in the cache_ptr->howto field from dst.r_type */
- RTYPE2HOWTO (cache_ptr, &dst);
-#endif
-
- }
-
- asect->relocation = reloc_cache;
- return true;
-}
-
-#ifndef coff_rtype_to_howto
-#ifdef RTYPE2HOWTO
-
-/* Get the howto structure for a reloc. This is only used if the file
- including this one defines coff_relocate_section to be
- _bfd_coff_generic_relocate_section, so it is OK if it does not
- always work. It is the responsibility of the including file to
- make sure it is reasonable if it is needed. */
-
-static reloc_howto_type *coff_rtype_to_howto
- PARAMS ((bfd *, asection *, struct internal_reloc *,
- struct coff_link_hash_entry *, struct internal_syment *,
- bfd_vma *));
-
-/*ARGSUSED*/
-static reloc_howto_type *
-coff_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 genrel;
-
- RTYPE2HOWTO (&genrel, rel);
- return genrel.howto;
-}
-
-#else /* ! defined (RTYPE2HOWTO) */
-
-#define coff_rtype_to_howto NULL
-
-#endif /* ! defined (RTYPE2HOWTO) */
-#endif /* ! defined (coff_rtype_to_howto) */
-
-/* This is stupid. This function should be a boolean predicate. */
-static long
-coff_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd * abfd;
- sec_ptr section;
- arelent ** relptr;
- asymbol ** symbols;
-{
- arelent *tblptr = section->relocation;
- unsigned int count = 0;
-
-
- if (section->flags & SEC_CONSTRUCTOR)
- {
- /* this section has relocs made up by us, they are not in the
- file, so take them out of their chain and place them into
- the data area provided */
- arelent_chain *chain = section->constructor_chain;
- for (count = 0; count < section->reloc_count; count++)
- {
- *relptr++ = &chain->relent;
- chain = chain->next;
- }
-
- }
- else
- {
- if (! coff_slurp_reloc_table (abfd, section, symbols))
- return -1;
-
- tblptr = section->relocation;
-
- for (; count++ < section->reloc_count;)
- *relptr++ = tblptr++;
-
-
- }
- *relptr = 0;
- return section->reloc_count;
-}
-
-#ifdef GNU960
-file_ptr
-coff_sym_filepos (abfd)
- bfd *abfd;
-{
- return obj_sym_filepos (abfd);
-}
-#endif
-
-#ifndef coff_reloc16_estimate
-#define coff_reloc16_estimate dummy_reloc16_estimate
-
-static int
-dummy_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;
-{
- abort ();
-}
-
-#endif
-
-#ifndef coff_reloc16_extra_cases
-#define coff_reloc16_extra_cases dummy_reloc16_extra_cases
-/* This works even if abort is not declared in any header file. */
-static void
-dummy_reloc16_extra_cases (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;
-{
- abort ();
-}
-#endif
-
-/* If coff_relocate_section is defined, we can use the optimized COFF
- backend linker. Otherwise we must continue to use the old linker. */
-#ifdef coff_relocate_section
-#ifndef coff_bfd_link_hash_table_create
-#define coff_bfd_link_hash_table_create _bfd_coff_link_hash_table_create
-#endif
-#ifndef coff_bfd_link_add_symbols
-#define coff_bfd_link_add_symbols _bfd_coff_link_add_symbols
-#endif
-#ifndef coff_bfd_final_link
-#define coff_bfd_final_link _bfd_coff_final_link
-#endif
-#else /* ! defined (coff_relocate_section) */
-#define coff_relocate_section NULL
-#define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#ifndef coff_bfd_link_add_symbols
-#define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#endif
-#define coff_bfd_final_link _bfd_generic_final_link
-#endif /* ! defined (coff_relocate_section) */
-#define coff_bfd_link_split_section _bfd_generic_link_split_section
-
-#ifndef coff_start_final_link
-#define coff_start_final_link NULL
-#endif
-
-#ifndef coff_adjust_symndx
-#define coff_adjust_symndx NULL
-#endif
-
-#ifndef coff_link_add_one_symbol
-#define coff_link_add_one_symbol _bfd_generic_link_add_one_symbol
-#endif
-
-static CONST bfd_coff_backend_data bfd_coff_std_swap_table =
-{
- coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in,
- coff_swap_aux_out, coff_swap_sym_out,
- coff_swap_lineno_out, coff_swap_reloc_out,
- coff_swap_filehdr_out, coff_swap_aouthdr_out,
- coff_swap_scnhdr_out,
- FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, RELSZ, LINESZ,
-#ifdef COFF_LONG_FILENAMES
- true,
-#else
- false,
-#endif
- coff_swap_filehdr_in, coff_swap_aouthdr_in, coff_swap_scnhdr_in,
- coff_swap_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook,
- coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
- coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
- coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
- coff_sym_is_global, coff_compute_section_file_positions,
- coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
- coff_adjust_symndx, coff_link_add_one_symbol
-};
-
-#define coff_close_and_cleanup _bfd_generic_close_and_cleanup
-#define coff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define coff_get_section_contents _bfd_generic_get_section_contents
-
-#ifndef coff_bfd_copy_private_symbol_data
-#define coff_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
-#endif
-
-#ifndef coff_bfd_copy_private_section_data
-#define coff_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
-#endif
-
-#ifndef coff_bfd_copy_private_bfd_data
-#define coff_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
-#endif
-
-#define coff_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
-#define coff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
-
-#ifndef coff_bfd_print_private_bfd_data
-#define coff_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
-#endif
-
-#ifndef coff_bfd_is_local_label
-#define coff_bfd_is_local_label bfd_generic_is_local_label
-#endif
-#ifndef coff_read_minisymbols
-#define coff_read_minisymbols _bfd_generic_read_minisymbols
-#endif
-#ifndef coff_minisymbol_to_symbol
-#define coff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-#endif
-
-/* The reloc lookup routine must be supplied by each individual COFF
- backend. */
-#ifndef coff_bfd_reloc_type_lookup
-#define coff_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-#endif
-
-#ifndef coff_bfd_get_relocated_section_contents
-#define coff_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#endif
-#ifndef coff_bfd_relax_section
-#define coff_bfd_relax_section bfd_generic_relax_section
-#endif
diff --git a/contrib/gdb/bfd/coffgen.c b/contrib/gdb/bfd/coffgen.c
deleted file mode 100644
index 285fe61ccc53..000000000000
--- a/contrib/gdb/bfd/coffgen.c
+++ /dev/null
@@ -1,2121 +0,0 @@
-/* Support for the generic parts of COFF, for BFD.
- 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. */
-
-/* Most of this hacked by Steve Chamberlain, sac@cygnus.com.
- Split out of coffcode.h by Ian Taylor, ian@cygnus.com. */
-
-/* This file contains COFF code that is not dependent on any
- particular COFF target. There is only one version of this file in
- libbfd.a, so no target specific code may be put in here. Or, to
- put it another way,
-
- ********** DO NOT PUT TARGET SPECIFIC CODE IN THIS FILE **********
-
- If you need to add some target specific behaviour, add a new hook
- function to bfd_coff_backend_data.
-
- Some of these functions are also called by the ECOFF routines.
- Those functions may not use any COFF specific information, such as
- coff_data (abfd). */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-static void coff_fix_symbol_name
- PARAMS ((bfd *, asymbol *, combined_entry_type *, bfd_size_type *,
- asection **, bfd_size_type *));
-static boolean coff_write_symbol
- PARAMS ((bfd *, asymbol *, combined_entry_type *, unsigned int *,
- bfd_size_type *, asection **, bfd_size_type *));
-static boolean coff_write_alien_symbol
- PARAMS ((bfd *, asymbol *, unsigned int *, bfd_size_type *,
- asection **, bfd_size_type *));
-static boolean coff_write_native_symbol
- PARAMS ((bfd *, coff_symbol_type *, unsigned int *, bfd_size_type *,
- asection **, bfd_size_type *));
-static void coff_pointerize_aux
- PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
- unsigned int, combined_entry_type *));
-
-#define STRING_SIZE_SIZE (4)
-
-/* Take a section header read from a coff file (in HOST byte order),
- and make a BFD "section" out of it. This is used by ECOFF. */
-static boolean
-make_a_section_from_file (abfd, hdr, target_index)
- bfd *abfd;
- struct internal_scnhdr *hdr;
- unsigned int target_index;
-{
- asection *return_section;
- char *name;
-
- /* Assorted wastage to null-terminate the name, thanks AT&T! */
- name = bfd_alloc (abfd, sizeof (hdr->s_name) + 1);
- if (name == NULL)
- return false;
- strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
- name[sizeof (hdr->s_name)] = 0;
-
- return_section = bfd_make_section_anyway (abfd, name);
- if (return_section == NULL)
- return false;
-
- return_section->vma = hdr->s_vaddr;
- return_section->lma = hdr->s_paddr;
- return_section->_raw_size = hdr->s_size;
- return_section->filepos = hdr->s_scnptr;
- return_section->rel_filepos = hdr->s_relptr;
- return_section->reloc_count = hdr->s_nreloc;
-
- bfd_coff_set_alignment_hook (abfd, return_section, hdr);
-
- return_section->line_filepos = hdr->s_lnnoptr;
-
- return_section->lineno_count = hdr->s_nlnno;
- return_section->userdata = NULL;
- return_section->next = (asection *) NULL;
- return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name);
-
- return_section->target_index = target_index;
-
- /* At least on i386-coff, the line number count for a shared library
- section must be ignored. */
- if ((return_section->flags & SEC_COFF_SHARED_LIBRARY) != 0)
- return_section->lineno_count = 0;
-
- if (hdr->s_nreloc != 0)
- return_section->flags |= SEC_RELOC;
- /* FIXME: should this check 'hdr->s_size > 0' */
- if (hdr->s_scnptr != 0)
- return_section->flags |= SEC_HAS_CONTENTS;
- return true;
-}
-
-/* Read in a COFF object and make it into a BFD. This is used by
- ECOFF as well. */
-
-static const bfd_target *
-coff_real_object_p (abfd, nscns, internal_f, internal_a)
- bfd *abfd;
- unsigned nscns;
- struct internal_filehdr *internal_f;
- struct internal_aouthdr *internal_a;
-{
- flagword oflags = abfd->flags;
- bfd_vma ostart = bfd_get_start_address (abfd);
- PTR tdata;
- size_t readsize; /* length of file_info */
- unsigned int scnhsz;
- char *external_sections;
-
- if (!(internal_f->f_flags & F_RELFLG))
- abfd->flags |= HAS_RELOC;
- if ((internal_f->f_flags & F_EXEC))
- abfd->flags |= EXEC_P;
- if (!(internal_f->f_flags & F_LNNO))
- abfd->flags |= HAS_LINENO;
- if (!(internal_f->f_flags & F_LSYMS))
- abfd->flags |= HAS_LOCALS;
-
- /* FIXME: How can we set D_PAGED correctly? */
- if ((internal_f->f_flags & F_EXEC) != 0)
- abfd->flags |= D_PAGED;
-
- bfd_get_symcount (abfd) = internal_f->f_nsyms;
- if (internal_f->f_nsyms)
- abfd->flags |= HAS_SYMS;
-
- if (internal_a != (struct internal_aouthdr *) NULL)
- bfd_get_start_address (abfd) = internal_a->entry;
- else
- bfd_get_start_address (abfd) = 0;
-
- /* Set up the tdata area. ECOFF uses its own routine, and overrides
- abfd->flags. */
- tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f, (PTR) internal_a);
- if (tdata == NULL)
- return 0;
-
- scnhsz = bfd_coff_scnhsz (abfd);
- readsize = nscns * scnhsz;
- external_sections = (char *) bfd_alloc (abfd, readsize);
- if (!external_sections)
- goto fail;
-
- if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize)
- goto fail;
-
- /* Now copy data as required; construct all asections etc */
- if (nscns != 0)
- {
- unsigned int i;
- for (i = 0; i < nscns; i++)
- {
- struct internal_scnhdr tmp;
- bfd_coff_swap_scnhdr_in (abfd,
- (PTR) (external_sections + i * scnhsz),
- (PTR) & tmp);
- make_a_section_from_file (abfd, &tmp, i + 1);
- }
- }
-
- /* make_abs_section (abfd); */
-
- if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false)
- goto fail;
-
- return abfd->xvec;
-
- fail:
- bfd_release (abfd, tdata);
- abfd->flags = oflags;
- bfd_get_start_address (abfd) = ostart;
- return (const bfd_target *) NULL;
-}
-
-/* Turn a COFF file into a BFD, but fail with bfd_error_wrong_format if it is
- not a COFF file. This is also used by ECOFF. */
-
-const bfd_target *
-coff_object_p (abfd)
- bfd *abfd;
-{
- unsigned int filhsz;
- unsigned int aoutsz;
- int nscns;
- PTR filehdr;
- struct internal_filehdr internal_f;
- struct internal_aouthdr internal_a;
-
- /* figure out how much to read */
- filhsz = bfd_coff_filhsz (abfd);
- aoutsz = bfd_coff_aoutsz (abfd);
-
- filehdr = bfd_alloc (abfd, filhsz);
- if (filehdr == NULL)
- return 0;
- if (bfd_read (filehdr, 1, filhsz, abfd) != filhsz)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
- bfd_coff_swap_filehdr_in (abfd, filehdr, &internal_f);
- bfd_release (abfd, filehdr);
-
- if (bfd_coff_bad_format_hook (abfd, &internal_f) == false)
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
- nscns = internal_f.f_nscns;
-
- if (internal_f.f_opthdr)
- {
- PTR opthdr;
-
- opthdr = bfd_alloc (abfd, aoutsz);
- if (opthdr == NULL)
- return 0;;
- if (bfd_read (opthdr, 1, aoutsz, abfd) != aoutsz)
- {
- return 0;
- }
- bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) & internal_a);
- }
-
- /* Seek past the opt hdr stuff */
- if (bfd_seek (abfd, (file_ptr) (internal_f.f_opthdr + filhsz), SEEK_SET)
- != 0)
- return NULL;
-
- return coff_real_object_p (abfd, nscns, &internal_f,
- (internal_f.f_opthdr != 0
- ? &internal_a
- : (struct internal_aouthdr *) NULL));
-}
-
-/* Get the BFD section from a COFF symbol section number. */
-
-asection *
-coff_section_from_bfd_index (abfd, index)
- bfd *abfd;
- int index;
-{
- struct sec *answer = abfd->sections;
-
- if (index == N_ABS)
- return bfd_abs_section_ptr;
- if (index == N_UNDEF)
- return bfd_und_section_ptr;
- if (index == N_DEBUG)
- return bfd_abs_section_ptr;
-
- while (answer)
- {
- if (answer->target_index == index)
- return answer;
- answer = answer->next;
- }
-
- /* We should not reach this point, but the SCO 3.2v4 /lib/libc_s.a
- has a bad symbol table in biglitpow.o. */
- return bfd_und_section_ptr;
-}
-
-/* Get the upper bound of a COFF symbol table. */
-
-long
-coff_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- if (!bfd_coff_slurp_symbol_table (abfd))
- return -1;
-
- return (bfd_get_symcount (abfd) + 1) * (sizeof (coff_symbol_type *));
-}
-
-
-/* Canonicalize a COFF symbol table. */
-
-long
-coff_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- unsigned int counter;
- coff_symbol_type *symbase;
- coff_symbol_type **location = (coff_symbol_type **) alocation;
-
- if (!bfd_coff_slurp_symbol_table (abfd))
- return -1;
-
- symbase = obj_symbols (abfd);
- counter = bfd_get_symcount (abfd);
- while (counter-- > 0)
- *location++ = symbase++;
-
- *location = NULL;
-
- return bfd_get_symcount (abfd);
-}
-
-/* Get the name of a symbol. The caller must pass in a buffer of size
- >= SYMNMLEN + 1. */
-
-const char *
-_bfd_coff_internal_syment_name (abfd, sym, buf)
- bfd *abfd;
- const struct internal_syment *sym;
- char *buf;
-{
- /* FIXME: It's not clear this will work correctly if sizeof
- (_n_zeroes) != 4. */
- if (sym->_n._n_n._n_zeroes != 0
- || sym->_n._n_n._n_offset == 0)
- {
- memcpy (buf, sym->_n._n_name, SYMNMLEN);
- buf[SYMNMLEN] = '\0';
- return buf;
- }
- else
- {
- const char *strings;
-
- BFD_ASSERT (sym->_n._n_n._n_offset >= STRING_SIZE_SIZE);
- strings = obj_coff_strings (abfd);
- if (strings == NULL)
- {
- strings = _bfd_coff_read_string_table (abfd);
- if (strings == NULL)
- return NULL;
- }
- return strings + sym->_n._n_n._n_offset;
- }
-}
-
-/* Read in and swap the relocs. This returns a buffer holding the
- relocs for section SEC in file ABFD. If CACHE is true and
- INTERNAL_RELOCS is NULL, the relocs read in will be saved in case
- the function is called again. If EXTERNAL_RELOCS is not NULL, it
- is a buffer large enough to hold the unswapped relocs. If
- INTERNAL_RELOCS is not NULL, it is a buffer large enough to hold
- the swapped relocs. If REQUIRE_INTERNAL is true, then the return
- value must be INTERNAL_RELOCS. The function returns NULL on error. */
-
-struct internal_reloc *
-_bfd_coff_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;
-{
- bfd_size_type relsz;
- bfd_byte *free_external = NULL;
- struct internal_reloc *free_internal = NULL;
- bfd_byte *erel;
- bfd_byte *erel_end;
- struct internal_reloc *irel;
-
- if (coff_section_data (abfd, sec) != NULL
- && coff_section_data (abfd, sec)->relocs != NULL)
- {
- if (! require_internal)
- return coff_section_data (abfd, sec)->relocs;
- memcpy (internal_relocs, coff_section_data (abfd, sec)->relocs,
- sec->reloc_count * sizeof (struct internal_reloc));
- return internal_relocs;
- }
-
- relsz = bfd_coff_relsz (abfd);
-
- if (external_relocs == NULL)
- {
- free_external = (bfd_byte *) bfd_malloc (sec->reloc_count * relsz);
- if (free_external == NULL && sec->reloc_count > 0)
- goto error_return;
- external_relocs = free_external;
- }
-
- if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
- || (bfd_read (external_relocs, relsz, sec->reloc_count, abfd)
- != relsz * sec->reloc_count))
- goto error_return;
-
- if (internal_relocs == NULL)
- {
- free_internal = ((struct internal_reloc *)
- bfd_malloc (sec->reloc_count
- * sizeof (struct internal_reloc)));
- if (free_internal == NULL && sec->reloc_count > 0)
- goto error_return;
- internal_relocs = free_internal;
- }
-
- /* Swap in the relocs. */
- erel = external_relocs;
- erel_end = erel + relsz * sec->reloc_count;
- irel = internal_relocs;
- for (; erel < erel_end; erel += relsz, irel++)
- bfd_coff_swap_reloc_in (abfd, (PTR) erel, (PTR) irel);
-
- if (free_external != NULL)
- {
- free (free_external);
- free_external = NULL;
- }
-
- if (cache && free_internal != NULL)
- {
- 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)->contents = NULL;
- }
- coff_section_data (abfd, sec)->relocs = free_internal;
- }
-
- return internal_relocs;
-
- error_return:
- if (free_external != NULL)
- free (free_external);
- if (free_internal != NULL)
- free (free_internal);
- return NULL;
-}
-
-/* Set lineno_count for the output sections of a COFF file. */
-
-int
-coff_count_linenumbers (abfd)
- bfd *abfd;
-{
- unsigned int limit = bfd_get_symcount (abfd);
- unsigned int i;
- int total = 0;
- asymbol **p;
- asection *s;
-
- if (limit == 0)
- {
- /* This may be from the backend linker, in which case the
- lineno_count in the sections is correct. */
- for (s = abfd->sections; s != NULL; s = s->next)
- total += s->lineno_count;
- return total;
- }
-
- for (s = abfd->sections; s != NULL; s = s->next)
- BFD_ASSERT (s->lineno_count == 0);
-
- for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
- {
- asymbol *q_maybe = *p;
-
- if (bfd_asymbol_flavour (q_maybe) == bfd_target_coff_flavour)
- {
- coff_symbol_type *q = coffsymbol (q_maybe);
-
- /* The AIX 4.1 compiler can sometimes generate line numbers
- attached to debugging symbols. We try to simply ignore
- those here. */
- if (q->lineno != NULL
- && q->symbol.section->owner != NULL)
- {
- /* This symbol has line numbers. Increment the owning
- section's linenumber count. */
- alent *l = q->lineno;
-
- ++q->symbol.section->output_section->lineno_count;
- ++total;
- ++l;
- while (l->line_number != 0)
- {
- ++total;
- ++q->symbol.section->output_section->lineno_count;
- ++l;
- }
- }
- }
- }
-
- return total;
-}
-
-/* Takes a bfd and a symbol, returns a pointer to the coff specific
- area of the symbol if there is one. */
-
-/*ARGSUSED*/
-coff_symbol_type *
-coff_symbol_from (ignore_abfd, symbol)
- bfd *ignore_abfd;
- asymbol *symbol;
-{
- if (bfd_asymbol_flavour (symbol) != bfd_target_coff_flavour)
- return (coff_symbol_type *) NULL;
-
- if (bfd_asymbol_bfd (symbol)->tdata.coff_obj_data == (coff_data_type *) NULL)
- return (coff_symbol_type *) NULL;
-
- return (coff_symbol_type *) symbol;
-}
-
-static void
-fixup_symbol_value (coff_symbol_ptr, syment)
- coff_symbol_type *coff_symbol_ptr;
- struct internal_syment *syment;
-{
-
- /* Normalize the symbol flags */
- if (bfd_is_com_section (coff_symbol_ptr->symbol.section))
- {
- /* a common symbol is undefined with a value */
- syment->n_scnum = N_UNDEF;
- syment->n_value = coff_symbol_ptr->symbol.value;
- }
- else if (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING)
- {
- syment->n_value = coff_symbol_ptr->symbol.value;
- }
- else if (bfd_is_und_section (coff_symbol_ptr->symbol.section))
- {
- syment->n_scnum = N_UNDEF;
- syment->n_value = 0;
- }
- else
- {
- if (coff_symbol_ptr->symbol.section)
- {
- syment->n_scnum =
- coff_symbol_ptr->symbol.section->output_section->target_index;
-
- syment->n_value =
- coff_symbol_ptr->symbol.value +
- coff_symbol_ptr->symbol.section->output_offset +
- coff_symbol_ptr->symbol.section->output_section->vma;
- }
- else
- {
- BFD_ASSERT (0);
- /* This can happen, but I don't know why yet (steve@cygnus.com) */
- syment->n_scnum = N_ABS;
- syment->n_value = coff_symbol_ptr->symbol.value;
- }
- }
-}
-
-/* Run through all the symbols in the symbol table and work out what
- their indexes into the symbol table will be when output.
-
- Coff requires that each C_FILE symbol points to the next one in the
- chain, and that the last one points to the first external symbol. We
- do that here too. */
-
-boolean
-coff_renumber_symbols (bfd_ptr, first_undef)
- bfd *bfd_ptr;
- int *first_undef;
-{
- unsigned int symbol_count = bfd_get_symcount (bfd_ptr);
- asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
- unsigned int native_index = 0;
- struct internal_syment *last_file = (struct internal_syment *) NULL;
- unsigned int symbol_index;
-
- /* COFF demands that undefined symbols come after all other symbols.
- Since we don't need to impose this extra knowledge on all our
- client programs, deal with that here. Sort the symbol table;
- just move the undefined symbols to the end, leaving the rest
- alone. The O'Reilly book says that defined global symbols come
- at the end before the undefined symbols, so we do that here as
- well. */
- /* @@ Do we have some condition we could test for, so we don't always
- have to do this? I don't think relocatability is quite right, but
- I'm not certain. [raeburn:19920508.1711EST] */
- {
- asymbol **newsyms;
- unsigned int i;
-
- newsyms = (asymbol **) bfd_alloc_by_size_t (bfd_ptr,
- sizeof (asymbol *)
- * (symbol_count + 1));
- if (!newsyms)
- return false;
- bfd_ptr->outsymbols = newsyms;
- for (i = 0; i < symbol_count; i++)
- if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) != 0
- || (!bfd_is_und_section (symbol_ptr_ptr[i]->section)
- && !bfd_is_com_section (symbol_ptr_ptr[i]->section)
- && ((symbol_ptr_ptr[i]->flags & (BSF_GLOBAL | BSF_FUNCTION))
- != BSF_GLOBAL)))
- *newsyms++ = symbol_ptr_ptr[i];
-
- for (i = 0; i < symbol_count; i++)
- if (!bfd_is_und_section (symbol_ptr_ptr[i]->section)
- && (bfd_is_com_section (symbol_ptr_ptr[i]->section)
- || ((symbol_ptr_ptr[i]->flags & (BSF_GLOBAL
- | BSF_NOT_AT_END
- | BSF_FUNCTION))
- == BSF_GLOBAL)))
- *newsyms++ = symbol_ptr_ptr[i];
-
- *first_undef = newsyms - bfd_ptr->outsymbols;
-
- for (i = 0; i < symbol_count; i++)
- if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) == 0
- && bfd_is_und_section (symbol_ptr_ptr[i]->section))
- *newsyms++ = symbol_ptr_ptr[i];
- *newsyms = (asymbol *) NULL;
- symbol_ptr_ptr = bfd_ptr->outsymbols;
- }
-
- for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
- {
- coff_symbol_type *coff_symbol_ptr = coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
- symbol_ptr_ptr[symbol_index]->udata.i = symbol_index;
- if (coff_symbol_ptr && coff_symbol_ptr->native)
- {
- combined_entry_type *s = coff_symbol_ptr->native;
- int i;
-
- if (s->u.syment.n_sclass == C_FILE)
- {
- if (last_file != (struct internal_syment *) NULL)
- last_file->n_value = native_index;
- last_file = &(s->u.syment);
- }
- else
- {
-
- /* Modify the symbol values according to their section and
- type */
-
- fixup_symbol_value (coff_symbol_ptr, &(s->u.syment));
- }
- for (i = 0; i < s->u.syment.n_numaux + 1; i++)
- s[i].offset = native_index++;
- }
- else
- {
- native_index++;
- }
- }
- obj_conv_table_size (bfd_ptr) = native_index;
-
- return true;
-}
-
-/* Run thorough the symbol table again, and fix it so that all
- pointers to entries are changed to the entries' index in the output
- symbol table. */
-
-void
-coff_mangle_symbols (bfd_ptr)
- bfd *bfd_ptr;
-{
- unsigned int symbol_count = bfd_get_symcount (bfd_ptr);
- asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
- unsigned int symbol_index;
-
- for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
- {
- coff_symbol_type *coff_symbol_ptr =
- coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
-
- if (coff_symbol_ptr && coff_symbol_ptr->native)
- {
- int i;
- combined_entry_type *s = coff_symbol_ptr->native;
-
- if (s->fix_value)
- {
- /* FIXME: We should use a union here. */
- s->u.syment.n_value =
- ((combined_entry_type *) s->u.syment.n_value)->offset;
- s->fix_value = 0;
- }
- if (s->fix_line)
- {
- /* The value is the offset into the line number entries
- for the symbol's section. On output, the symbol's
- section should be N_DEBUG. */
- s->u.syment.n_value =
- (coff_symbol_ptr->symbol.section->output_section->line_filepos
- + s->u.syment.n_value * bfd_coff_linesz (bfd_ptr));
- coff_symbol_ptr->symbol.section =
- coff_section_from_bfd_index (bfd_ptr, N_DEBUG);
- BFD_ASSERT (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING);
- }
- for (i = 0; i < s->u.syment.n_numaux; i++)
- {
- combined_entry_type *a = s + i + 1;
- if (a->fix_tag)
- {
- a->u.auxent.x_sym.x_tagndx.l =
- a->u.auxent.x_sym.x_tagndx.p->offset;
- a->fix_tag = 0;
- }
- if (a->fix_end)
- {
- a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l =
- a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p->offset;
- a->fix_end = 0;
- }
- if (a->fix_scnlen)
- {
- a->u.auxent.x_csect.x_scnlen.l =
- a->u.auxent.x_csect.x_scnlen.p->offset;
- a->fix_scnlen = 0;
- }
- }
- }
- }
-}
-
-static void
-coff_fix_symbol_name (abfd, symbol, native, string_size_p,
- debug_string_section_p, debug_string_size_p)
- bfd *abfd;
- asymbol *symbol;
- combined_entry_type *native;
- bfd_size_type *string_size_p;
- asection **debug_string_section_p;
- bfd_size_type *debug_string_size_p;
-{
- unsigned int name_length;
- union internal_auxent *auxent;
- char *name = (char *) (symbol->name);
-
- if (name == (char *) NULL)
- {
- /* coff symbols always have names, so we'll make one up */
- symbol->name = "strange";
- name = (char *) symbol->name;
- }
- name_length = strlen (name);
-
- if (native->u.syment.n_sclass == C_FILE
- && native->u.syment.n_numaux > 0)
- {
- strncpy (native->u.syment._n._n_name, ".file", SYMNMLEN);
- auxent = &(native + 1)->u.auxent;
-
- if (bfd_coff_long_filenames (abfd))
- {
- if (name_length <= FILNMLEN)
- {
- strncpy (auxent->x_file.x_fname, name, FILNMLEN);
- }
- else
- {
- auxent->x_file.x_n.x_offset = *string_size_p + STRING_SIZE_SIZE;
- auxent->x_file.x_n.x_zeroes = 0;
- *string_size_p += name_length + 1;
- }
- }
- else
- {
- strncpy (auxent->x_file.x_fname, name, FILNMLEN);
- if (name_length > FILNMLEN)
- {
- name[FILNMLEN] = '\0';
- }
- }
- }
- else
- {
- if (name_length <= SYMNMLEN)
- {
- /* This name will fit into the symbol neatly */
- strncpy (native->u.syment._n._n_name, symbol->name, SYMNMLEN);
- }
- else if (!bfd_coff_symname_in_debug (abfd, &native->u.syment))
- {
- native->u.syment._n._n_n._n_offset = (*string_size_p
- + STRING_SIZE_SIZE);
- native->u.syment._n._n_n._n_zeroes = 0;
- *string_size_p += name_length + 1;
- }
- else
- {
- long filepos;
- bfd_byte buf[2];
-
- /* This name should be written into the .debug section. For
- some reason each name is preceded by a two byte length
- and also followed by a null byte. FIXME: We assume that
- the .debug section has already been created, and that it
- is large enough. */
- if (*debug_string_section_p == (asection *) NULL)
- *debug_string_section_p = bfd_get_section_by_name (abfd, ".debug");
- filepos = bfd_tell (abfd);
- bfd_put_16 (abfd, name_length + 1, buf);
- if (!bfd_set_section_contents (abfd,
- *debug_string_section_p,
- (PTR) buf,
- (file_ptr) *debug_string_size_p,
- (bfd_size_type) 2)
- || !bfd_set_section_contents (abfd,
- *debug_string_section_p,
- (PTR) symbol->name,
- ((file_ptr) *debug_string_size_p
- + 2),
- (bfd_size_type) name_length + 1))
- abort ();
- if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
- abort ();
- native->u.syment._n._n_n._n_offset = *debug_string_size_p + 2;
- native->u.syment._n._n_n._n_zeroes = 0;
- *debug_string_size_p += name_length + 3;
- }
- }
-}
-
-/* We need to keep track of the symbol index so that when we write out
- the relocs we can get the index for a symbol. This method is a
- hack. FIXME. */
-
-#define set_index(symbol, idx) ((symbol)->udata.i = (idx))
-
-/* Write a symbol out to a COFF file. */
-
-static boolean
-coff_write_symbol (abfd, symbol, native, written, string_size_p,
- debug_string_section_p, debug_string_size_p)
- bfd *abfd;
- asymbol *symbol;
- combined_entry_type *native;
- unsigned int *written;
- bfd_size_type *string_size_p;
- asection **debug_string_section_p;
- bfd_size_type *debug_string_size_p;
-{
- unsigned int numaux = native->u.syment.n_numaux;
- int type = native->u.syment.n_type;
- int class = native->u.syment.n_sclass;
- PTR buf;
- bfd_size_type symesz;
-
- if (native->u.syment.n_sclass == C_FILE)
- symbol->flags |= BSF_DEBUGGING;
-
- if (symbol->flags & BSF_DEBUGGING
- && bfd_is_abs_section (symbol->section))
- {
- native->u.syment.n_scnum = N_DEBUG;
- }
- else if (bfd_is_abs_section (symbol->section))
- {
- native->u.syment.n_scnum = N_ABS;
- }
- else if (bfd_is_und_section (symbol->section))
- {
- native->u.syment.n_scnum = N_UNDEF;
- }
- else
- {
- native->u.syment.n_scnum =
- symbol->section->output_section->target_index;
- }
-
- coff_fix_symbol_name (abfd, symbol, native, string_size_p,
- debug_string_section_p, debug_string_size_p);
-
- symesz = bfd_coff_symesz (abfd);
- buf = bfd_alloc (abfd, symesz);
- if (!buf)
- return false;
- bfd_coff_swap_sym_out (abfd, &native->u.syment, buf);
- if (bfd_write (buf, 1, symesz, abfd) != symesz)
- return false;
- bfd_release (abfd, buf);
-
- if (native->u.syment.n_numaux > 0)
- {
- bfd_size_type auxesz;
- unsigned int j;
-
- auxesz = bfd_coff_auxesz (abfd);
- buf = bfd_alloc (abfd, auxesz);
- if (!buf)
- return false;
- for (j = 0; j < native->u.syment.n_numaux; j++)
- {
- bfd_coff_swap_aux_out (abfd,
- &((native + j + 1)->u.auxent),
- type,
- class,
- j,
- native->u.syment.n_numaux,
- buf);
- if (bfd_write (buf, 1, auxesz, abfd) != auxesz)
- return false;
- }
- bfd_release (abfd, buf);
- }
-
- /* Store the index for use when we write out the relocs. */
- set_index (symbol, *written);
-
- *written += numaux + 1;
- return true;
-}
-
-/* Write out a symbol to a COFF file that does not come from a COFF
- file originally. This symbol may have been created by the linker,
- or we may be linking a non COFF file to a COFF file. */
-
-static boolean
-coff_write_alien_symbol (abfd, symbol, written, string_size_p,
- debug_string_section_p, debug_string_size_p)
- bfd *abfd;
- asymbol *symbol;
- unsigned int *written;
- bfd_size_type *string_size_p;
- asection **debug_string_section_p;
- bfd_size_type *debug_string_size_p;
-{
- combined_entry_type *native;
- combined_entry_type dummy;
-
- native = &dummy;
- native->u.syment.n_type = T_NULL;
- native->u.syment.n_flags = 0;
- if (bfd_is_und_section (symbol->section))
- {
- native->u.syment.n_scnum = N_UNDEF;
- native->u.syment.n_value = symbol->value;
- }
- else if (bfd_is_com_section (symbol->section))
- {
- native->u.syment.n_scnum = N_UNDEF;
- native->u.syment.n_value = symbol->value;
- }
- else if (symbol->flags & BSF_DEBUGGING)
- {
- /* There isn't much point to writing out a debugging symbol
- unless we are prepared to convert it into COFF debugging
- format. So, we just ignore them. We must clobber the symbol
- name to keep it from being put in the string table. */
- symbol->name = "";
- return true;
- }
- else
- {
- native->u.syment.n_scnum =
- symbol->section->output_section->target_index;
- native->u.syment.n_value = (symbol->value
- + symbol->section->output_section->vma
- + symbol->section->output_offset);
-
- /* Copy the any flags from the the file header into the symbol.
- FIXME: Why? */
- {
- coff_symbol_type *c = coff_symbol_from (abfd, symbol);
- if (c != (coff_symbol_type *) NULL)
- native->u.syment.n_flags = bfd_asymbol_bfd (&c->symbol)->flags;
- }
- }
-
- native->u.syment.n_type = 0;
- if (symbol->flags & BSF_LOCAL)
- native->u.syment.n_sclass = C_STAT;
- else
- native->u.syment.n_sclass = C_EXT;
- native->u.syment.n_numaux = 0;
-
- return coff_write_symbol (abfd, symbol, native, written, string_size_p,
- debug_string_section_p, debug_string_size_p);
-}
-
-/* Write a native symbol to a COFF file. */
-
-static boolean
-coff_write_native_symbol (abfd, symbol, written, string_size_p,
- debug_string_section_p, debug_string_size_p)
- bfd *abfd;
- coff_symbol_type *symbol;
- unsigned int *written;
- bfd_size_type *string_size_p;
- asection **debug_string_section_p;
- bfd_size_type *debug_string_size_p;
-{
- combined_entry_type *native = symbol->native;
- alent *lineno = symbol->lineno;
-
- /* If this symbol has an associated line number, we must store the
- symbol index in the line number field. We also tag the auxent to
- point to the right place in the lineno table. */
- if (lineno && !symbol->done_lineno && symbol->symbol.section->owner != NULL)
- {
- unsigned int count = 0;
- lineno[count].u.offset = *written;
- if (native->u.syment.n_numaux)
- {
- union internal_auxent *a = &((native + 1)->u.auxent);
-
- a->x_sym.x_fcnary.x_fcn.x_lnnoptr =
- symbol->symbol.section->output_section->moving_line_filepos;
- }
-
- /* Count and relocate all other linenumbers. */
- count++;
- while (lineno[count].line_number != 0)
- {
-#if 0
- /* 13 april 92. sac
- I've been told this, but still need proof:
- > The second bug is also in `bfd/coffcode.h'. This bug
- > causes the linker to screw up the pc-relocations for
- > all the line numbers in COFF code. This bug isn't only
- > specific to A29K implementations, but affects all
- > systems using COFF format binaries. Note that in COFF
- > object files, the line number core offsets output by
- > the assembler are relative to the start of each
- > procedure, not to the start of the .text section. This
- > patch relocates the line numbers relative to the
- > `native->u.syment.n_value' instead of the section
- > virtual address.
- > modular!olson@cs.arizona.edu (Jon Olson)
- */
- lineno[count].u.offset += native->u.syment.n_value;
-#else
- lineno[count].u.offset +=
- (symbol->symbol.section->output_section->vma
- + symbol->symbol.section->output_offset);
-#endif
- count++;
- }
- symbol->done_lineno = true;
-
- symbol->symbol.section->output_section->moving_line_filepos +=
- count * bfd_coff_linesz (abfd);
- }
-
- return coff_write_symbol (abfd, &(symbol->symbol), native, written,
- string_size_p, debug_string_section_p,
- debug_string_size_p);
-}
-
-/* Write out the COFF symbols. */
-
-boolean
-coff_write_symbols (abfd)
- bfd *abfd;
-{
- bfd_size_type string_size;
- asection *debug_string_section;
- bfd_size_type debug_string_size;
- unsigned int i;
- unsigned int limit = bfd_get_symcount (abfd);
- unsigned int written = 0;
- asymbol **p;
-
- string_size = 0;
- debug_string_section = NULL;
- debug_string_size = 0;
-
- /* Seek to the right place */
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
- return false;
-
- /* Output all the symbols we have */
-
- written = 0;
- for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
- {
- asymbol *symbol = *p;
- coff_symbol_type *c_symbol = coff_symbol_from (abfd, symbol);
-
- if (c_symbol == (coff_symbol_type *) NULL
- || c_symbol->native == (combined_entry_type *) NULL)
- {
- if (!coff_write_alien_symbol (abfd, symbol, &written, &string_size,
- &debug_string_section,
- &debug_string_size))
- return false;
- }
- else
- {
- if (!coff_write_native_symbol (abfd, c_symbol, &written,
- &string_size, &debug_string_section,
- &debug_string_size))
- return false;
- }
- }
-
- obj_raw_syment_count (abfd) = written;
-
- /* Now write out strings */
-
- if (string_size != 0)
- {
- unsigned int size = string_size + STRING_SIZE_SIZE;
- bfd_byte buffer[STRING_SIZE_SIZE];
-
-#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd, size, buffer);
-#else
- #error Change bfd_h_put_32
-#endif
- if (bfd_write ((PTR) buffer, 1, sizeof (buffer), abfd) != sizeof (buffer))
- return false;
- for (p = abfd->outsymbols, i = 0;
- i < limit;
- i++, p++)
- {
- asymbol *q = *p;
- size_t name_length = strlen (q->name);
- coff_symbol_type *c_symbol = coff_symbol_from (abfd, q);
- size_t maxlen;
-
- /* Figure out whether the symbol name should go in the string
- table. Symbol names that are short enough are stored
- directly in the syment structure. File names permit a
- different, longer, length in the syment structure. On
- XCOFF, some symbol names are stored in the .debug section
- rather than in the string table. */
-
- if (c_symbol == NULL
- || c_symbol->native == NULL)
- {
- /* This is not a COFF symbol, so it certainly is not a
- file name, nor does it go in the .debug section. */
- maxlen = SYMNMLEN;
- }
- else if (bfd_coff_symname_in_debug (abfd,
- &c_symbol->native->u.syment))
- {
- /* This symbol name is in the XCOFF .debug section.
- Don't write it into the string table. */
- maxlen = name_length;
- }
- else if (c_symbol->native->u.syment.n_sclass == C_FILE
- && c_symbol->native->u.syment.n_numaux > 0)
- maxlen = FILNMLEN;
- else
- maxlen = SYMNMLEN;
-
- if (name_length > maxlen)
- {
- if (bfd_write ((PTR) (q->name), 1, name_length + 1, abfd)
- != name_length + 1)
- return false;
- }
- }
- }
- else
- {
- /* We would normally not write anything here, but we'll write
- out 4 so that any stupid coff reader which tries to read the
- string table even when there isn't one won't croak. */
- unsigned int size = STRING_SIZE_SIZE;
- bfd_byte buffer[STRING_SIZE_SIZE];
-
-#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd, size, buffer);
-#else
- #error Change bfd_h_put_32
-#endif
- if (bfd_write ((PTR) buffer, 1, STRING_SIZE_SIZE, abfd)
- != STRING_SIZE_SIZE)
- return false;
- }
-
- /* Make sure the .debug section was created to be the correct size.
- We should create it ourselves on the fly, but we don't because
- BFD won't let us write to any section until we know how large all
- the sections are. We could still do it by making another pass
- over the symbols. FIXME. */
- BFD_ASSERT (debug_string_size == 0
- || (debug_string_section != (asection *) NULL
- && (BFD_ALIGN (debug_string_size,
- 1 << debug_string_section->alignment_power)
- == bfd_section_size (abfd, debug_string_section))));
-
- return true;
-}
-
-boolean
-coff_write_linenumbers (abfd)
- bfd *abfd;
-{
- asection *s;
- bfd_size_type linesz;
- PTR buff;
-
- linesz = bfd_coff_linesz (abfd);
- buff = bfd_alloc (abfd, linesz);
- if (!buff)
- return false;
- for (s = abfd->sections; s != (asection *) NULL; s = s->next)
- {
- if (s->lineno_count)
- {
- asymbol **q = abfd->outsymbols;
- if (bfd_seek (abfd, s->line_filepos, SEEK_SET) != 0)
- return false;
- /* Find all the linenumbers in this section */
- while (*q)
- {
- asymbol *p = *q;
- if (p->section->output_section == s)
- {
- alent *l =
- BFD_SEND (bfd_asymbol_bfd (p), _get_lineno,
- (bfd_asymbol_bfd (p), p));
- if (l)
- {
- /* Found a linenumber entry, output */
- struct internal_lineno out;
- memset ((PTR) & out, 0, sizeof (out));
- out.l_lnno = 0;
- out.l_addr.l_symndx = l->u.offset;
- bfd_coff_swap_lineno_out (abfd, &out, buff);
- if (bfd_write (buff, 1, linesz, abfd) != linesz)
- return false;
- l++;
- while (l->line_number)
- {
- out.l_lnno = l->line_number;
- out.l_addr.l_symndx = l->u.offset;
- bfd_coff_swap_lineno_out (abfd, &out, buff);
- if (bfd_write (buff, 1, linesz, abfd) != linesz)
- return false;
- l++;
- }
- }
- }
- q++;
- }
- }
- }
- bfd_release (abfd, buff);
- return true;
-}
-
-/*ARGSUSED */
-alent *
-coff_get_lineno (ignore_abfd, symbol)
- bfd *ignore_abfd;
- asymbol *symbol;
-{
- return coffsymbol (symbol)->lineno;
-}
-
-#if 0
-
-/* This is only called from coff_add_missing_symbols, which has been
- disabled. */
-
-asymbol *
-coff_section_symbol (abfd, name)
- bfd *abfd;
- char *name;
-{
- asection *sec = bfd_make_section_old_way (abfd, name);
- asymbol *sym;
- combined_entry_type *csym;
-
- sym = sec->symbol;
- csym = coff_symbol_from (abfd, sym)->native;
- /* Make sure back-end COFF stuff is there. */
- if (csym == 0)
- {
- struct foo
- {
- coff_symbol_type sym;
- /* @@FIXME This shouldn't use a fixed size!! */
- combined_entry_type e[10];
- };
- struct foo *f;
- f = (struct foo *) bfd_alloc_by_size_t (abfd, sizeof (*f));
- if (!f)
- {
- bfd_set_error (bfd_error_no_error);
- return NULL;
- }
- memset ((char *) f, 0, sizeof (*f));
- coff_symbol_from (abfd, sym)->native = csym = f->e;
- }
- csym[0].u.syment.n_sclass = C_STAT;
- csym[0].u.syment.n_numaux = 1;
-/* SF_SET_STATICS (sym); @@ ??? */
- csym[1].u.auxent.x_scn.x_scnlen = sec->_raw_size;
- csym[1].u.auxent.x_scn.x_nreloc = sec->reloc_count;
- csym[1].u.auxent.x_scn.x_nlinno = sec->lineno_count;
-
- if (sec->output_section == NULL)
- {
- sec->output_section = sec;
- sec->output_offset = 0;
- }
-
- return sym;
-}
-
-#endif /* 0 */
-
-/* This function transforms the offsets into the symbol table into
- pointers to syments. */
-
-static void
-coff_pointerize_aux (abfd, table_base, symbol, indaux, auxent)
- bfd *abfd;
- combined_entry_type *table_base;
- combined_entry_type *symbol;
- unsigned int indaux;
- combined_entry_type *auxent;
-{
- int type = symbol->u.syment.n_type;
- int class = symbol->u.syment.n_sclass;
-
- if (coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook)
- {
- if ((*coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook)
- (abfd, table_base, symbol, indaux, auxent))
- return;
- }
-
- /* Don't bother if this is a file or a section */
- if (class == C_STAT && type == T_NULL)
- return;
- if (class == C_FILE)
- return;
-
- /* Otherwise patch up */
-#define N_TMASK coff_data (abfd)->local_n_tmask
-#define N_BTSHFT coff_data (abfd)->local_n_btshft
- if ((ISFCN (type) || ISTAG (class) || class == C_BLOCK)
- && auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l > 0)
- {
- auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p =
- table_base + auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l;
- auxent->fix_end = 1;
- }
- /* A negative tagndx is meaningless, but the SCO 3.2v4 cc can
- generate one, so we must be careful to ignore it. */
- if (auxent->u.auxent.x_sym.x_tagndx.l > 0)
- {
- auxent->u.auxent.x_sym.x_tagndx.p =
- table_base + auxent->u.auxent.x_sym.x_tagndx.l;
- auxent->fix_tag = 1;
- }
-}
-
-/* Allocate space for the ".debug" section, and read it.
- We did not read the debug section until now, because
- we didn't want to go to the trouble until someone needed it. */
-
-static char *
-build_debug_section (abfd)
- bfd *abfd;
-{
- char *debug_section;
- long position;
-
- asection *sect = bfd_get_section_by_name (abfd, ".debug");
-
- if (!sect)
- {
- bfd_set_error (bfd_error_no_debug_section);
- return NULL;
- }
-
- debug_section = (PTR) bfd_alloc (abfd,
- bfd_get_section_size_before_reloc (sect));
- if (debug_section == NULL)
- return NULL;
-
- /* Seek to the beginning of the `.debug' section and read it.
- Save the current position first; it is needed by our caller.
- Then read debug section and reset the file pointer. */
-
- position = bfd_tell (abfd);
- if (bfd_seek (abfd, sect->filepos, SEEK_SET) != 0
- || (bfd_read (debug_section,
- bfd_get_section_size_before_reloc (sect), 1, abfd)
- != bfd_get_section_size_before_reloc (sect))
- || bfd_seek (abfd, position, SEEK_SET) != 0)
- return NULL;
- return debug_section;
-}
-
-
-/* Return a pointer to a malloc'd copy of 'name'. 'name' may not be
- \0-terminated, but will not exceed 'maxlen' characters. The copy *will*
- be \0-terminated. */
-static char *
-copy_name (abfd, name, maxlen)
- bfd *abfd;
- char *name;
- int maxlen;
-{
- int len;
- char *newname;
-
- for (len = 0; len < maxlen; ++len)
- {
- if (name[len] == '\0')
- {
- break;
- }
- }
-
- if ((newname = (PTR) bfd_alloc (abfd, len + 1)) == NULL)
- return (NULL);
- strncpy (newname, name, len);
- newname[len] = '\0';
- return newname;
-}
-
-/* Read in the external symbols. */
-
-boolean
-_bfd_coff_get_external_symbols (abfd)
- bfd *abfd;
-{
- bfd_size_type symesz;
- size_t size;
- PTR syms;
-
- if (obj_coff_external_syms (abfd) != NULL)
- return true;
-
- symesz = bfd_coff_symesz (abfd);
-
- size = obj_raw_syment_count (abfd) * symesz;
-
- syms = (PTR) bfd_malloc (size);
- if (syms == NULL && size != 0)
- return false;
-
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || bfd_read (syms, size, 1, abfd) != size)
- {
- if (syms != NULL)
- free (syms);
- return false;
- }
-
- obj_coff_external_syms (abfd) = syms;
-
- return true;
-}
-
-/* Read in the external strings. The strings are not loaded until
- they are needed. This is because we have no simple way of
- detecting a missing string table in an archive. */
-
-const char *
-_bfd_coff_read_string_table (abfd)
- bfd *abfd;
-{
- char extstrsize[STRING_SIZE_SIZE];
- size_t strsize;
- char *strings;
-
- if (obj_coff_strings (abfd) != NULL)
- return obj_coff_strings (abfd);
-
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd)),
- SEEK_SET) != 0)
- return NULL;
-
- if (bfd_read (extstrsize, sizeof extstrsize, 1, abfd) != sizeof extstrsize)
- {
- if (bfd_get_error () != bfd_error_file_truncated)
- return NULL;
-
- /* There is no string table. */
- strsize = STRING_SIZE_SIZE;
- }
- else
- {
-#if STRING_SIZE_SIZE == 4
- strsize = bfd_h_get_32 (abfd, (bfd_byte *) extstrsize);
-#else
- #error Change bfd_h_get_32
-#endif
- }
-
- if (strsize < STRING_SIZE_SIZE)
- {
- (*_bfd_error_handler)
- ("%s: bad string table size %lu", bfd_get_filename (abfd),
- (unsigned long) strsize);
- bfd_set_error (bfd_error_bad_value);
- return NULL;
- }
-
- strings = (char *) bfd_malloc (strsize);
- if (strings == NULL)
- return NULL;
-
- if (bfd_read (strings + STRING_SIZE_SIZE,
- strsize - STRING_SIZE_SIZE, 1, abfd)
- != strsize - STRING_SIZE_SIZE)
- {
- free (strings);
- return NULL;
- }
-
- obj_coff_strings (abfd) = strings;
-
- return strings;
-}
-
-/* Free up the external symbols and strings read from a COFF file. */
-
-boolean
-_bfd_coff_free_symbols (abfd)
- bfd *abfd;
-{
- if (obj_coff_external_syms (abfd) != NULL
- && ! obj_coff_keep_syms (abfd))
- {
- free (obj_coff_external_syms (abfd));
- obj_coff_external_syms (abfd) = NULL;
- }
- if (obj_coff_strings (abfd) != NULL
- && ! obj_coff_keep_strings (abfd))
- {
- free (obj_coff_strings (abfd));
- obj_coff_strings (abfd) = NULL;
- }
- return true;
-}
-
-/* Read a symbol table into freshly bfd_allocated memory, swap it, and
- knit the symbol names into a normalized form. By normalized here I
- mean that all symbols have an n_offset pointer that points to a null-
- terminated string. */
-
-combined_entry_type *
-coff_get_normalized_symtab (abfd)
- bfd *abfd;
-{
- combined_entry_type *internal;
- combined_entry_type *internal_ptr;
- combined_entry_type *symbol_ptr;
- combined_entry_type *internal_end;
- bfd_size_type symesz;
- char *raw_src;
- char *raw_end;
- const char *string_table = NULL;
- char *debug_section = NULL;
- unsigned long size;
-
- if (obj_raw_syments (abfd) != NULL)
- return obj_raw_syments (abfd);
-
- size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
- internal = (combined_entry_type *) bfd_zalloc (abfd, size);
- if (internal == NULL && size != 0)
- return NULL;
- internal_end = internal + obj_raw_syment_count (abfd);
-
- if (! _bfd_coff_get_external_symbols (abfd))
- return NULL;
-
- raw_src = (char *) obj_coff_external_syms (abfd);
-
- /* mark the end of the symbols */
- symesz = bfd_coff_symesz (abfd);
- raw_end = (char *) raw_src + obj_raw_syment_count (abfd) * symesz;
-
- /* FIXME SOMEDAY. A string table size of zero is very weird, but
- probably possible. If one shows up, it will probably kill us. */
-
- /* Swap all the raw entries */
- for (internal_ptr = internal;
- raw_src < raw_end;
- raw_src += symesz, internal_ptr++)
- {
-
- unsigned int i;
- bfd_coff_swap_sym_in (abfd, (PTR) raw_src,
- (PTR) & internal_ptr->u.syment);
- symbol_ptr = internal_ptr;
-
- for (i = 0;
- i < symbol_ptr->u.syment.n_numaux;
- i++)
- {
- internal_ptr++;
- raw_src += symesz;
- bfd_coff_swap_aux_in (abfd, (PTR) raw_src,
- symbol_ptr->u.syment.n_type,
- symbol_ptr->u.syment.n_sclass,
- i, symbol_ptr->u.syment.n_numaux,
- &(internal_ptr->u.auxent));
- coff_pointerize_aux (abfd, internal, symbol_ptr, i,
- internal_ptr);
- }
- }
-
- /* Free the raw symbols, but not the strings (if we have them). */
- obj_coff_keep_strings (abfd) = true;
- if (! _bfd_coff_free_symbols (abfd))
- return NULL;
-
- for (internal_ptr = internal; internal_ptr < internal_end;
- internal_ptr++)
- {
- if (internal_ptr->u.syment.n_sclass == C_FILE
- && internal_ptr->u.syment.n_numaux > 0)
- {
- /* make a file symbol point to the name in the auxent, since
- the text ".file" is redundant */
- if ((internal_ptr + 1)->u.auxent.x_file.x_n.x_zeroes == 0)
- {
- /* the filename is a long one, point into the string table */
- if (string_table == NULL)
- {
- string_table = _bfd_coff_read_string_table (abfd);
- if (string_table == NULL)
- return NULL;
- }
-
- internal_ptr->u.syment._n._n_n._n_offset =
- ((long)
- (string_table
- + (internal_ptr + 1)->u.auxent.x_file.x_n.x_offset));
- }
- else
- {
- /* ordinary short filename, put into memory anyway */
- internal_ptr->u.syment._n._n_n._n_offset = (long)
- copy_name (abfd, (internal_ptr + 1)->u.auxent.x_file.x_fname,
- FILNMLEN);
- }
- }
- else
- {
- if (internal_ptr->u.syment._n._n_n._n_zeroes != 0)
- {
- /* This is a "short" name. Make it long. */
- unsigned long i = 0;
- char *newstring = NULL;
-
- /* find the length of this string without walking into memory
- that isn't ours. */
- for (i = 0; i < 8; ++i)
- {
- if (internal_ptr->u.syment._n._n_name[i] == '\0')
- {
- break;
- } /* if end of string */
- } /* possible lengths of this string. */
-
- if ((newstring = (PTR) bfd_alloc (abfd, ++i)) == NULL)
- return (NULL);
- memset (newstring, 0, i);
- strncpy (newstring, internal_ptr->u.syment._n._n_name, i - 1);
- internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
- internal_ptr->u.syment._n._n_n._n_zeroes = 0;
- }
- else if (internal_ptr->u.syment._n._n_n._n_offset == 0)
- internal_ptr->u.syment._n._n_n._n_offset = (long int) "";
- else if (!bfd_coff_symname_in_debug (abfd, &internal_ptr->u.syment))
- {
- /* Long name already. Point symbol at the string in the
- table. */
- if (string_table == NULL)
- {
- string_table = _bfd_coff_read_string_table (abfd);
- if (string_table == NULL)
- return NULL;
- }
- internal_ptr->u.syment._n._n_n._n_offset =
- ((long int)
- (string_table
- + internal_ptr->u.syment._n._n_n._n_offset));
- }
- else
- {
- /* Long name in debug section. Very similar. */
- if (debug_section == NULL)
- debug_section = build_debug_section (abfd);
- internal_ptr->u.syment._n._n_n._n_offset = (long int)
- (debug_section + internal_ptr->u.syment._n._n_n._n_offset);
- }
- }
- internal_ptr += internal_ptr->u.syment.n_numaux;
- }
-
- obj_raw_syments (abfd) = internal;
- BFD_ASSERT (obj_raw_syment_count (abfd)
- == (unsigned int) (internal_ptr - internal));
-
- return (internal);
-} /* coff_get_normalized_symtab() */
-
-long
-coff_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;
- }
- return (asect->reloc_count + 1) * sizeof (arelent *);
-}
-
-asymbol *
-coff_make_empty_symbol (abfd)
- bfd *abfd;
-{
- coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
- if (new == NULL)
- return (NULL);
- memset (new, 0, sizeof *new);
- new->symbol.section = 0;
- new->native = 0;
- new->lineno = (alent *) NULL;
- new->done_lineno = false;
- new->symbol.the_bfd = abfd;
- return &new->symbol;
-}
-
-/* Make a debugging symbol. */
-
-asymbol *
-coff_bfd_make_debug_symbol (abfd, ptr, sz)
- bfd *abfd;
- PTR ptr;
- unsigned long sz;
-{
- coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
- if (new == NULL)
- return (NULL);
- /* @@ This shouldn't be using a constant multiplier. */
- new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
- if (!new->native)
- return (NULL);
- new->symbol.section = bfd_abs_section_ptr;
- new->symbol.flags = BSF_DEBUGGING;
- new->lineno = (alent *) NULL;
- new->done_lineno = false;
- new->symbol.the_bfd = abfd;
- return &new->symbol;
-}
-
-/*ARGSUSED */
-void
-coff_get_symbol_info (abfd, symbol, ret)
- bfd *abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
- if (coffsymbol (symbol)->native != NULL
- && coffsymbol (symbol)->native->fix_value)
- {
- combined_entry_type *psym;
-
- psym = ((combined_entry_type *)
- coffsymbol (symbol)->native->u.syment.n_value);
- ret->value = (bfd_vma) (psym - obj_raw_syments (abfd));
- }
-}
-
-/* Print out information about COFF symbol. */
-
-void
-coff_print_symbol (abfd, filep, symbol, how)
- bfd *abfd;
- PTR filep;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) filep;
-
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
-
- case bfd_print_symbol_more:
- fprintf (file, "coff %s %s",
- coffsymbol (symbol)->native ? "n" : "g",
- coffsymbol (symbol)->lineno ? "l" : " ");
- break;
-
- case bfd_print_symbol_all:
- if (coffsymbol (symbol)->native)
- {
- unsigned long val;
- unsigned int aux;
- combined_entry_type *combined = coffsymbol (symbol)->native;
- combined_entry_type *root = obj_raw_syments (abfd);
- struct lineno_cache_entry *l = coffsymbol (symbol)->lineno;
-
- fprintf (file, "[%3ld]", (long) (combined - root));
-
- if (! combined->fix_value)
- val = (unsigned long) combined->u.syment.n_value;
- else
- val = ((unsigned long)
- ((combined_entry_type *) combined->u.syment.n_value
- - root));
-
- fprintf (file,
- "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%08lx %s",
- combined->u.syment.n_scnum,
- combined->u.syment.n_flags,
- combined->u.syment.n_type,
- combined->u.syment.n_sclass,
- combined->u.syment.n_numaux,
- val,
- symbol->name);
-
- for (aux = 0; aux < combined->u.syment.n_numaux; aux++)
- {
- combined_entry_type *auxp = combined + aux + 1;
- long tagndx;
-
- if (auxp->fix_tag)
- tagndx = auxp->u.auxent.x_sym.x_tagndx.p - root;
- else
- tagndx = auxp->u.auxent.x_sym.x_tagndx.l;
-
- fprintf (file, "\n");
-
- if (bfd_coff_print_aux (abfd, file, root, combined, auxp, aux))
- continue;
-
- switch (combined->u.syment.n_sclass)
- {
- case C_FILE:
- fprintf (file, "File ");
- break;
-
- case C_STAT:
- if (combined->u.syment.n_type == T_NULL)
- /* probably a section symbol? */
- {
- fprintf (file, "AUX scnlen 0x%lx nreloc %d nlnno %d",
- (long) auxp->u.auxent.x_scn.x_scnlen,
- auxp->u.auxent.x_scn.x_nreloc,
- auxp->u.auxent.x_scn.x_nlinno);
- break;
- }
- /* else fall through */
-
- default:
- fprintf (file, "AUX lnno %d size 0x%x tagndx %ld",
- auxp->u.auxent.x_sym.x_misc.x_lnsz.x_lnno,
- auxp->u.auxent.x_sym.x_misc.x_lnsz.x_size,
- tagndx);
- if (auxp->fix_end)
- fprintf (file, " endndx %ld",
- ((long)
- (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p
- - root)));
- break;
- }
- }
-
- if (l)
- {
- fprintf (file, "\n%s :", l->u.sym->name);
- l++;
- while (l->line_number)
- {
- fprintf (file, "\n%4d : 0x%lx",
- l->line_number,
- ((unsigned long)
- (l->u.offset + symbol->section->vma)));
- l++;
- }
- }
- }
- else
- {
- bfd_print_symbol_vandf ((PTR) file, symbol);
- fprintf (file, " %-5s %s %s %s",
- symbol->section->name,
- coffsymbol (symbol)->native ? "n" : "g",
- coffsymbol (symbol)->lineno ? "l" : " ",
- symbol->name);
- }
- }
-}
-
-/* Provided a BFD, a section and an offset into the section, calculate
- and return the name of the source file and the line nearest to the
- wanted location. */
-
-/*ARGSUSED*/
-boolean
-coff_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;
-{
- boolean found;
- unsigned int i;
- unsigned int line_base;
- coff_data_type *cof = coff_data (abfd);
- /* Run through the raw syments if available */
- combined_entry_type *p;
- combined_entry_type *pend;
- alent *l;
- struct coff_section_tdata *sec_data;
-
- /* Before looking through the symbol table, try to use a .stab
- section to find the information. */
- if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
- &found, filename_ptr,
- functionname_ptr, line_ptr,
- &coff_data (abfd)->line_info))
- return false;
- if (found)
- return true;
-
- *filename_ptr = 0;
- *functionname_ptr = 0;
- *line_ptr = 0;
-
- /* Don't try and find line numbers in a non coff file */
- if (abfd->xvec->flavour != bfd_target_coff_flavour)
- return false;
-
- if (cof == NULL)
- return false;
-
- /* Find the first C_FILE symbol. */
- p = cof->raw_syments;
- pend = p + cof->raw_syment_count;
- while (p < pend)
- {
- if (p->u.syment.n_sclass == C_FILE)
- break;
- p += 1 + p->u.syment.n_numaux;
- }
-
- if (p < pend)
- {
- bfd_vma maxdiff;
-
- /* Look through the C_FILE symbols to find the best one. */
- *filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
- maxdiff = (bfd_vma) 0 - (bfd_vma) 1;
- while (1)
- {
- combined_entry_type *p2;
-
- for (p2 = p + 1 + p->u.syment.n_numaux;
- p2 < pend;
- p2 += 1 + p2->u.syment.n_numaux)
- {
- if (p2->u.syment.n_scnum > 0
- && (section
- == coff_section_from_bfd_index (abfd,
- p2->u.syment.n_scnum)))
- break;
- if (p2->u.syment.n_sclass == C_FILE)
- {
- p2 = pend;
- break;
- }
- }
-
- if (p2 < pend
- && offset >= (bfd_vma) p2->u.syment.n_value
- && offset - (bfd_vma) p2->u.syment.n_value < maxdiff)
- {
- *filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
- maxdiff = offset - p2->u.syment.n_value;
- }
-
- /* Avoid endless loops on erroneous files by ensuring that
- we always move forward in the file. */
- if (p - cof->raw_syments >= p->u.syment.n_value)
- break;
-
- p = cof->raw_syments + p->u.syment.n_value;
- if (p > pend || p->u.syment.n_sclass != C_FILE)
- break;
- }
- }
-
- /* Now wander though the raw linenumbers of the section */
- /* If we have been called on this section before, and the offset we
- want is further down then we can prime the lookup loop. */
- sec_data = coff_section_data (abfd, section);
- if (sec_data != NULL
- && sec_data->i > 0
- && offset >= sec_data->offset)
- {
- i = sec_data->i;
- *functionname_ptr = sec_data->function;
- line_base = sec_data->line_base;
- }
- else
- {
- i = 0;
- line_base = 0;
- }
-
- if (section->lineno != NULL)
- {
- l = &section->lineno[i];
-
- for (; i < section->lineno_count; i++)
- {
- if (l->line_number == 0)
- {
- /* Get the symbol this line number points at */
- coff_symbol_type *coff = (coff_symbol_type *) (l->u.sym);
- if (coff->symbol.value > offset)
- break;
- *functionname_ptr = coff->symbol.name;
- if (coff->native)
- {
- combined_entry_type *s = coff->native;
- s = s + 1 + s->u.syment.n_numaux;
-
- /* In XCOFF a debugging symbol can follow the
- function symbol. */
- if (s->u.syment.n_scnum == N_DEBUG)
- s = s + 1 + s->u.syment.n_numaux;
-
- /* S should now point to the .bf of the function. */
- if (s->u.syment.n_numaux)
- {
- /* The linenumber is stored in the auxent. */
- union internal_auxent *a = &((s + 1)->u.auxent);
- line_base = a->x_sym.x_misc.x_lnsz.x_lnno;
- *line_ptr = line_base;
- }
- }
- }
- else
- {
- if (l->u.offset + bfd_get_section_vma (abfd, section) > offset)
- break;
- *line_ptr = l->line_number + line_base - 1;
- }
- l++;
- }
- }
-
- /* Cache the results for the next call. */
- if (sec_data == NULL && section->owner == abfd)
- {
- section->used_by_bfd =
- ((PTR) bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata)));
- sec_data = (struct coff_section_tdata *) section->used_by_bfd;
- }
- if (sec_data != NULL)
- {
- sec_data->offset = offset;
- sec_data->i = i;
- sec_data->function = *functionname_ptr;
- sec_data->line_base = line_base;
- }
-
- return true;
-}
-
-int
-coff_sizeof_headers (abfd, reloc)
- bfd *abfd;
- boolean reloc;
-{
- size_t size;
-
- if (reloc == false)
- {
- size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
- }
- else
- {
- size = bfd_coff_filhsz (abfd);
- }
-
- size += abfd->section_count * bfd_coff_scnhsz (abfd);
- return size;
-}
diff --git a/contrib/gdb/bfd/cofflink.c b/contrib/gdb/bfd/cofflink.c
deleted file mode 100644
index c4a42a091478..000000000000
--- 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/coffswap.h b/contrib/gdb/bfd/coffswap.h
deleted file mode 100644
index ef1b6b3a913e..000000000000
--- a/contrib/gdb/bfd/coffswap.h
+++ /dev/null
@@ -1,807 +0,0 @@
-/* Generic COFF swapping routines, for BFD.
- Copyright 1990, 1991, 1992, 1993, 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. */
-
-/* This file contains routines used to swap COFF data. It is a header
- file because the details of swapping depend on the details of the
- structures used by each COFF implementation. This is included by
- coffcode.h, as well as by the ECOFF backend.
-
- Any file which uses this must first include "coff/internal.h" and
- "coff/CPU.h". The functions will then be correct for that CPU. */
-
-#ifndef IMAGE_BASE
-#define IMAGE_BASE 0
-#endif
-
-#define PUTWORD bfd_h_put_32
-#define PUTHALF bfd_h_put_16
-#define PUTBYTE bfd_h_put_8
-
-#ifndef GET_FCN_LNNOPTR
-#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
-#endif
-
-#ifndef GET_FCN_ENDNDX
-#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
-#endif
-
-#ifndef PUT_FCN_LNNOPTR
-#define PUT_FCN_LNNOPTR(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
-#endif
-#ifndef PUT_FCN_ENDNDX
-#define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
-#endif
-#ifndef GET_LNSZ_LNNO
-#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
-#endif
-#ifndef GET_LNSZ_SIZE
-#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
-#endif
-#ifndef PUT_LNSZ_LNNO
-#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
-#endif
-#ifndef PUT_LNSZ_SIZE
-#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
-#endif
-#ifndef GET_SCN_SCNLEN
-#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
-#endif
-#ifndef GET_SCN_NRELOC
-#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
-#endif
-#ifndef GET_SCN_NLINNO
-#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
-#endif
-#ifndef PUT_SCN_SCNLEN
-#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
-#endif
-#ifndef PUT_SCN_NRELOC
-#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
-#endif
-#ifndef PUT_SCN_NLINNO
-#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
-#endif
-#ifndef GET_LINENO_LNNO
-#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
-#endif
-#ifndef PUT_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
-
-#ifndef NO_COFF_RELOCS
-
-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);
-
-#ifdef RS6000COFF_C
- reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
- reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
-#else
- reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
-#endif
-
-#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);
-
-#ifdef RS6000COFF_C
- bfd_h_put_8 (abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type);
- bfd_h_put_8 (abfd, reloc_src->r_size, (bfd_byte *) reloc_dst->r_size);
-#else
- bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
- reloc_dst->r_type);
-#endif
-
-#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);
-}
-
-#endif /* NO_COFF_RELOCS */
-
-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_symptr =
- GET_FILEHDR_SYMPTR (abfd, (bfd_byte *) filehdr_src->f_symptr);
- filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
- filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
- filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
-}
-
-static unsigned int
-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);
-}
-
-
-#ifndef NO_COFF_SYMBOLS
-
-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);
-}
-
-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;
-
- /* RS/6000 "csect" auxents */
-#ifdef RS6000COFF_C
- case C_EXT:
- case C_HIDEXT:
- if (indx + 1 == numaux)
- {
- in->x_csect.x_scnlen.l = bfd_h_get_32 (abfd, ext->x_csect.x_scnlen);
- in->x_csect.x_parmhash = bfd_h_get_32 (abfd,
- ext->x_csect.x_parmhash);
- in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash);
- /* We don't have to hack bitfields in x_smtyp because it's
- defined by shifts-and-ands, which are equivalent on all
- byte orders. */
- in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp);
- in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas);
- in->x_csect.x_stab = bfd_h_get_32 (abfd, ext->x_csect.x_stab);
- in->x_csect.x_snstab = bfd_h_get_16 (abfd, ext->x_csect.x_snstab);
- return;
- }
- break;
-#endif
-
- case C_STAT:
-#ifdef C_LEAFSTAT
- case C_LEAFSTAT:
-#endif
- case C_HIDDEN:
- if (type == T_NULL) {
- in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
- in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
- in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
- 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) {
- PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
- PUTWORD(abfd,
- in->x_file.x_n.x_offset,
- (bfd_byte *) ext->x_file.x_n.x_offset);
- }
- else {
-#if FILNMLEN != E_FILNMLEN
- -> Error, we need to cope with truncating or extending FILNMLEN!;
-#else
- memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
-#endif
- }
- return sizeof (AUXENT);
-
-#ifdef RS6000COFF_C
- /* RS/6000 "csect" auxents */
- case C_EXT:
- case C_HIDEXT:
- if (indx + 1 == numaux)
- {
- PUTWORD (abfd, in->x_csect.x_scnlen.l, ext->x_csect.x_scnlen);
- PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
- PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
- /* We don't have to hack bitfields in x_smtyp because it's
- defined by shifts-and-ands, which are equivalent on all
- byte orders. */
- PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
- PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
- PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
- PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
- return sizeof (AUXENT);
- }
- break;
-#endif
-
- case C_STAT:
-#ifdef C_LEAFSTAT
- case C_LEAFSTAT:
-#endif
- case C_HIDDEN:
- if (type == T_NULL) {
- PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
- PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
- PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
- return sizeof (AUXENT);
- }
- break;
- }
-
- PUTWORD(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))
- PUTWORD (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);
-}
-
-#endif /* NO_COFF_SYMBOLS */
-
-#ifndef NO_COFF_LINENOS
-
-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;
- PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
- ext->l_addr.l_symndx);
-
- PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
- return sizeof(struct external_lineno);
-}
-
-#endif /* NO_COFF_LINENOS */
-
-
-static void
-coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
- bfd *abfd;
- PTR aouthdr_ext1;
- PTR aouthdr_int1;
-{
- AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
- struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
-
- aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
- aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
- aouthdr_int->tsize =
- 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);
-
-#ifdef I960
- aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
-#endif
-
-#ifdef APOLLO_M68
- bfd_h_put_32(abfd, aouthdr_int->o_inlib, (bfd_byte *) aouthdr_ext->o_inlib);
- bfd_h_put_32(abfd, aouthdr_int->o_sri, (bfd_byte *) aouthdr_ext->o_sri);
- bfd_h_put_32(abfd, aouthdr_int->vid[0], (bfd_byte *) aouthdr_ext->vid);
- bfd_h_put_32(abfd, aouthdr_int->vid[1], (bfd_byte *) aouthdr_ext->vid + 4);
-#endif
-
-
-#ifdef RS6000COFF_C
- aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
- aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
- aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
- aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
- aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
- aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
- aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
- aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
- aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
- aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
- aouthdr_int->o_cputype = bfd_h_get_16(abfd, aouthdr_ext->o_cputype);
- aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
- aouthdr_int->o_maxdata = bfd_h_get_32(abfd, aouthdr_ext->o_maxdata);
-#endif
-
-#ifdef MIPSECOFF
- aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start);
- aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value);
- aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
- aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]);
- aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]);
- aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]);
- aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]);
-#endif
-
-#ifdef ALPHAECOFF
- aouthdr_int->bss_start = bfd_h_get_64(abfd, aouthdr_ext->bss_start);
- aouthdr_int->gp_value = bfd_h_get_64(abfd, aouthdr_ext->gp_value);
- aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
- aouthdr_int->fprmask = bfd_h_get_32(abfd, aouthdr_ext->fprmask);
-#endif
-}
-
-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;
- AOUTHDR *aouthdr_out = (AOUTHDR *)out;
-
- bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
- bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
- PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
- PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
- PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
- PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
- PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
- (bfd_byte *) aouthdr_out->text_start);
- PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
- (bfd_byte *) aouthdr_out->data_start);
-
-#ifdef I960
- bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
-#endif
-
-#ifdef RS6000COFF_C
- bfd_h_put_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
- bfd_h_put_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
- bfd_h_put_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
- bfd_h_put_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
- bfd_h_put_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
- bfd_h_put_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
- bfd_h_put_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
- bfd_h_put_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
- bfd_h_put_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
- bfd_h_put_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
- bfd_h_put_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
- bfd_h_put_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
- bfd_h_put_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
- memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2);
-#endif
-
-#ifdef MIPSECOFF
- bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
- bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
- bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]);
-#endif
-
-#ifdef ALPHAECOFF
- /* FIXME: What does bldrev mean? */
- bfd_h_put_16(abfd, (bfd_vma) 2, (bfd_byte *) aouthdr_out->bldrev);
- bfd_h_put_16(abfd, (bfd_vma) 0, (bfd_byte *) aouthdr_out->padding);
- bfd_h_put_64(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
- bfd_h_put_64(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
- bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
- bfd_h_put_32(abfd, aouthdr_in->fprmask, (bfd_byte *) aouthdr_out->fprmask);
-#endif
-
- 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);
-#if defined(M88)
- scnhdr_int->s_nreloc = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
- scnhdr_int->s_nlnno = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
-#else
- scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
- scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
-#endif
-#ifdef I960
- scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align);
-#endif
-}
-
-static unsigned int
-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);
-
- memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
-
- PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr,
- (bfd_byte *) scnhdr_ext->s_vaddr);
-
-
- PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr,
- (bfd_byte *) scnhdr_ext->s_paddr);
- PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size,
- (bfd_byte *) scnhdr_ext->s_size);
-
- 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);
- PUTWORD(abfd, scnhdr_int->s_flags, (bfd_byte *) scnhdr_ext->s_flags);
-#if defined(M88)
- PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
- PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
-#else
- if (scnhdr_int->s_nlnno <= 0xffff)
- PUTHALF(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);
- PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
- ret = 0;
- }
- if (scnhdr_int->s_nreloc <= 0xffff)
- PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
- 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);
- PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
- ret = 0;
- }
-#endif
-
-#if defined(I960)
- PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
-#endif
- return ret;
-}
diff --git a/contrib/gdb/bfd/config.bfd b/contrib/gdb/bfd/config.bfd
deleted file mode 100644
index 7757d5fec299..000000000000
--- a/contrib/gdb/bfd/config.bfd
+++ /dev/null
@@ -1,491 +0,0 @@
-# config.bfd
-# Convert a canonical host type into a BFD host type.
-# Set shell variable targ to canonical target name, and run
-# using ``. config.bfd''.
-# Sets the following shell variables:
-# targ_defvec Default vector for this target
-# targ_selvecs Vectors to build for this target
-# targ_archs Architectures for this target
-# targ_cflags $(CFLAGS) for this target (FIXME: pretty bogus)
-# targ_undercore Whether underscores are used: yes or no
-
-# The binutils c++filt program wants to know whether underscores are
-# stripped or not. That is why we set targ_underscore. c++filt uses
-# this information to choose a default. This information is
-# duplicated in the symbol_leading_char field of the BFD target
-# vector, but c++filt does not deal with object files and is not
-# linked against libbfd.a. It is not terribly important that c++filt
-# get this right; it is just convenient.
-
-targ_defvec=
-targ_selvecs=
-targ_cflags=
-targ_underscore=no
-
-targ_cpu=`echo $targ | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-case "${targ_cpu}" in
-arm*) targ_archs=bfd_arm_arch ;;
-hppa*) targ_archs=bfd_hppa_arch ;;
-i[345]86) targ_archs=bfd_i386_arch ;;
-m68*) targ_archs=bfd_m68k_arch ;;
-m88*) targ_archs=bfd_m88k_arch ;;
-mips*) targ_archs=bfd_mips_arch ;;
-powerpc*) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
-rs6000) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
-sparc*) targ_archs=bfd_sparc_arch ;;
-z8k*) targ_archs=bfd_z8k_arch ;;
-*) targ_archs=bfd_${targ_cpu}_arch ;;
-esac
-
-# WHEN ADDING ENTRIES TO THIS MATRIX:
-# Make sure that the left side always has two dashes. Otherwise you
-# can get spurious matches. Even for unambiguous cases, do this as a
-# convention, else the table becomes a real mess to understand and maintain.
-
-case "${targ}" in
- alpha-*-netware*)
- targ_defvec=ecoffalpha_little_vec
- targ_selvecs=nlm32_alpha_vec
- ;;
- alpha-*-*)
- targ_defvec=ecoffalpha_little_vec
- ;;
-
-
- arm-*-riscix*)
- targ_defvec=riscix_vec
- ;;
- arm-*-pe*)
- targ_defvec=armpe_little_vec
- targ_selvecs="armpe_little_vec armpe_big_vec armpei_little_vec armpei_big_vec"
- targ_underscore=yes
- ;;
- arm-*-aout | armel-*-aout)
- targ_defvec=aout_arm_little_vec
- targ_selvecs=aout_arm_big_vec
- ;;
- armeb-*-aout)
- targ_defvec=aout_arm_big_vec
- targ_selvecs=aout_arm_little_vec
- ;;
- arm-*-coff)
- targ_defvec=armcoff_little_vec
- targ_selvecs=armcoff_big_vec
- targ_underscore=yes
- ;;
-
- a29k-*-ebmon* | a29k-*-udi* | a29k-*-coff* | a29k-*-sym1* | \
- a29k-*-vxworks* | a29k-*-sysv*)
- targ_defvec=a29kcoff_big_vec
- targ_selvecs=sunos_big_vec
- targ_underscore=yes
- ;;
- a29k-*-aout* | a29k-*-bsd* | a29k-*-vsta*)
- targ_defvec=sunos_big_vec
- targ_underscore=yes
- ;;
-
- h8300*-*-*)
- targ_defvec=h8300coff_vec
- targ_underscore=yes
- ;;
-
- h8500-*-*)
- targ_defvec=h8500coff_vec
- targ_underscore=yes
- ;;
-
- sh-*-*)
- targ_defvec=shcoff_vec
- targ_selvecs="shcoff_vec shlcoff_vec"
- targ_underscore=yes
- ;;
-
- hppa*-*-*elf* | hppa*-*-lites* | hppa*-*-sysv4*)
- targ_defvec=bfd_elf32_hppa_vec
- ;;
- hppa*-*-bsd*)
- targ_defvec=som_vec
- targ_selvecs=bfd_elf32_hppa_vec
- ;;
- hppa*-*-hpux* | hppa*-*-hiux*)
- targ_defvec=som_vec
- ;;
- hppa*-*-osf*)
- targ_defvec=som_vec
- targ_selvecs=bfd_elf32_hppa_vec
- ;;
-
- i[345]86-*-sysv4* | i[345]86-*-unixware | i[345]86-*-solaris2* | \
- i[345]86-*-elf | i[345]86-*-sco*elf*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs=i386coff_vec
- ;;
- i[345]86-*-sysv* | i[345]86-*-isc* | i[345]86-*-sco* | i[345]86-*-coff | \
- i[345]86-*-aix* | i[345]86-*-go32*)
- targ_defvec=i386coff_vec
- ;;
- i[345]86-sequent-bsd*)
- targ_defvec=i386dynix_vec
- targ_underscore=yes
- ;;
- i[345]86-*-bsd*)
- targ_defvec=i386bsd_vec
- targ_underscore=yes
- ;;
- i[345]86-*-freebsd*)
- targ_defvec=i386freebsd_vec
- targ_selvecs=i386bsd_vec
- targ_underscore=yes
- ;;
- i[345]86-*-netbsd*)
- targ_defvec=i386netbsd_vec
- targ_selvecs=i386bsd_vec
- targ_underscore=yes
- ;;
- i[345]86-*-netware*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs="nlm32_i386_vec i386coff_vec i386aout_vec"
- ;;
- i[345]86-*-linuxaout*)
- targ_defvec=i386linux_vec
- targ_selvecs=bfd_elf32_i386_vec
- targ_underscore=yes
- ;;
- i[345]86-*-linux*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs=i386linux_vec
- targ_underscore=yes
- ;;
- i[345]86-*-lynxos*)
- targ_defvec=i386lynx_coff_vec
- targ_selvecs=i386lynx_aout_vec
- ;;
- i[345]86-*-gnu*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs=i386mach3_vec
- targ_cflags=-DSTAT_FOR_EXEC
- targ_underscore=yes
- ;;
- i[345]86-*-mach* | i[345]86-*-osf1mk*)
- targ_defvec=i386mach3_vec
- targ_cflags=-DSTAT_FOR_EXEC
- targ_underscore=yes
- ;;
- i[345]86-*-os9k)
- targ_defvec=i386os9k_vec
- ;;
- i[345]86-*-msdos*)
- targ_defvec=i386aout_vec
- targ_selvecs=i386msdos_vec
- ;;
- i[345]86-*-moss*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs="i386msdos_vec i386aout_vec"
- ;;
- i[345]86-*-cygwin32 | i[345]86-*-winnt | i[345]86-*-pe)
- targ_defvec=i386pe_vec
- targ_selvecs="i386pe_vec i386pei_vec"
- ;;
- i[345]86-none-*)
- targ_defvec=i386coff_vec
- ;;
- i[345]86-*-aout* | i[345]86*-*-vsta*)
- targ_defvec=i386aout_vec
- ;;
-
- i860-*-mach3* | i860-*-osf1* | i860-*-coff*)
- targ_defvec=i860coff_vec
- ;;
- i860-*-sysv4* | i860-*-elf*)
- targ_defvec=bfd_elf32_i860_vec
- ;;
-
- i960-*-vxworks4* | i960-*-vxworks5.0)
- targ_defvec=b_out_vec_little_host
- targ_selvecs="b_out_vec_big_host icoff_little_vec icoff_big_vec"
- targ_underscore=yes
- ;;
- i960-*-vxworks5.* | i960-*-coff* | i960-*-sysv*)
- targ_defvec=icoff_little_vec
- targ_selvecs="icoff_big_vec b_out_vec_little_host b_out_vec_big_host"
- targ_underscore=yes
- ;;
- i960-*-vxworks* | i960-*-aout* | i960-*-bout* | i960-*-nindy*)
- targ_defvec=b_out_vec_little_host
- targ_selvecs="b_out_vec_big_host icoff_little_vec icoff_big_vec"
- targ_underscore=yes
- ;;
-
- m68*-apollo-*)
- targ_defvec=apollocoff_vec
- ;;
- m68*-bull-sysv*)
- targ_defvec=m68kcoffun_vec
- targ_underscore=yes
- ;;
- m68*-hp-bsd*)
- targ_defvec=hp300bsd_vec
- targ_underscore=yes
- ;;
- m68*-*-aout*)
- targ_defvec=aout0_big_vec
- # We include this here, rather than making a separate cisco
- # configuration, so that cisco-core.c gets routinely tested at
- # least for compilation.
- targ_selvecs=cisco_core_vec
- targ_underscore=yes
- ;;
- m68*-*-elf* | m68*-*-sysv4*)
- targ_defvec=bfd_elf32_m68k_vec
- targ_selvecs=m68kcoff_vec
- ;;
- m68*-*-coff* | m68*-*-sysv*)
- targ_defvec=m68kcoff_vec
- targ_selvecs="m68kcoff_vec versados_vec"
- ;;
- m68*-*-hpux*)
- targ_defvec=hp300hpux_vec
- targ_underscore=yes
- ;;
- m68*-*-linuxaout*)
- targ_defvec=m68klinux_vec
- targ_selvecs=bfd_elf32_m68k_vec
- targ_underscore=yes
- ;;
- m68*-*-linux*)
- targ_defvec=bfd_elf32_m68k_vec
- targ_selvecs=m68klinux_vec
- ;;
- m68*-*-lynxos*)
- targ_defvec=m68klynx_coff_vec
- targ_selvecs=m68klynx_aout_vec
- ;;
- m68*-hp*-netbsd*)
- targ_defvec=m68k4knetbsd_vec
- targ_selvecs="m68knetbsd_vec hp300bsd_vec sunos_big_vec"
- targ_underscore=yes
- ;;
- m68*-*-netbsd*)
- targ_defvec=m68knetbsd_vec
- targ_selvecs="m68k4knetbsd_vec hp300bsd_vec sunos_big_vec"
- targ_underscore=yes
- ;;
- m68*-*-sunos* | m68*-*-os68k* | m68*-*-vxworks* | m68*-netx-* | \
- m68*-*-bsd* | m68*-*-vsta*)
- targ_defvec=sunos_big_vec
- targ_underscore=yes
- ;;
- m68*-ericsson-*)
- targ_defvec=sunos_big_vec
- targ_selvecs="m68kcoff_vec tekhex_vec"
- targ_underscore=yes
- ;;
- m68*-cbm-*)
- targ_defvec=bfd_elf32_m68k_vec
- targ_selvecs=m68kcoff_vec
- ;;
- m68*-apple-aux*)
- targ_defvec=m68kaux_coff_vec
- ;;
- m68*-*-psos*)
- targ_defvec=bfd_elf32_m68k_vec
- targ_selvecs=ieee_vec
- targ_underscore=yes
- ;;
-
- m88*-harris-cxux* | m88*-*-dgux* | m88*-*-sysv4*)
- targ_defvec=bfd_elf32_m88k_vec
- targ_selvecs=m88kbcs_vec
- ;;
- m88*-*-mach3*)
- targ_defvec=m88kmach3_vec
- targ_cflags=-DSTAT_FOR_EXEC
- ;;
- m88*-*-*)
- targ_defvec=m88kbcs_vec
- targ_underscore=yes
- ;;
-
- mips*-big-*)
- targ_defvec=ecoff_big_vec
- targ_selvecs=ecoff_little_vec
- ;;
- mips-dec-netbsd*)
- targ_defvec=bfd_elf32_littlemips_vec
- targ_selvecs=bfd_elf32_bigmips_vec
- ;;
- mips*-dec-bsd*)
- targ_defvec=aout_mips_little_vec
- targ_underscore=yes
- ;;
- mips*-dec-mach3*)
- targ_defvec=aout_mips_little_vec
- targ_cflags=-DSTAT_FOR_EXEC
- ;;
- mips*-dec-* | mips*el-*-ecoff*)
- targ_defvec=ecoff_little_vec
- targ_selvecs=ecoff_big_vec
- ;;
- mips*-*-ecoff*)
- targ_defvec=ecoff_big_vec
- targ_selvecs=ecoff_little_vec
- ;;
- mips*-*-irix5*)
- targ_defvec=bfd_elf32_bigmips_vec
- targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec"
- ;;
- mips*-sgi-* | mips*-*-bsd*)
- targ_defvec=ecoff_big_vec
- targ_selvecs=ecoff_little_vec
- ;;
- mips*-*-mach3*)
- targ_defvec=aout_mips_little_vec
- targ_cflags=-DSTAT_FOR_EXEC
- ;;
- mips*-*-sysv4*)
- targ_defvec=bfd_elf32_bigmips_vec
- targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec"
- ;;
- mips*-*-sysv* | mips*-*-riscos*)
- targ_defvec=ecoff_big_vec
- targ_selvecs=ecoff_little_vec
- ;;
- mips*el-*-elf*)
- targ_defvec=bfd_elf32_littlemips_vec
- targ_selvecs=bfd_elf32_bigmips_vec
- ;;
- mips*-*-elf*)
- targ_defvec=bfd_elf32_bigmips_vec
- targ_selvecs=bfd_elf32_littlemips_vec
- ;;
-
- ns32k-pc532-mach* | ns32k-pc532-ux*)
- targ_defvec=pc532machaout_vec
- targ_underscore=yes
- ;;
- ns32k-*-netbsd* | ns32k-*-lites*)
- targ_defvec=pc532netbsd_vec
- targ_underscore=yes
- ;;
-
- powerpc-*-aix*)
- targ_defvec=rs6000coff_vec
- ;;
- powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | powerpc-*-solaris2*)
- targ_defvec=bfd_elf32_powerpc_vec
- targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec"
- ;;
- powerpc-*-macos* | powerpc-*-mpw*)
- targ_defvec=pmac_xcoff_vec
- ;;
- powerpc-*-netware*)
- targ_defvec=bfd_elf32_powerpc_vec
- targ_selvecs="nlm32_powerpc_vec rs6000coff_vec"
- ;;
- powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
- powerpcle-*-solaris2*)
- targ_defvec=bfd_elf32_powerpcle_vec
- targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec"
- ;;
-
- powerpcle-*-pe | powerpcle-*-winnt* | powerpcle-*-cygwin32)
- targ_defvec=bfd_powerpcle_pe_vec
- targ_selvecs="bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec"
- ;;
-
- rs6000-*-*)
- targ_defvec=rs6000coff_vec
- ;;
-
- sparc-*-lynxos*)
- targ_defvec=sparclynx_coff_vec
- targ_selvecs=sparclynx_aout_vec
- ;;
- sparc-*-netbsd*)
- targ_defvec=sparcnetbsd_vec
- targ_underscore=yes
- ;;
- sparc-*-elf* | sparc-*-sysv4* | sparc-*-solaris2*)
- targ_defvec=bfd_elf32_sparc_vec
- targ_selvecs=sunos_big_vec
- ;;
- sparc64-*-aout*)
- targ_defvec=sunos_big_vec
- targ_underscore=yes
- ;;
- sparc64-*-elf*)
- targ_defvec=bfd_elf64_sparc_vec
- targ_selvecs=bfd_elf32_sparc_vec
- ;;
- sparc64-*-solaris2* | sparc64-*-sysv4*)
- targ_defvec=bfd_elf32_sparc_vec
- # Adding 64 bit support by default causes things like objdump to
- # print addresses as 64 bits.
- #targ_selvecs=bfd_elf64_sparc_vec
- ;;
- sparc-*-netware*)
- targ_defvec=bfd_elf32_sparc_vec
- targ_selvecs="nlm32_sparc_vec sunos_big_vec"
- ;;
- sparc*-*-coff*)
- targ_defvec=sparccoff_vec
- ;;
- sparc*-*-*)
- targ_defvec=sunos_big_vec
- targ_underscore=yes
- ;;
-
- tahoe-*-*)
- targ_defvec=host_aout_vec
- targ_underscore=yes
- ;;
-
- vax-*-vms*)
- echo 1>&2 "*** BFD does not support target ${targ}."
- echo 1>&2 "*** Look in bfd/config.bfd for supported targets."
- exit 1
- ;;
- vax-*-*)
- targ_defvec=host_aout_vec
- targ_underscore=yes
- ;;
-
- we32k-*-*)
- targ_defvec=we32kcoff_vec
- ;;
-
- w65-*-*)
- targ_defvec=w65_vec
- ;;
-
- z8k*-*-*)
- targ_defvec=z8kcoff_vec
- targ_underscore=yes
- ;;
-
- *-*-ieee*)
- targ_defvec=ieee_vec
- ;;
-
- *-adobe-*)
- targ_defvec=a_aout_adobe_vec
- targ_underscore=yes
- ;;
-
- *-sony-*)
- targ_defvec=newsos3_vec
- targ_underscore=yes
- ;;
-
- *-tandem-*)
- targ_defvec=m68kcoff_vec
- targ_selvecs=ieee_vec
- ;;
-
- *)
- echo 1>&2 "*** BFD does not support target ${targ}."
- echo 1>&2 "*** Look in bfd/config.bfd for supported targets."
- exit 1
- ;;
-esac
diff --git a/contrib/gdb/bfd/config.in b/contrib/gdb/bfd/config.in
deleted file mode 100644
index dd4f968e7940..000000000000
--- a/contrib/gdb/bfd/config.in
+++ /dev/null
@@ -1,67 +0,0 @@
-/* config.in. Generated automatically from configure.in by autoheader. */
-
-/* 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
-
-/* Define if you have a working `mmap' system call. */
-#undef HAVE_MMAP
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
-/* 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
-
-/* Define if you have the fcntl function. */
-#undef HAVE_FCNTL
-
-/* Define if you have the getpagesize function. */
-#undef HAVE_GETPAGESIZE
-
-/* Define if you have the madvise function. */
-#undef HAVE_MADVISE
-
-/* Define if you have the mprotect function. */
-#undef HAVE_MPROTECT
-
-/* Define if you have the valloc function. */
-#undef HAVE_VALLOC
-
-/* Define if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
-
-/* Define if you have the <stddef.h> header file. */
-#undef HAVE_STDDEF_H
-
-/* Define if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define if you have the <sys/file.h> header file. */
-#undef HAVE_SYS_FILE_H
-
-/* Define if you have the <sys/time.h> header file. */
-#undef HAVE_SYS_TIME_H
-
-/* Define if you have the <time.h> header file. */
-#undef HAVE_TIME_H
-
-/* Define if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
diff --git a/contrib/gdb/bfd/configure b/contrib/gdb/bfd/configure
deleted file mode 100644
index 5db14db15a9e..000000000000
--- a/contrib/gdb/bfd/configure
+++ /dev/null
@@ -1,2439 +0,0 @@
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.8
-# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_help="$ac_help
- --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)"
-ac_help="$ac_help
- --enable-targets alternative target configurations"
-ac_help="$ac_help
- --enable-shared build shared BFD library"
-ac_help="$ac_help
- --enable-commonbfdlib build shared BFD/opcodes/libiberty library"
-ac_help="$ac_help
- --with-mmap try using mmap for BFD input files if available"
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-
-ac_prev=
-for ac_option
-do
-
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$ac_optarg" ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file="$ac_optarg" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix="$ac_optarg" ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he)
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$ac_optarg" ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir="$ac_optarg" ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir="$ac_optarg" ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir="$ac_optarg" ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir="$ac_optarg" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir="$ac_optarg" ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir="$ac_optarg" ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir="$ac_optarg" ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix="$ac_optarg" ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix="$ac_optarg" ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix="$ac_optarg" ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name="$ac_optarg" ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir="$ac_optarg" ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir="$ac_optarg" ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site="$ac_optarg" ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir="$ac_optarg" ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir="$ac_optarg" ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.8"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes="$ac_optarg" ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries="$ac_optarg" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set LANG and LC_ALL to C if already set.
-# These must not be set unconditionally because not all systems understand
-# e.g. LANG=C (notably SCO).
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=libbfd.c
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-# Check whether --enable-64-bit-bfd or --disable-64-bit-bfd was given.
-if test "${enable_64_bit_bfd+set}" = set; then
- enableval="$enable_64_bit_bfd"
- case "${enableval}" in
- yes) want64=true ;;
- no) want64=false ;;
- *) { echo "configure: error: bad value ${enableval} for 64-bit-bfd option" 1>&2; exit 1; } ;;
-esac
-else
- want64=false
-fi
-# Check whether --enable-targets or --disable-targets was given.
-if test "${enable_targets+set}" = set; then
- enableval="$enable_targets"
- case "${enableval}" in
- yes | "") { echo "configure: error: enable-targets option must specify target names or 'all'" 1>&2; exit 1; }
- ;;
- no) enable_targets= ;;
- *) enable_targets=$enableval ;;
-esac
-fi
-# Check whether --enable-shared or --disable-shared was given.
-if test "${enable_shared+set}" = set; then
- enableval="$enable_shared"
- case "${enableval}" in
- yes) shared=true ;;
- no) shared=false ;;
- *) { echo "configure: error: bad value ${enableval} for BFD shared option" 1>&2; exit 1; } ;;
-esac
-fi
-# Check whether --enable-commonbfdlib or --disable-commonbfdlib was given.
-if test "${enable_commonbfdlib+set}" = set; then
- enableval="$enable_commonbfdlib"
- case "${enableval}" in
- yes) commonbfdlib=true ;;
- no) commonbfdlib=false ;;
- *) { echo "configure: error: bad value ${enableval} for BFD commonbfdlib option" 1>&2; exit 1; } ;;
-esac
-fi
-# Check whether --with-mmap or --without-mmap was given.
-if test "${with_mmap+set}" = set; then
- withval="$with_mmap"
- case "${withval}" in
- yes) want_mmap=true ;;
- no) want_mmap=false ;;
- *) { echo "configure: error: bad value ${withval} for BFD with-mmap option" 1>&2; exit 1; } ;;
-esac
-else
- want_mmap=false
-fi
-
-
-
-ac_aux_dir=
-for ac_dir in `cd $srcdir/..;pwd` $srcdir/`cd $srcdir/..;pwd`; do
- if test -f $ac_dir/install-sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f $ac_dir/install.sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- { echo "configure: error: can not find install-sh or install.sh in `cd $srcdir/..;pwd` $srcdir/`cd $srcdir/..;pwd`" 1>&2; exit 1; }
-fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
-
-
-# Do some error checking and defaulting for the host and target type.
-# The inputs are:
-# configure --host=HOST --target=TARGET --build=BUILD NONOPT
-#
-# The rules are:
-# 1. You are not allowed to specify --host, --target, and nonopt at the
-# same time.
-# 2. Host defaults to nonopt.
-# 3. If nonopt is not specified, then host defaults to the current host,
-# as determined by config.guess.
-# 4. Target and build default to nonopt.
-# 5. If nonopt is not specified, then target and build default to host.
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-case $host---$target---$nonopt in
-NONE---*---* | *---NONE---* | *---*---NONE) ;;
-*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
-esac
-
-
-# Make sure we can run config.sub.
-if $ac_config_sub sun4 >/dev/null 2>&1; then :
-else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking host system type""... $ac_c" 1>&6
-
-host_alias=$host
-case "$host_alias" in
-NONE)
- case $nonopt in
- NONE)
- if host_alias=`$ac_config_guess`; then :
- else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
- fi ;;
- *) host_alias=$nonopt ;;
- esac ;;
-esac
-
-host=`$ac_config_sub $host_alias`
-host_cpu=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
-host_os=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
-echo "$ac_t""$host" 1>&6
-
-echo $ac_n "checking target system type""... $ac_c" 1>&6
-
-target_alias=$target
-case "$target_alias" in
-NONE)
- case $nonopt in
- NONE) target_alias=$host_alias ;;
- *) target_alias=$nonopt ;;
- esac ;;
-esac
-
-target=`$ac_config_sub $target_alias`
-target_cpu=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-target_vendor=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
-target_os=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
-echo "$ac_t""$target" 1>&6
-
-echo $ac_n "checking build system type""... $ac_c" 1>&6
-
-build_alias=$build
-case "$build_alias" in
-NONE)
- case $nonopt in
- NONE) build_alias=$host_alias ;;
- *) build_alias=$nonopt ;;
- esac ;;
-esac
-
-build=`$ac_config_sub $build_alias`
-build_cpu=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-build_vendor=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
-build_os=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
-echo "$ac_t""$build" 1>&6
-
-test "$host_alias" != "$target_alias" &&
- test "$program_prefix$program_suffix$program_transform_name" = \
- NONENONEs,x,x, &&
- program_prefix=${target_alias}-
-
-if test -z "$target" ; then
- { echo "configure: error: Unrecognized target system type; please check config.sub." 1>&2; exit 1; }
-fi
-if test "$program_transform_name" = s,x,x,; then
- program_transform_name=
-else
- # Double any \ or $. echo might interpret backslashes.
- cat <<\EOF_SED > conftestsed
-s,\\,\\\\,g; s,\$,$$,g
-EOF_SED
- program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
- rm -f conftestsed
-fi
-test "$program_prefix" != NONE &&
- program_transform_name="s,^,${program_prefix},; $program_transform_name"
-# Use a double $ so make ignores it.
-test "$program_suffix" != NONE &&
- program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
-
-# sed with no file args requires a program.
-test "$program_transform_name" = "" && program_transform_name="s,x,x,"
-
-
-host64=false
-target64=false
-
-# host stuff:
-
-ALLLIBS='$(TARGETLIB)'
-PICFLAG=
-SHLIB=unused-shlib
-SHLINK=unused-shlink
-if test "${shared}" = "true"; then
- PICFLAG=-fpic
- if test "${commonbfdlib}" = "true"; then
- ALLLIBS='$(TARGETLIB)'
- else
- ALLLIBS='$(TARGETLIB) $(SHLIB) $(SHLINK)'
- SHLIB=libbfd.so.`sed -e 's/[^0-9]*\([0-9.]*\).*/\1/' ${srcdir}/VERSION`
- SHLINK=libbfd.so
- fi
-fi
-
-# Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="gcc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- ac_prog_rejected=no
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# -gt 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- set dummy "$ac_dir/$ac_word" "$@"
- shift
- ac_cv_prog_CC="$@"
- fi
-fi
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.c <<EOF
-#ifdef __GNUC__
- yes;
-#endif
-EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:814: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
- ac_cv_prog_gcc=yes
-else
- ac_cv_prog_gcc=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
-if test $ac_cv_prog_gcc = yes; then
- GCC=yes
- if test "${CFLAGS+set}" != set; then
- echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
- ac_cv_prog_gcc_g=yes
-else
- ac_cv_prog_gcc_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
- if test $ac_cv_prog_gcc_g = yes; then
- CFLAGS="-g -O"
- else
- CFLAGS="-O"
- fi
- fi
-else
- GCC=
- test "${CFLAGS+set}" = set || CFLAGS="-g"
-fi
-
-
-# Permit host specific settings.
-. ${srcdir}/configure.host
-
-
-if test $host != $build; then
- ac_tool_prefix=${host_alias}-
-else
- ac_tool_prefix=
-fi
-
-# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ar; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$AR"; then
- ac_cv_prog_AR="$AR" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_AR="${ac_tool_prefix}ar"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar"
-fi
-fi
-AR="$ac_cv_prog_AR"
-if test -n "$AR"; then
- echo "$ac_t""$AR" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-
-# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
- echo "$ac_t""$RANLIB" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-if test -z "$ac_cv_prog_RANLIB"; then
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_RANLIB="ranlib"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
- echo "$ac_t""$RANLIB" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-else
- RANLIB=":"
-fi
-fi
-
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- # Account for people who put trailing slashes in PATH elements.
- case "$ac_dir/" in
- /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- for ac_prog in ginstall installbsd scoinst install; do
- if test -f $ac_dir/$ac_prog; then
- if test $ac_prog = install &&
- grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- # OSF/1 installbsd also uses dspmsg, but is usable.
- :
- else
- ac_cv_path_install="$ac_dir/$ac_prog -c"
- break 2
- fi
- fi
- done
- ;;
- esac
- done
- IFS="$ac_save_ifs"
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL="$ac_cv_path_install"
- else
- # As a last resort, use the slow shell script. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL="$ac_install_sh"
- fi
-fi
-echo "$ac_t""$INSTALL" 1>&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-if test "${shared}" = "true"; then
- if test "${GCC}" != "yes" && test "${shared_non_gcc}" != "yes"; then
- echo "configure: warning: BFD --enable-shared only supported when using gcc" 1>&2
- shared=false
- ALLLIBS='$(TARGETLIB)'
- PICFLAG=
- SHLIB=unused-shlib
- fi
-fi
-
-
-
-
-
-
-if test "${commonbfdlib}" = "true"; then
- COMMON_SHLIB=yes
- PICLIST=piclist
-else
- COMMON_SHLIB=
- PICLIST=
-fi
-
-
-
-
-HOST_64BIT_LONG=0
-if test "x${HOST_64BIT_TYPE}" = "xlong"; then
- HOST_64BIT_LONG=1
-fi
-
-
-# If we cannot run a trivial program, we must be cross compiling.
-echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_c_cross=yes
-else
-cat > conftest.$ac_ext <<EOF
-#line 1056 "configure"
-#include "confdefs.h"
-main(){return(0);}
-EOF
-{ (eval echo configure:1060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_c_cross=no
-else
- ac_cv_c_cross=yes
-fi
-fi
-rm -fr conftest*
-fi
-
-echo "$ac_t""$ac_cv_c_cross" 1>&6
-cross_compiling=$ac_cv_c_cross
-
-# Put a plausible default for CC_FOR_BUILD in Makefile.
-if test -z "$CC_FOR_BUILD"; then
- if test "x$cross_compiling" = "xno"; then
- CC_FOR_BUILD='$(CC)'
- else
- CC_FOR_BUILD=gcc
- fi
-fi
-
-
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 1098 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1104: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 1113 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1119: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-for ac_hdr in stddef.h string.h strings.h stdlib.h time.h unistd.h
-do
-ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1147 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1152: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-for ac_hdr in fcntl.h sys/file.h sys/time.h
-do
-ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1184 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1189: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1218 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-int main() { return 0; }
-int t() {
-struct tm *tp;
-; return 0; }
-EOF
-if { (eval echo configure:1228: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_header_time=yes
-else
- rm -rf conftest*
- ac_cv_header_time=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_header_time" 1>&6
-if test $ac_cv_header_time = yes; then
- cat >> confdefs.h <<\EOF
-#define TIME_WITH_SYS_TIME 1
-EOF
-
-fi
-
-for ac_func in fcntl getpagesize
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1254 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-
-
-case "${host}" in
-i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32)
- cat >> confdefs.h <<\EOF
-#define USE_BINARY_FOPEN 1
-EOF
- ;;
-esac
-
-echo $ac_n "checking whether malloc must be declared""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'bfd_cv_decl_needed_malloc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1313 "configure"
-#include "confdefs.h"
-
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-int main() { return 0; }
-int t() {
-char *(*pfn) = (char *(*)) malloc
-; return 0; }
-EOF
-if { (eval echo configure:1328: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- bfd_cv_decl_needed_malloc=no
-else
- rm -rf conftest*
- bfd_cv_decl_needed_malloc=yes
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$bfd_cv_decl_needed_malloc" 1>&6
-if test $bfd_cv_decl_needed_malloc = yes; then
- bfd_tr_decl=NEED_DECLARATION_`echo malloc | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $bfd_tr_decl 1
-EOF
-
-fi
-
-echo $ac_n "checking whether free must be declared""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'bfd_cv_decl_needed_free'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1353 "configure"
-#include "confdefs.h"
-
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-int main() { return 0; }
-int t() {
-char *(*pfn) = (char *(*)) free
-; return 0; }
-EOF
-if { (eval echo configure:1368: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- bfd_cv_decl_needed_free=no
-else
- rm -rf conftest*
- bfd_cv_decl_needed_free=yes
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$bfd_cv_decl_needed_free" 1>&6
-if test $bfd_cv_decl_needed_free = yes; then
- bfd_tr_decl=NEED_DECLARATION_`echo free | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $bfd_tr_decl 1
-EOF
-
-fi
-
-
-# If we are configured native, pick a core file support file.
-COREFILE=
-COREFLAG=
-if test "${target}" = "${host}"; then
- case "${host}" in
- alpha*-*-linux*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/alphalinux.h"
-EOF
-
- ;;
- alpha*-*-*) COREFILE=osf-core.o ;;
- arm-*-riscix) COREFILE=trad-core.o ;;
- hppa*-*-hpux*) COREFILE=hpux-core.o ;;
- hppa*-*-hiux*) COREFILE=hpux-core.o ;;
- hppa*-*-bsd*) COREFILE="hpux-core.o hppabsd-core.o"
- COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;;
- i[345]86-sequent-bsd*)
- COREFILE=trad-core.o;
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/symmetry.h"
-EOF
-
- ;;
- i[345]86-sequent-sysv4*) ;;
- i[345]86-sequent-sysv*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/symmetry.h"
-EOF
-
- ;;
- i[345]86-*-bsd* | i[345]86-*-freebsd*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i386bsd.h"
-EOF
-
- ;;
- i[345]86-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- i[345]86-esix-sysv3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/esix.h"
-EOF
-
- ;;
- i[345]86-*-sco* | i[345]86-*-isc*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i386sco.h"
-EOF
-
- ;;
- i[345]86-*-mach3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i386mach3.h"
-EOF
-
- ;;
- i[345]86-*-linux*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i386linux.h"
-EOF
-
- ;;
- i[345]86-*-isc*) COREFILE=trad-core.o ;;
- i[345]86-*-aix*) COREFILE=aix386-core.o ;;
- i860-*-mach3* | i860-*-osf1*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i860mach3.h"
-EOF
-
- ;;
- mips-dec-bsd*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/mipsbsd.h"
-EOF
-
- ;;
- mips-dec-mach3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/mipsmach3.h"
-EOF
-
- ;;
- mips-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- mips-dec-*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/decstation.h"
-EOF
-
- ;;
- mips-sgi-irix4*) COREFILE=irix-core.o ;;
- mips-sgi-irix5*) COREFILE=irix-core.o ;;
- mips-*-mach3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/mipsmach3.h"
-EOF
-
- ;;
- mips-*-sysv4*) ;;
- mips-*-sysv* | mips-*-riscos*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/riscos.h"
-EOF
-
- ;;
- mips-sony-bsd*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/news-mips.h"
-EOF
-
- ;;
- m68*-bull*-sysv*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/dpx2.h"
-EOF
-
- ;;
- m68*-hp-hpux*) COREFILE=hpux-core.o ;;
- m68*-hp-bsd*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/hp300bsd.h"
-EOF
-
- ;;
- m68*-*-linux*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/m68klinux.h"
-EOF
-
- ;;
- m68*-motorola-sysv*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/delta68.h"
-EOF
-
- ;;
- m68*-sony-*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/news.h"
-EOF
-
- ;;
- m68*-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- m68*-apple-aux*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/m68kaux.h"
-EOF
-
- ;;
- m88*-*-sysv4*) ;;
- m88*-motorola-sysv*) COREFILE=ptrace-core.o ;;
- m88*-*-mach3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/m88kmach3.h"
-EOF
-
- ;;
- ns32k-pc532-mach)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/pc532mach.h"
-EOF
-
- ;;
- ns32k-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- rs6000-*-lynx*) COREFILE=lynx-core.o ;;
- rs6000-*-aix4*) COREFILE=rs6000-core.o ;;
- rs6000-*-*) COREFILE=rs6000-core.o ;;
- powerpc-*-aix4*) COREFILE=rs6000-core.o ;;
- powerpc-*-aix*) COREFILE=rs6000-core.o ;;
- sparc-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- tahoe-*-*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/tahoe.h"
-EOF
-
- ;;
- vax-*-ultrix2*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/vaxult2.h"
-EOF
-
- ;;
- vax-*-ultrix*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/vaxult2.h"
-EOF
-
- ;;
- vax-*-*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/vaxbsd.h"
-EOF
-
- ;;
- esac
-
- case "$COREFILE" in
- aix386-core.o) COREFLAG=-DAIX386_CORE ;;
- hppabsd-core.o) COREFLAG=-DHPPABSD_CORE ;;
- hpux-core.o) COREFLAG=-DHPUX_CORE ;;
- irix-core.o) COREFLAG=-DIRIX_CORE ;;
- lynx-core.o) COREFLAG=-DLYNX_CORE ;;
- osf-core.o) COREFLAG=-DOSF_CORE ;;
- ptrace-core.o) COREFLAG=-DPTRACE_CORE ;;
- rs6000-core.o) COREFLAG="$COREFLAG -DAIX_CORE" ;;
- trad-core.o) COREFLAG="$COREFLAG -DTRAD_CORE" ;;
- esac
-
- # The ELF code uses the native <sys/procfs.h> to handle core files.
- # Define HAVE_SYS_PROCFS_H if the file exists and defines
- # prstatus_t.
- echo $ac_n "checking for sys/procfs.h""... $ac_c" 1>&6
- if eval "test \"`echo '$''{'bfd_cv_header_sys_procfs_h'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1640 "configure"
-#include "confdefs.h"
-#include <sys/procfs.h>
-int main() { return 0; }
-int t() {
-prstatus_t t;
-; return 0; }
-EOF
-if { (eval echo configure:1648: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- bfd_cv_header_sys_procfs_h=yes
-else
- rm -rf conftest*
- bfd_cv_header_sys_procfs_h=no
-fi
-rm -f conftest*
-
-fi
-
- echo "$ac_t""$bfd_cv_header_sys_procfs_h" 1>&6
- if test $bfd_cv_header_sys_procfs_h = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS_PROCFS_H 1
-EOF
-
- fi
-
-fi
-
-
-
-# target stuff:
-
-# Canonicalize the secondary target names.
-if test -n "$enable_targets" ; then
- for targ in `echo $enable_targets | sed 's/,/ /g'`
- do
- result=`$ac_config_sub $targ 2>/dev/null`
- if test -n "$result" ; then
- canon_targets="$canon_targets $result"
- else
- # Allow targets that config.sub doesn't recognize, like "all".
- canon_targets="$canon_targets $targ"
- fi
- done
-fi
-
-all_targets=false
-defvec=
-selvecs=
-selarchs=
-TDEFINES=
-for targ in $target $canon_targets
-do
- if test "x$targ" = "xall"; then
- all_targets=true
- else
- . $srcdir/config.bfd
- if test "x$targ" = "x$target"; then
- defvec=$targ_defvec
- fi
- selvecs="$selvecs $targ_defvec $targ_selvecs"
- selarchs="$selarchs $targ_archs"
- TDEFINES="$TDEFINES $targ_cflags"
- fi
-done
-
-
-# This processing still needs to be done if we're to decide properly whether
-# 64-bit support needs to be compiled in. Currently, it will be included if
-# the default or any other explicitly requested target requires it; it
-# will not be included on a 32-bit host if no 64-bit target is requested, and
-# no "--with-64-bit-bfd" option is given, even if "--with-targets=all" is
-# used.
-
-# uniq the default and selected vectors in all the configured targets.
-f=""
-for i in $selvecs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-selvecs="$f"
-
-# uniq the architectures in all the configured targets.
-f=""
-for i in $selarchs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-selarchs="$f"
-
-# Target backend .o files.
-tb=
-
-elf="elf.o elflink.o"
-
-for vec in $selvecs
-do
- case "$vec" in
- # This list is alphabetized to make it easy to compare
- # with the two vector lists in targets.c.
- a29kcoff_big_vec) tb="$tb coff-a29k.o cofflink.o" ;;
- a_out_adobe_vec) tb="$tb aout-adobe.o aout32.o" ;;
- armcoff_little_vec) tb="$tb coff-arm.o cofflink.o " ;;
- armcoff_big_vec) tb="$tb coff-arm.o cofflink.o " ;;
- armpe_little_vec) tb="$tb pe-arm.o cofflink.o " ;;
- armpe_big_vec) tb="$tb pe-arm.o cofflink.o " ;;
- armpei_little_vec) tb="$tb pei-arm.o cofflink.o " ;;
- armpei_big_vec) tb="$tb pei-arm.o cofflink.o " ;;
- aout0_big_vec) tb="$tb aout0.o aout32.o" ;;
- aout_arm_big_vec) tb="$tb aout-arm.o aout32.o" ;;
- aout_arm_little_vec) tb="$tb aout-arm.o aout32.o" ;;
- aout_mips_big_vec) tb="$tb mipsbsd.o aout32.o" ;;
- aout_mips_little_vec) tb="$tb mipsbsd.o aout32.o" ;;
- apollocoff_vec) tb="$tb coff-apollo.o" ;;
- b_out_vec_big_host) tb="$tb bout.o aout32.o" ;;
- b_out_vec_little_host) tb="$tb bout.o aout32.o" ;;
- bfd_elf32_big_generic_vec) tb="$tb elf32-gen.o elf32.o $elf" ;;
- bfd_elf32_bigmips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;;
- bfd_elf32_hppa_vec) tb="$tb elf32-hppa.o elf32.o $elf" ;;
- bfd_elf32_i386_vec) tb="$tb elf32-i386.o elf32.o $elf" ;;
- bfd_elf32_i860_vec) tb="$tb elf32-i860.o elf32.o $elf" ;;
- bfd_elf32_little_generic_vec) tb="$tb elf32-gen.o elf32.o $elf" ;;
- bfd_elf32_littlemips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;;
- bfd_elf32_m68k_vec) tb="$tb elf32-m68k.o elf32.o $elf" ;;
- bfd_elf32_m88k_vec) tb="$tb elf32-m88k.o elf32.o $elf" ;;
- bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;;
- bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;;
- bfd_elf32_sparc_vec) tb="$tb elf32-sparc.o elf32.o $elf" ;;
- bfd_elf64_big_generic_vec) tb="$tb elf64-gen.o elf64.o $elf"
- target64=true ;;
- bfd_elf64_little_generic_vec) tb="$tb elf64-gen.o elf64.o $elf"
- target64=true ;;
- bfd_elf64_sparc_vec) tb="$tb elf64-sparc.o elf64.o $elf"
- target64=true ;;
- cisco_core_vec) tb="$tb cisco-core.o" ;;
- demo_64_vec) tb="$tb demo64.o aout64.o"
- target64=true ;;
- ecoff_big_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
- ecoff_little_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
- ecoffalpha_little_vec) tb="$tb coff-alpha.o ecoff.o ecofflink.o"
- target64=true ;;
- h8300coff_vec) tb="$tb coff-h8300.o reloc16.o" ;;
- h8500coff_vec) tb="$tb coff-h8500.o reloc16.o" ;;
- host_aout_vec) tb="$tb host-aout.o aout32.o" ;;
- hp300bsd_vec) tb="$tb hp300bsd.o aout32.o" ;;
- hp300hpux_vec) tb="$tb hp300hpux.o aout32.o" ;;
- i386aout_vec) tb="$tb i386aout.o aout32.o" ;;
- i386bsd_vec) tb="$tb i386bsd.o aout32.o" ;;
- i386coff_vec) tb="$tb coff-i386.o cofflink.o" ;;
- i386dynix_vec) tb="$tb i386dynix.o aout32.o" ;;
- i386freebsd_vec) tb="$tb i386freebsd.o aout32.o" ;;
- i386msdos_vec) tb="$tb i386msdos.o" ;;
- i386pe_vec) tb="$tb pe-i386.o cofflink.o " ;;
- i386pei_vec) tb="$tb pei-i386.o cofflink.o" ;;
- i386linux_vec) tb="$tb i386linux.o aout32.o" ;;
- i386lynx_aout_vec) tb="$tb i386lynx.o lynx-core.o aout32.o" ;;
- i386lynx_coff_vec) tb="$tb cf-i386lynx.o cofflink.o lynx-core.o" ;;
- i386mach3_vec) tb="$tb i386mach3.o aout32.o" ;;
- i386netbsd_vec) tb="$tb i386netbsd.o aout32.o" ;;
- i386os9k_vec) tb="$tb i386os9k.o aout32.o" ;;
- i860coff_vec) tb="$tb coff-i860.o cofflink.o" ;;
- icoff_big_vec) tb="$tb coff-i960.o cofflink.o" ;;
- icoff_little_vec) tb="$tb coff-i960.o cofflink.o" ;;
- ieee_vec) tb="$tb ieee.o" ;;
- m68kcoff_vec) tb="$tb coff-m68k.o cofflink.o" ;;
- m68kcoffun_vec) tb="$tb coff-u68k.o coff-m68k.o cofflink.o" ;;
- m68klinux_vec) tb="$tb m68klinux.o aout32.o" ;;
- m68klynx_aout_vec) tb="$tb m68klynx.o lynx-core.o aout32.o" ;;
- m68klynx_coff_vec) tb="$tb cf-m68klynx.o coff-m68k.o cofflink.o lynx-core.o" ;;
- m68knetbsd_vec) tb="$tb m68knetbsd.o aout32.o" ;;
- m68k4knetbsd_vec) tb="$tb m68k4knetbsd.o aout32.o" ;;
- m68kaux_coff_vec) tb="$tb coff-aux.o coff-m68k.o cofflink.o" ;;
- m88kbcs_vec) tb="$tb coff-m88k.o" ;;
- newsos3_vec) tb="$tb newsos3.o aout32.o" ;;
- nlm32_i386_vec) tb="$tb nlm32-i386.o nlm32.o nlm.o" ;;
- nlm32_sparc_vec) tb="$tb nlm32-sparc.o nlm32.o nlm.o" ;;
- nlm32_alpha_vec) tb="$tb nlm32-alpha.o nlm32.o nlm.o"
- target64=true ;;
- riscix_vec) tb="$tb aout32.o riscix.o" ;;
- nlm32_powerpc_vec) tb="$tb nlm32-ppc.o nlm32.o nlm.o" ;;
- pc532netbsd_vec) tb="$tb ns32knetbsd.o aout-ns32k.o" ;;
- pc532machaout_vec) tb="$tb pc532-mach.o aout-ns32k.o" ;;
- pmac_xcoff_vec) tb="$tb coff-pmac.o xcofflink.o" ;;
- rs6000coff_vec) tb="$tb coff-rs6000.o xcofflink.o" ;;
- bfd_powerpc_pe_vec) tb="$tb pe-ppc.o cofflink.o" ;;
- bfd_powerpcle_pe_vec) tb="$tb pe-ppc.o cofflink.o" ;;
- bfd_powerpc_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;;
- bfd_powerpcle_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;;
- shcoff_vec) tb="$tb coff-sh.o cofflink.o" ;;
- shlcoff_vec) tb="$tb coff-sh.o cofflink.o" ;;
- som_vec) tb="$tb som.o" ;;
- sparclynx_aout_vec) tb="$tb sparclynx.o lynx-core.o aout32.o" ;;
- sparclynx_coff_vec) tb="$tb cf-sparclynx.o lynx-core.o" ;;
- sparcnetbsd_vec) tb="$tb sparcnetbsd.o aout32.o" ;;
- sparccoff_vec) tb="$tb coff-sparc.o" ;;
- srec_vec) tb="$tb srec.o" ;;
- sunos_big_vec) tb="$tb sunos.o aout32.o" ;;
- symbolsrec_vec) tb="$tb srec.o" ;;
- tekhex_vec) tb="$tb tekhex.o" ;;
- we32kcoff_vec) tb="$tb coff-we32k.o" ;;
- z8kcoff_vec) tb="$tb coff-z8k.o reloc16.o" ;;
- w65_vec) tb="$tb coff-w65.o reloc16.o" ;;
- versados_vec) tb="$tb versados.o" ;;
-
- "") ;;
- *) { echo "configure: error: *** unknown target vector $vec" 1>&2; exit 1; } ;;
- esac
-done
-
-# Target architecture .o files.
-ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.o/g`
-
-# Weed out duplicate .o files.
-f=""
-for i in $tb ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-tb="$f"
-
-f=""
-for i in $ta ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-ta="$f"
-
-bfd_backends="$tb"
-bfd_machines="$ta"
-
-if test x${all_targets} = xtrue ; then
- bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)'
- bfd_machines="${bfd_machines}"' $(ALL_MACHINES)'
- selvecs=
- selarchs=
-else # all_targets is true
- # Only set these if they will be nonempty, for the clever echo.
- test -n "$selvecs" &&
- selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
- test -n "$selarchs" &&
- selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
-fi # all_targets is true
-
-case ${host64}-${target64}-${want64} in
- *true*)
- wordsize=64
- all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)'
- ;;
- false-false-false)
- wordsize=32
- all_backends='$(BFD32_BACKENDS)'
- ;;
-esac
-
-
-
-
-
-
-tdefaults=""
-test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
-test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
-test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
-
-
-for ac_func in valloc getpagesize
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1928 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_mmap'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_func_mmap=no
-else
-cat > conftest.$ac_ext <<EOF
-#line 1980 "configure"
-#include "confdefs.h"
-
-/* Thanks to Mike Haertel and Jim Avera for this test. */
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#ifndef HAVE_GETPAGESIZE
-# include <sys/param.h>
-# ifdef EXEC_PAGESIZE
-# define getpagesize() EXEC_PAGESIZE
-# else
-# ifdef NBPG
-# define getpagesize() NBPG * CLSIZE
-# ifndef CLSIZE
-# define CLSIZE 1
-# endif
-# else
-# ifdef NBPC
-# define getpagesize() NBPC
-# else
-# define getpagesize() PAGESIZE /* SVR4 */
-# endif
-# endif
-# endif
-#endif
-
-#ifndef HAVE_VALLOC
-# define valloc malloc
-#endif
-
-#ifdef __cplusplus
-extern "C" { void *valloc(unsigned), *malloc(unsigned); }
-#else
-char *valloc(), *malloc();
-#endif
-
-int
-main()
-{
- char *buf1, *buf2, *buf3;
- int i = getpagesize(), j;
- int i2 = i * 2;
- int fd;
-
- buf1 = (char *)valloc(i2);
- buf2 = (char *)valloc(i);
- buf3 = (char *)malloc(i2);
- for (j = 0; j < i2; ++j)
- *(buf1 + j) = rand();
- fd = open("conftestmmap", O_CREAT | O_RDWR, 0666);
- write(fd, buf1, i2);
- mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0);
- for (j = 0; j < i; ++j)
- if (*(buf1 + j) != *(buf2 + j))
- exit(1);
- lseek(fd, (long)i, 0);
- read(fd, buf2, i); /* read into mapped memory -- file should not change */
- /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */
- lseek(fd, (long)0, 0);
- read(fd, buf3, i2);
- for (j = 0; j < i2; ++j)
- if (*(buf1 + j) != *(buf3 + j))
- exit(1);
- exit(0);
-}
-
-EOF
-{ (eval echo configure:2049: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_func_mmap=yes
-else
- ac_cv_func_mmap=no
-fi
-fi
-rm -fr conftest*
-fi
-
-echo "$ac_t""$ac_cv_func_mmap" 1>&6
-if test $ac_cv_func_mmap = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_MMAP 1
-EOF
-
-fi
-
-for ac_func in madvise mprotect
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2074 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-case ${want_mmap}+${ac_cv_func_mmap} in
- true+yes ) cat >> confdefs.h <<\EOF
-#define USE_MMAP 1
-EOF
- ;;
-esac
-
-rm -f doc/config.status
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
- sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \
- >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-DEFS=-DHAVE_CONFIG_H
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.8"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
-
-trap 'rm -fr `echo "Makefile doc/Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@host@%$host%g
-s%@host_alias@%$host_alias%g
-s%@host_cpu@%$host_cpu%g
-s%@host_vendor@%$host_vendor%g
-s%@host_os@%$host_os%g
-s%@target@%$target%g
-s%@target_alias@%$target_alias%g
-s%@target_cpu@%$target_cpu%g
-s%@target_vendor@%$target_vendor%g
-s%@target_os@%$target_os%g
-s%@build@%$build%g
-s%@build_alias@%$build_alias%g
-s%@build_cpu@%$build_cpu%g
-s%@build_vendor@%$build_vendor%g
-s%@build_os@%$build_os%g
-s%@CC@%$CC%g
-s%@HDEFINES@%$HDEFINES%g
-s%@AR@%$AR%g
-s%@RANLIB@%$RANLIB%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@ALLLIBS@%$ALLLIBS%g
-s%@PICFLAG@%$PICFLAG%g
-s%@SHLIB@%$SHLIB%g
-s%@SHLIB_CC@%$SHLIB_CC%g
-s%@SHLIB_CFLAGS@%$SHLIB_CFLAGS%g
-s%@COMMON_SHLIB@%$COMMON_SHLIB%g
-s%@PICLIST@%$PICLIST%g
-s%@SHLINK@%$SHLINK%g
-s%@HOST_64BIT_LONG@%$HOST_64BIT_LONG%g
-s%@CC_FOR_BUILD@%$CC_FOR_BUILD%g
-s%@CPP@%$CPP%g
-s%@COREFILE@%$COREFILE%g
-s%@COREFLAG@%$COREFLAG%g
-s%@TDEFINES@%$TDEFINES%g
-s%@wordsize@%$wordsize%g
-s%@all_backends@%$all_backends%g
-s%@bfd_backends@%$bfd_backends%g
-s%@bfd_machines@%$bfd_machines%g
-s%@tdefaults@%$tdefaults%g
-
-CEOF
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile doc/Makefile"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust relative srcdir, etc. for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
- case "$ac_given_INSTALL" in
- [/$]*) INSTALL="$ac_given_INSTALL" ;;
- *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
- esac
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
-" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file
-fi; done
-rm -f conftest.subs
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='\([ ]\)%\1#\2define\3'
-ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-
-CONFIG_HEADERS=${CONFIG_HEADERS-"config.h:config.in"}
-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- echo creating $ac_file
-
- rm -f conftest.frag conftest.in conftest.out
- cp $ac_given_srcdir/$ac_file_in conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h. And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >> conftest.vals <<\EOF
-s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
-EOF
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
-# Maximum number of lines to put in a single here document.
-ac_max_here_lines=12
-
-rm -f conftest.tail
-while :
-do
- ac_lines=`grep -c . conftest.vals`
- # grep -c gives empty output for an empty file on some AIX systems.
- if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
- # Write a limited-size here document to conftest.frag.
- echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
- echo 'CEOF
- sed -f conftest.frag conftest.in > conftest.out
- rm -f conftest.in
- mv conftest.out conftest.in
-' >> $CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
- rm -f conftest.vals
- mv conftest.tail conftest.vals
-done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
- rm -f conftest.frag conftest.h
- echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
- cat conftest.in >> conftest.h
- rm -f conftest.in
- if cmp -s $ac_file conftest.h 2>/dev/null; then
- echo "$ac_file is unchanged"
- rm -f conftest.h
- else
- rm -f $ac_file
- mv conftest.h $ac_file
- fi
-fi; done
-
-
-case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
diff --git a/contrib/gdb/bfd/configure.bat b/contrib/gdb/bfd/configure.bat
deleted file mode 100644
index 78fe79e91123..000000000000
--- 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/configure.host b/contrib/gdb/bfd/configure.host
deleted file mode 100644
index 484e5bda90eb..000000000000
--- a/contrib/gdb/bfd/configure.host
+++ /dev/null
@@ -1,128 +0,0 @@
-# This file is a shell script that overrides some of the tools and
-# flags used on a host specific basis.
-
-# Since the "bfd/hosts" directory is shared by the bfd, opcodes, and
-# binutils directories (at least), the index to it is also shared.
-# This is that index. Each configure.in file should source this file
-# in its per-host part.
-
-# This sets the following shell variables:
-# HDEFINES host specific compiler options
-# host64 set to true if this is a 64 bit host
-# HOST_64BIT_TYPE host 64 bit type
-# SHLIB_CC compiler to use when building shared library
-# SHLIB_CFLAGS flags to use when building shared library
-# PICFLAG may be set to flag to use to compile PIC
-# SHLINK may be set to the name to link the shared library to
-# ALLLIBS may be set to libraries to build
-# HLDFLAGS LDFLAGS specific to the host
-# RPATH_ENVVAR environment variable used to find shared libraries
-
-HDEFINES=
-host64=false
-HOST_64BIT_TYPE=
-
-case "${host}" in
-
-alpha-*-*) host64=true; HOST_64BIT_TYPE=long ;;
-
-hppa*-*-hpux*) HDEFINES=-DHOST_HPPAHPUX ;;
-hppa*-*-hiux*) HDEFINES=-DHOST_HPPAHPUX ;;
-hppa*-*-bsd*) HDEFINES=-DHOST_HPPABSD ;;
-hppa*-*-osf*) HDEFINES=-DHOST_HPPAOSF ;;
-
-i[345]86-sequent-bsd*) HDEFINES=-Dshared=genshared ;;
-i[345]86-sequent-sysv4*) ;;
-i[345]86-sequent-sysv*) HDEFINES=-Dshared=genshared ;;
-
-mips-dec-netbsd*) ;;
-mips-dec-*) HDEFINES="-G 4" ;;
-mips-sgi-irix3*) HDEFINES="-G 4" ;;
-mips-sgi-irix4*) HDEFINES="-G 4" ;;
-mips-*-sysv4*) ;;
-mips-*-sysv*) HDEFINES="-G 4" ;;
-mips-*-riscos*) HDEFINES="-G 4" ;;
-
-m68*-hp-hpux*) HDEFINES=-DHOST_HP300HPUX ;;
-
-esac
-
-# If we are configuring with --enable-shared, adjust the shared
-# library support based on the host. This support must work for both
-# the BFD and the opcodes libraries.
-HLDFLAGS=
-RPATH_ENVVAR=LD_LIBRARY_PATH
-SHLIB_CC='$(CC)'
-SHLIB_CFLAGS='-shared'
-if [ "${shared}" = "true" ]; then
- case "${host}" in
- hppa*-*-*) picfrag=../config/mh-papic ;;
- i[3456]86-*-*) picfrag=../config/mh-x86pic ;;
- *-*-*) picfrag=../config/mh-${host_cpu}pic ;;
- esac
- if [ -f "${picfrag}" ]; then
- pic=`sed -n -e 's/^PICFLAG[ ]*=[ ]*\(.*\)$/\1/p' ${picfrag}`
- if [ -n "${pic}" ]; then
- PICFLAG=${pic}
- fi
- fi
-
- case "${host}" in
- *-dec-osf*)
- # -fpic is not needed on the Alpha.
- PICFLAG=
- ;;
- *-*-hpux*)
- # HP/UX uses .sl for shared libraries.
- SHLINK=`echo ${SHLINK} | sed -e 's/so$/sl/'`
- SHLIB_CFLAGS='-shared $(PICFLAG)'
- HLDFLAGS='-Wl,+s,+b,$(libdir)'
- RPATH_ENVVAR=SHLIB_PATH
- ;;
- *-*-irix5*)
- # -fpic is not needed on Irix 5.
- PICFLAG=
- SHLIB_CFLAGS='-shared -Wl,-soname,$(SONAME)'
- HLDFLAGS='-Wl,-rpath,$(libdir)'
- ;;
- *-*-linux*aout*)
- ;;
- *-*-linux*)
- SHLIB_CFLAGS='-shared -Wl,-soname,$(SONAME)'
- case "$(libdir)" in
- /lib | /usr/lib) ;;
- *) HLDFLAGS='-Wl,-rpath,$(libdir)' ;;
- esac
- ;;
- *-*-sysv4* | *-*-solaris*)
- SHLIB_CFLAGS='-shared -h $(SONAME)'
- HLDFLAGS='-R $(libdir)'
- ;;
- *-*-sunos*)
- # Build a libTARGET-bfd.so.VERSION symlink in the object directory.
- ALLLIBS=`echo ${ALLLIBS} | sed -e 's/\$(SHLINK)/stamp-tshlink/'`
- ;;
- esac
-fi
-
-# On SunOS, if the linker supports the -rpath option, use it to
-# prevent ../bfd and ../opcodes from being included in the run time
-# search path.
-case "${host}" in
- *-*-sunos*)
- echo 'main () { }' > conftest.c
- ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
- if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
- :
- elif grep 'No such file' conftest.t >/dev/null 2>&1; then
- :
- elif grep 'do not mix' conftest.t >/dev/null 2>&1; then
- :
- elif [ "${shared}" = "true" ]; then
- HLDFLAGS='-Wl,-rpath=$(libdir)'
- else
- HLDFLAGS='-Wl,-rpath='
- fi
- rm -f conftest.t conftest.c conftest
- ;;
-esac
diff --git a/contrib/gdb/bfd/configure.in b/contrib/gdb/bfd/configure.in
deleted file mode 100644
index c8b8de54fe92..000000000000
--- a/contrib/gdb/bfd/configure.in
+++ /dev/null
@@ -1,577 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-dnl
-AC_PREREQ(2.3)
-AC_INIT(libbfd.c)
-
-AC_ARG_ENABLE(64-bit-bfd,
-[ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)],
-[case "${enableval}" in
- yes) want64=true ;;
- no) want64=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
-esac],[want64=false])dnl
-AC_ARG_ENABLE(targets,
-[ --enable-targets alternative target configurations],
-[case "${enableval}" in
- yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
- ;;
- no) enable_targets= ;;
- *) enable_targets=$enableval ;;
-esac])dnl
-AC_ARG_ENABLE(shared,
-[ --enable-shared build shared BFD library],
-[case "${enableval}" in
- yes) shared=true ;;
- no) shared=false ;;
- *) AC_MSG_ERROR([bad value ${enableval} for BFD shared option]) ;;
-esac])dnl
-AC_ARG_ENABLE(commonbfdlib,
-[ --enable-commonbfdlib build shared BFD/opcodes/libiberty library],
-[case "${enableval}" in
- yes) commonbfdlib=true ;;
- no) commonbfdlib=false ;;
- *) AC_MSG_ERROR([bad value ${enableval} for BFD commonbfdlib option]) ;;
-esac])dnl
-AC_ARG_WITH(mmap,
-[ --with-mmap try using mmap for BFD input files if available],
-[case "${withval}" in
- yes) want_mmap=true ;;
- no) want_mmap=false ;;
- *) AC_MSG_ERROR(bad value ${withval} for BFD with-mmap option) ;;
-esac],[want_mmap=false])dnl
-
-AC_CONFIG_HEADER(config.h:config.in)
-
-AC_CONFIG_AUX_DIR(`cd $srcdir/..;pwd`)
-AC_CANONICAL_SYSTEM
-if test -z "$target" ; then
- AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
-fi
-AC_ARG_PROGRAM
-
-host64=false
-target64=false
-
-# host stuff:
-
-ALLLIBS='$(TARGETLIB)'
-PICFLAG=
-SHLIB=unused-shlib
-SHLINK=unused-shlink
-if test "${shared}" = "true"; then
- PICFLAG=-fpic
- if test "${commonbfdlib}" = "true"; then
- ALLLIBS='$(TARGETLIB)'
- else
- ALLLIBS='$(TARGETLIB) $(SHLIB) $(SHLINK)'
-changequote(,)dnl
- SHLIB=libbfd.so.`sed -e 's/[^0-9]*\([0-9.]*\).*/\1/' ${srcdir}/VERSION`
-changequote([,])dnl
- SHLINK=libbfd.so
- fi
-fi
-
-AC_PROG_CC
-
-# Permit host specific settings.
-. ${srcdir}/configure.host
-
-AC_SUBST(HDEFINES)
-AC_CHECK_TOOL(AR, ar)
-AC_CHECK_TOOL(RANLIB, ranlib, :)
-AC_PROG_INSTALL
-
-if test "${shared}" = "true"; then
- if test "${GCC}" != "yes" && test "${shared_non_gcc}" != "yes"; then
- AC_MSG_WARN([BFD --enable-shared only supported when using gcc])
- shared=false
- ALLLIBS='$(TARGETLIB)'
- PICFLAG=
- SHLIB=unused-shlib
- fi
-fi
-
-AC_SUBST(ALLLIBS)
-AC_SUBST(PICFLAG)
-AC_SUBST(SHLIB)
-AC_SUBST(SHLIB_CC)
-AC_SUBST(SHLIB_CFLAGS)
-if test "${commonbfdlib}" = "true"; then
- COMMON_SHLIB=yes
- PICLIST=piclist
-else
- COMMON_SHLIB=
- PICLIST=
-fi
-AC_SUBST(COMMON_SHLIB)
-AC_SUBST(PICLIST)
-AC_SUBST(SHLINK)
-
-HOST_64BIT_LONG=0
-if test "x${HOST_64BIT_TYPE}" = "xlong"; then
- HOST_64BIT_LONG=1
-fi
-AC_SUBST(HOST_64BIT_LONG)
-
-BFD_CC_FOR_BUILD
-
-AC_CHECK_HEADERS(stddef.h string.h strings.h stdlib.h time.h unistd.h)
-AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h)
-AC_HEADER_TIME
-AC_CHECK_FUNCS(fcntl getpagesize)
-
-BFD_BINARY_FOPEN
-
-BFD_NEED_DECLARATION(malloc)
-BFD_NEED_DECLARATION(free)
-
-# If we are configured native, pick a core file support file.
-COREFILE=
-COREFLAG=
-if test "${target}" = "${host}"; then
- case "${host}" in
- alpha*-*-linux*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/alphalinux.h")
- ;;
- alpha*-*-*) COREFILE=osf-core.o ;;
- arm-*-riscix) COREFILE=trad-core.o ;;
- hppa*-*-hpux*) COREFILE=hpux-core.o ;;
- hppa*-*-hiux*) COREFILE=hpux-core.o ;;
- hppa*-*-bsd*) COREFILE="hpux-core.o hppabsd-core.o"
- COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;;
-changequote(,)dnl
- i[345]86-sequent-bsd*)
-changequote([,])dnl
- COREFILE=trad-core.o;
- AC_DEFINE(TRAD_HEADER,"hosts/symmetry.h")
- ;;
-changequote(,)dnl
- i[345]86-sequent-sysv4*) ;;
- i[345]86-sequent-sysv*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/symmetry.h")
- ;;
-changequote(,)dnl
- i[345]86-*-bsd* | i[345]86-*-freebsd*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i386bsd.h")
- ;;
-changequote(,)dnl
- i[345]86-*-netbsd*)
-changequote([,])dnl
- COREFILE=netbsd-core.o
- ;;
-changequote(,)dnl
- i[345]86-esix-sysv3*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/esix.h")
- ;;
-changequote(,)dnl
- i[345]86-*-sco* | i[345]86-*-isc*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i386sco.h")
- ;;
-changequote(,)dnl
- i[345]86-*-mach3*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i386mach3.h")
- ;;
-changequote(,)dnl
- i[345]86-*-linux*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i386linux.h")
- ;;
-changequote(,)dnl
- i[345]86-*-isc*) COREFILE=trad-core.o ;;
- i[345]86-*-aix*) COREFILE=aix386-core.o ;;
-changequote([,])dnl
- i860-*-mach3* | i860-*-osf1*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i860mach3.h")
- ;;
- mips-dec-bsd*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/mipsbsd.h")
- ;;
- mips-dec-mach3*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/mipsmach3.h")
- ;;
- mips-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- mips-dec-*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/decstation.h")
- ;;
- mips-sgi-irix4*) COREFILE=irix-core.o ;;
- mips-sgi-irix5*) COREFILE=irix-core.o ;;
- mips-*-mach3*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/mipsmach3.h")
- ;;
- mips-*-sysv4*) ;;
- mips-*-sysv* | mips-*-riscos*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/riscos.h")
- ;;
- mips-sony-bsd*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/news-mips.h")
- ;;
- m68*-bull*-sysv*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/dpx2.h")
- ;;
- m68*-hp-hpux*) COREFILE=hpux-core.o ;;
- m68*-hp-bsd*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/hp300bsd.h")
- ;;
- m68*-*-linux*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/m68klinux.h")
- ;;
- m68*-motorola-sysv*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER, "hosts/delta68.h")
- ;;
- m68*-sony-*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/news.h")
- ;;
- m68*-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- m68*-apple-aux*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/m68kaux.h")
- ;;
- m88*-*-sysv4*) ;;
- m88*-motorola-sysv*) COREFILE=ptrace-core.o ;;
- m88*-*-mach3*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/m88kmach3.h")
- ;;
- ns32k-pc532-mach)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/pc532mach.h")
- ;;
- ns32k-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- rs6000-*-lynx*) COREFILE=lynx-core.o ;;
- rs6000-*-aix4*) COREFILE=rs6000-core.o ;;
- rs6000-*-*) COREFILE=rs6000-core.o ;;
- powerpc-*-aix4*) COREFILE=rs6000-core.o ;;
- powerpc-*-aix*) COREFILE=rs6000-core.o ;;
- sparc-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- tahoe-*-*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/tahoe.h")
- ;;
- vax-*-ultrix2*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/vaxult2.h")
- ;;
- vax-*-ultrix*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/vaxult2.h")
- ;;
- vax-*-*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/vaxbsd.h")
- ;;
- esac
-
- case "$COREFILE" in
- aix386-core.o) COREFLAG=-DAIX386_CORE ;;
- hppabsd-core.o) COREFLAG=-DHPPABSD_CORE ;;
- hpux-core.o) COREFLAG=-DHPUX_CORE ;;
- irix-core.o) COREFLAG=-DIRIX_CORE ;;
- lynx-core.o) COREFLAG=-DLYNX_CORE ;;
- osf-core.o) COREFLAG=-DOSF_CORE ;;
- ptrace-core.o) COREFLAG=-DPTRACE_CORE ;;
- rs6000-core.o) COREFLAG="$COREFLAG -DAIX_CORE" ;;
- trad-core.o) COREFLAG="$COREFLAG -DTRAD_CORE" ;;
- esac
-
- # The ELF code uses the native <sys/procfs.h> to handle core files.
- # Define HAVE_SYS_PROCFS_H if the file exists and defines
- # prstatus_t.
- AC_MSG_CHECKING([for sys/procfs.h])
- AC_CACHE_VAL(bfd_cv_header_sys_procfs_h,
- [AC_TRY_COMPILE([#include <sys/procfs.h>],
- [prstatus_t t;],
- bfd_cv_header_sys_procfs_h=yes, bfd_cv_header_sys_procfs_h=no)])
- AC_MSG_RESULT($bfd_cv_header_sys_procfs_h)
- if test $bfd_cv_header_sys_procfs_h = yes; then
- AC_DEFINE(HAVE_SYS_PROCFS_H)
- fi
-
-fi
-AC_SUBST(COREFILE)
-AC_SUBST(COREFLAG)
-
-# target stuff:
-
-# Canonicalize the secondary target names.
-if test -n "$enable_targets" ; then
- for targ in `echo $enable_targets | sed 's/,/ /g'`
- do
- result=`$ac_config_sub $targ 2>/dev/null`
- if test -n "$result" ; then
- canon_targets="$canon_targets $result"
- else
- # Allow targets that config.sub doesn't recognize, like "all".
- canon_targets="$canon_targets $targ"
- fi
- done
-fi
-
-all_targets=false
-defvec=
-selvecs=
-selarchs=
-TDEFINES=
-for targ in $target $canon_targets
-do
- if test "x$targ" = "xall"; then
- all_targets=true
- else
- . $srcdir/config.bfd
- if test "x$targ" = "x$target"; then
- defvec=$targ_defvec
- fi
- selvecs="$selvecs $targ_defvec $targ_selvecs"
- selarchs="$selarchs $targ_archs"
- TDEFINES="$TDEFINES $targ_cflags"
- fi
-done
-AC_SUBST(TDEFINES)
-
-# This processing still needs to be done if we're to decide properly whether
-# 64-bit support needs to be compiled in. Currently, it will be included if
-# the default or any other explicitly requested target requires it; it
-# will not be included on a 32-bit host if no 64-bit target is requested, and
-# no "--with-64-bit-bfd" option is given, even if "--with-targets=all" is
-# used.
-
-# uniq the default and selected vectors in all the configured targets.
-f=""
-for i in $selvecs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-selvecs="$f"
-
-# uniq the architectures in all the configured targets.
-f=""
-for i in $selarchs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-selarchs="$f"
-
-# Target backend .o files.
-tb=
-
-elf="elf.o elflink.o"
-
-for vec in $selvecs
-do
- case "$vec" in
- # This list is alphabetized to make it easy to compare
- # with the two vector lists in targets.c.
- a29kcoff_big_vec) tb="$tb coff-a29k.o cofflink.o" ;;
- a_out_adobe_vec) tb="$tb aout-adobe.o aout32.o" ;;
- armcoff_little_vec) tb="$tb coff-arm.o cofflink.o " ;;
- armcoff_big_vec) tb="$tb coff-arm.o cofflink.o " ;;
- armpe_little_vec) tb="$tb pe-arm.o cofflink.o " ;;
- armpe_big_vec) tb="$tb pe-arm.o cofflink.o " ;;
- armpei_little_vec) tb="$tb pei-arm.o cofflink.o " ;;
- armpei_big_vec) tb="$tb pei-arm.o cofflink.o " ;;
- aout0_big_vec) tb="$tb aout0.o aout32.o" ;;
- aout_arm_big_vec) tb="$tb aout-arm.o aout32.o" ;;
- aout_arm_little_vec) tb="$tb aout-arm.o aout32.o" ;;
- aout_mips_big_vec) tb="$tb mipsbsd.o aout32.o" ;;
- aout_mips_little_vec) tb="$tb mipsbsd.o aout32.o" ;;
- apollocoff_vec) tb="$tb coff-apollo.o" ;;
- b_out_vec_big_host) tb="$tb bout.o aout32.o" ;;
- b_out_vec_little_host) tb="$tb bout.o aout32.o" ;;
- bfd_elf32_big_generic_vec) tb="$tb elf32-gen.o elf32.o $elf" ;;
- bfd_elf32_bigmips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;;
- bfd_elf32_hppa_vec) tb="$tb elf32-hppa.o elf32.o $elf" ;;
- bfd_elf32_i386_vec) tb="$tb elf32-i386.o elf32.o $elf" ;;
- bfd_elf32_i860_vec) tb="$tb elf32-i860.o elf32.o $elf" ;;
- bfd_elf32_little_generic_vec) tb="$tb elf32-gen.o elf32.o $elf" ;;
- bfd_elf32_littlemips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;;
- bfd_elf32_m68k_vec) tb="$tb elf32-m68k.o elf32.o $elf" ;;
- bfd_elf32_m88k_vec) tb="$tb elf32-m88k.o elf32.o $elf" ;;
- bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;;
- bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;;
- bfd_elf32_sparc_vec) tb="$tb elf32-sparc.o elf32.o $elf" ;;
- bfd_elf64_big_generic_vec) tb="$tb elf64-gen.o elf64.o $elf"
- target64=true ;;
- bfd_elf64_little_generic_vec) tb="$tb elf64-gen.o elf64.o $elf"
- target64=true ;;
- bfd_elf64_sparc_vec) tb="$tb elf64-sparc.o elf64.o $elf"
- target64=true ;;
- cisco_core_vec) tb="$tb cisco-core.o" ;;
- demo_64_vec) tb="$tb demo64.o aout64.o"
- target64=true ;;
- ecoff_big_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
- ecoff_little_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
- ecoffalpha_little_vec) tb="$tb coff-alpha.o ecoff.o ecofflink.o"
- target64=true ;;
- h8300coff_vec) tb="$tb coff-h8300.o reloc16.o" ;;
- h8500coff_vec) tb="$tb coff-h8500.o reloc16.o" ;;
- host_aout_vec) tb="$tb host-aout.o aout32.o" ;;
- hp300bsd_vec) tb="$tb hp300bsd.o aout32.o" ;;
- hp300hpux_vec) tb="$tb hp300hpux.o aout32.o" ;;
- i386aout_vec) tb="$tb i386aout.o aout32.o" ;;
- i386bsd_vec) tb="$tb i386bsd.o aout32.o" ;;
- i386coff_vec) tb="$tb coff-i386.o cofflink.o" ;;
- i386dynix_vec) tb="$tb i386dynix.o aout32.o" ;;
- i386freebsd_vec) tb="$tb i386freebsd.o aout32.o" ;;
- i386msdos_vec) tb="$tb i386msdos.o" ;;
- i386pe_vec) tb="$tb pe-i386.o cofflink.o " ;;
- i386pei_vec) tb="$tb pei-i386.o cofflink.o" ;;
- i386linux_vec) tb="$tb i386linux.o aout32.o" ;;
- i386lynx_aout_vec) tb="$tb i386lynx.o lynx-core.o aout32.o" ;;
- i386lynx_coff_vec) tb="$tb cf-i386lynx.o cofflink.o lynx-core.o" ;;
- i386mach3_vec) tb="$tb i386mach3.o aout32.o" ;;
- i386netbsd_vec) tb="$tb i386netbsd.o aout32.o" ;;
- i386os9k_vec) tb="$tb i386os9k.o aout32.o" ;;
- i860coff_vec) tb="$tb coff-i860.o cofflink.o" ;;
- icoff_big_vec) tb="$tb coff-i960.o cofflink.o" ;;
- icoff_little_vec) tb="$tb coff-i960.o cofflink.o" ;;
- ieee_vec) tb="$tb ieee.o" ;;
- m68kcoff_vec) tb="$tb coff-m68k.o cofflink.o" ;;
- m68kcoffun_vec) tb="$tb coff-u68k.o coff-m68k.o cofflink.o" ;;
- m68klinux_vec) tb="$tb m68klinux.o aout32.o" ;;
- m68klynx_aout_vec) tb="$tb m68klynx.o lynx-core.o aout32.o" ;;
- m68klynx_coff_vec) tb="$tb cf-m68klynx.o coff-m68k.o cofflink.o lynx-core.o" ;;
- m68knetbsd_vec) tb="$tb m68knetbsd.o aout32.o" ;;
- m68k4knetbsd_vec) tb="$tb m68k4knetbsd.o aout32.o" ;;
- m68kaux_coff_vec) tb="$tb coff-aux.o coff-m68k.o cofflink.o" ;;
- m88kbcs_vec) tb="$tb coff-m88k.o" ;;
- newsos3_vec) tb="$tb newsos3.o aout32.o" ;;
- nlm32_i386_vec) tb="$tb nlm32-i386.o nlm32.o nlm.o" ;;
- nlm32_sparc_vec) tb="$tb nlm32-sparc.o nlm32.o nlm.o" ;;
- nlm32_alpha_vec) tb="$tb nlm32-alpha.o nlm32.o nlm.o"
- target64=true ;;
- riscix_vec) tb="$tb aout32.o riscix.o" ;;
- nlm32_powerpc_vec) tb="$tb nlm32-ppc.o nlm32.o nlm.o" ;;
- pc532netbsd_vec) tb="$tb ns32knetbsd.o aout-ns32k.o" ;;
- pc532machaout_vec) tb="$tb pc532-mach.o aout-ns32k.o" ;;
- pmac_xcoff_vec) tb="$tb coff-pmac.o xcofflink.o" ;;
- rs6000coff_vec) tb="$tb coff-rs6000.o xcofflink.o" ;;
- bfd_powerpc_pe_vec) tb="$tb pe-ppc.o cofflink.o" ;;
- bfd_powerpcle_pe_vec) tb="$tb pe-ppc.o cofflink.o" ;;
- bfd_powerpc_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;;
- bfd_powerpcle_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;;
- shcoff_vec) tb="$tb coff-sh.o cofflink.o" ;;
- shlcoff_vec) tb="$tb coff-sh.o cofflink.o" ;;
- som_vec) tb="$tb som.o" ;;
- sparclynx_aout_vec) tb="$tb sparclynx.o lynx-core.o aout32.o" ;;
- sparclynx_coff_vec) tb="$tb cf-sparclynx.o lynx-core.o" ;;
- sparcnetbsd_vec) tb="$tb sparcnetbsd.o aout32.o" ;;
- sparccoff_vec) tb="$tb coff-sparc.o" ;;
- srec_vec) tb="$tb srec.o" ;;
- sunos_big_vec) tb="$tb sunos.o aout32.o" ;;
- symbolsrec_vec) tb="$tb srec.o" ;;
- tekhex_vec) tb="$tb tekhex.o" ;;
- we32kcoff_vec) tb="$tb coff-we32k.o" ;;
- z8kcoff_vec) tb="$tb coff-z8k.o reloc16.o" ;;
- w65_vec) tb="$tb coff-w65.o reloc16.o" ;;
- versados_vec) tb="$tb versados.o" ;;
-
- "") ;;
- *) AC_MSG_ERROR(*** unknown target vector $vec) ;;
- esac
-done
-
-# Target architecture .o files.
-ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.o/g`
-
-# Weed out duplicate .o files.
-f=""
-for i in $tb ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-tb="$f"
-
-f=""
-for i in $ta ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-ta="$f"
-
-bfd_backends="$tb"
-bfd_machines="$ta"
-
-if test x${all_targets} = xtrue ; then
- bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)'
- bfd_machines="${bfd_machines}"' $(ALL_MACHINES)'
- selvecs=
- selarchs=
-else # all_targets is true
- # Only set these if they will be nonempty, for the clever echo.
- test -n "$selvecs" &&
- selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
- test -n "$selarchs" &&
- selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
-fi # all_targets is true
-
-case ${host64}-${target64}-${want64} in
- *true*)
- wordsize=64
- all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)'
- ;;
- false-false-false)
- wordsize=32
- all_backends='$(BFD32_BACKENDS)'
- ;;
-esac
-
-AC_SUBST(wordsize)
-AC_SUBST(all_backends)
-AC_SUBST(bfd_backends)
-AC_SUBST(bfd_machines)
-
-tdefaults=""
-test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
-test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
-test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
-AC_SUBST(tdefaults)
-
-dnl AC_CHECK_HEADERS(sys/mman.h)
-AC_FUNC_MMAP
-AC_CHECK_FUNCS(madvise mprotect)
-case ${want_mmap}+${ac_cv_func_mmap} in
- true+yes ) AC_DEFINE(USE_MMAP) ;;
-esac
-
-rm -f doc/config.status
-AC_OUTPUT(Makefile doc/Makefile,
-[case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac])
diff --git a/contrib/gdb/bfd/corefile.c b/contrib/gdb/bfd/corefile.c
deleted file mode 100644
index 212f519ce8a5..000000000000
--- a/contrib/gdb/bfd/corefile.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Core file generic interface routines for BFD.
- 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. */
-
-/*
-SECTION
- Core files
-
-DESCRIPTION
- These are functions pertaining to core files.
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-
-/*
-FUNCTION
- bfd_core_file_failing_command
-
-SYNOPSIS
- CONST char *bfd_core_file_failing_command(bfd *abfd);
-
-DESCRIPTION
- Return a read-only string explaining which program was running
- when it failed and produced the core file @var{abfd}.
-
-*/
-
-CONST char *
-bfd_core_file_failing_command (abfd)
- bfd *abfd;
-{
- if (abfd->format != bfd_core) {
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
- }
- return BFD_SEND (abfd, _core_file_failing_command, (abfd));
-}
-
-/*
-FUNCTION
- bfd_core_file_failing_signal
-
-SYNOPSIS
- int bfd_core_file_failing_signal(bfd *abfd);
-
-DESCRIPTION
- Returns the signal number which caused the core dump which
- generated the file the BFD @var{abfd} is attached to.
-*/
-
-int
-bfd_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- if (abfd->format != bfd_core) {
- bfd_set_error (bfd_error_invalid_operation);
- return 0;
- }
- return BFD_SEND (abfd, _core_file_failing_signal, (abfd));
-}
-
-
-/*
-FUNCTION
- core_file_matches_executable_p
-
-SYNOPSIS
- boolean core_file_matches_executable_p
- (bfd *core_bfd, bfd *exec_bfd);
-
-DESCRIPTION
- Return <<true>> if the core file attached to @var{core_bfd}
- was generated by a run of the executable file attached to
- @var{exec_bfd}, <<false>> otherwise.
-*/
-boolean
-core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- if ((core_bfd->format != bfd_core) || (exec_bfd->format != bfd_object)) {
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- return BFD_SEND (core_bfd, _core_file_matches_executable_p,
- (core_bfd, exec_bfd));
-}
diff --git a/contrib/gdb/bfd/cpu-a29k.c b/contrib/gdb/bfd/cpu-a29k.c
deleted file mode 100644
index 5bd25a47720b..000000000000
--- 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 0d66a8b74e80..000000000000
--- 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 92103e632f0e..000000000000
--- 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 380dfb5556e9..000000000000
--- 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 e4abfd178070..000000000000
--- 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 5201008dfe1c..000000000000
--- 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-i386.c b/contrib/gdb/bfd/cpu-i386.c
deleted file mode 100644
index 404109033b7f..000000000000
--- a/contrib/gdb/bfd/cpu-i386.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BFD support for the Intel 386 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_i386_arch =
- {
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_i386,
- 0, /* only 1 machine */
- "i386",
- "i386",
- 3,
- true, /* the one and only */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- };
diff --git a/contrib/gdb/bfd/cpu-i860.c b/contrib/gdb/bfd/cpu-i860.c
deleted file mode 100644
index 57c867cdb2cb..000000000000
--- 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 6970f89fca5c..000000000000
--- 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 17a373916756..000000000000
--- 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 c3716c5a394c..000000000000
--- 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 5e1934210a29..000000000000
--- 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 e18e3cfc9ba1..000000000000
--- 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 11f0f80af5ab..000000000000
--- 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 9852ae9a0536..000000000000
--- 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 7f6dd68ba04a..000000000000
--- 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 e48aa5e7f2b3..000000000000
--- 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 bdc6d39e451f..000000000000
--- 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 c0bbf045219c..000000000000
--- 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 a38cbc1268b4..000000000000
--- 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 5cce8eb0689b..000000000000
--- 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 c91381d46e93..000000000000
--- 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/dep-in.sed b/contrib/gdb/bfd/dep-in.sed
deleted file mode 100644
index 1cbd786fb2ee..000000000000
--- a/contrib/gdb/bfd/dep-in.sed
+++ /dev/null
@@ -1,24 +0,0 @@
-:loop
-/\\$/N
-/\\$/b loop
-
-s! @BFD_H@!!g
-s!@INCDIR@!$(INCDIR)!g
-s!@SRCDIR@/!!g
-s!hosts/[^ ]*\.h ! !g
-s/ sysdep.h//g
-s/ libbfd.h//g
-s/ config.h//g
-s! \$(INCDIR)/fopen-[^ ]*\.h!!g
-s! \$(INCDIR)/ansidecl\.h!!g
-s! \$(INCDIR)/obstack\.h!!g
-
-s/\\\n */ /g
-
-s/ *$//
-s/ */ /g
-s/ *:/:/g
-/:$/d
-
-s/\(.\{50\}[^ ]*\) /\1 \\\
- /g
diff --git a/contrib/gdb/bfd/doc/ChangeLog b/contrib/gdb/bfd/doc/ChangeLog
deleted file mode 100644
index f076e3777b56..000000000000
--- a/contrib/gdb/bfd/doc/ChangeLog
+++ /dev/null
@@ -1,268 +0,0 @@
-Tue Jan 30 14:10:46 1996 Ian Lance Taylor <ian@cygnus.com>
-
- From Ronald F. Guilmette <rfg@monkeys.com>:
- * Makefile.in (libbfd.h): Depend upon proto.str.
- (libcoff.h, bfd.h): Likewise.
-
-Fri Nov 3 14:46:48 1995 Fred Fish <fnf@cygnus.com>
-
- * Makefile.in (SRCDOC, SRCPROT, core.texi, bfd.h): Use corefile.c,
- renamed from core.c.
-
-Wed Nov 1 14:28:23 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de>
-
- * chew.c: Include <ctype.h>.
-
-Fri Oct 6 16:23:34 1995 Ken Raeburn <raeburn@cygnus.com>
-
- Mon Sep 25 22:49:32 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
-
- * Makefile.in (Makefile): Only remake this Makefile.
-
-Wed Oct 4 15:51:05 1995 Ken Raeburn <raeburn@cygnus.com>
-
- * chew.c: Include <stdio.h>.
-
-Tue Sep 12 18:14:50 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (maintainer-clean): New target.
-
-Thu Aug 31 12:18:43 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (bfd.h): Add additional #endif at end of bfd.h if
- __cplusplus is defined.
-
-Tue Nov 29 16:13:34 1994 Doug Evans <dje@canuck.cygnus.com>
-
- * chew.c (write_buffer): New argument `f', all callers changed.
- (stdout, stderr, print, drop, idrop): New forth words.
- * proto.str (COMMENT): New command.
- * doc.str (COMMENT): Likewise.
-
-Mon Sep 12 11:44:17 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * Makefile.in (DOCFILES): Remove ctor.texi.
- (IPROTOS): Remove ctor.ip.
- (SRCIPROT): Remove $(srcdir)/../ctor.c.
- (ctor.texi): Remove target.
- (libbfd.h): Remove dependency on $(srcdir)/../ctor.c. Remove
- $(MKDOC) run on $(srcdir)/../ctor.c.
- * bfd.texinfo (Constructors): Remove section.
-
-Fri Sep 2 13:33:44 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * chew.c: Include assert.h. Added prototypes for most functions.
- Changed most uses of int to long. Do bounds checking on the
- stacks. Added comment at the beginning documenting most of the
- intrinsics. Lots of whitespace changes. Re-ordered some
- functions.
- (die, check_range, icheck_range): New functions.
- (strip_trailing_newlines, print_stack_level): New functions.
- (translatecomments): Don't insert tab before "/*".
- (iscommand): Minimum command length is now 4.
- (nextword): Handle some \-sequences.
- (push_addr): Deleted.
- (main): Add new intrinsics strip_trailing_newlines and
- print_stack_level. Complain at end if stack contains more than
- one element, or less.
- (remchar): Make sure the string is not empty before chopping off a
- character.
-
- * doc.str, proto.str: Handle new commands SENUM, ENUM, ENUMX,
- ENUMEQ, ENUMEQX, ENUMDOC.
-
-Wed Jan 12 18:37:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * bfd.texinfo: Added Linker Functions node.
- * doc/Makefile.in (DOCFILES): Added linker.texi.
- (SRCDOC): Added linker.c.
- (linker.texi): New target.
-
-Tue Jan 4 10:52:56 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * chew.c: Don't rely on a correct declaration of exit.
- (chew_exit): New function which just calls exit.
- (main): Use it.
-
-Mon Jan 3 11:40:40 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * bfd.texinfo: Added Hash Tables node.
- * Makefile.in (DOCFILES): Added hash.texi.
- (SRCDOC): Added hash.c.
- (hash.texi): New target.
-
-Thu Dec 30 16:57:04 1993 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * Makefile.in: Delete all references to seclet.c, since it's just
- been deleted. Don't mention hash.c, linker.c, or genlink.h yet,
- since they don't contain documentation yet (hint, hint!).
-
-Fri Nov 5 10:58:53 1993 David J. Mackenzie (djm@thepub.cygnus.com)
-
- * bfd.texinfo: Small cleanups.
-
-Fri Nov 19 03:46:11 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (archures.texi): Depends on $(MKDOC).
-
-Tue Aug 10 14:22:39 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * bfd.texinfo (BFD back end): Don't include elfcode.texi, since
- it's empty now and that triggers a makeinfo bug.
-
-Mon Aug 9 16:27:30 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * bfd.texinfo (BFD back end): New section on ELF, includes
- elf.texi and elfcode.texi.
- * Makefile.in (DOCFILES): Include elf.texi, elfcode.texi.
- (SRCDOC): Include elfcode.h, elf.c.
- (elf.texi, elfcode.texi): New intermediate targets.
-
-Thu Jun 24 13:48:13 1993 David J. Mackenzie (djm@thepub.cygnus.com)
-
- * Makefile.in (.c.o, chew.o): Put CFLAGS last.
- * bfdsumm.texi: New file, broken out of bfd.texinfo, to share
- with ld.texinfo.
-
-Mon Jun 14 12:07:07 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com)
-
- * Makefile.in (install-info): remove parentdir cruft,
-
-Wed Jun 9 16:00:32 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * Makefile.in (mostlyclean): Remove chew.o.
-
-Tue May 25 14:46:58 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (libbfd.h): Use elfcode.h, not elf32.c.
-
-Mon May 24 15:50:07 1993 Ken Raeburn (raeburn@cygnus.com)
-
- * chew.c (compile): Add a couple of missing casts.
-
-Wed May 12 14:45:14 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (CC_FOR_BUILD): New variable, define to be $(CC).
- (chew.o, $(MKDOC)): Build using CC_FOR_BUILD rather than CC, since
- it must run on the build machine.
-
-Tue Apr 6 22:38:10 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (chew): Don't compile from .c to executable in a
- single step; it puts a temporary .o filename into the executable,
- which makes multi-stage comparisons fail. Compile chew.c to
- chew.o, and link that, which makes identical executables every time.
-
-Wed Mar 24 17:26:29 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
-
- * Makefile.in: fix typo (bfd.texinfo not bfd.texino)
-
-Fri Mar 19 01:13:00 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
-
- * bfd.texinfo: Since BFD version number has been bumped, do same
- to "version number" on title page, and elsewhere. Should be
- fixed to extract real version number.
-
-Tue Mar 16 12:15:13 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * Makefile.in: Add *clean rules.
-
-Mon Jan 11 18:43:56 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * Makefile.in (libbfd.h): Removed duplicate init.c and libbfd.c.
- Added seclet.c.
- (bfd.h): Added dependency on bfd.c and seclet.c. Added seclet.c
- to build.
-
-Thu Dec 17 19:35:43 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: added dvi target, define and use $(TEXI2DVI)
-
-Thu Dec 3 17:42:48 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (TEXIDIR): New variable.
- (bfd.dvi): Look for bfd.texinfo in $(srcdir). Generate index.
-
- * bfd.texinfo: Minor doc fixes.
-
-Thu Nov 5 03:13:55 1992 John Gilmore (gnu@cygnus.com)
-
- Cleanup: Replace all uses of EXFUN in the BFD sources, with PARAMS.
-
- * doc/chew.c (exfunstuff): Eliminate.
- (paramstuff): Replace exfunstuff with function to generate PARAMS.
- * doc/proto.str: Use paramstuff rather than exfunstuff.
-
-Mon Aug 17 12:40:32 1992 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * chew.c: various patches provided by Howard Chu.
-
-Fri Jun 19 18:59:54 1992 John Gilmore (gnu at cygnus.com)
-
- * Makefile.in (libbfd.h): Add elf.c as a source of prototypes.
-
-Mon May 11 18:55:59 1992 John Gilmore (gnu at cygnus.com)
-
- * chew.c: exit() should be declared by config files, not by
- portable source code. Its type could be int or void function.
-
-Mon May 4 13:45:57 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in: another CFLAGS correction.
-
-Tue Apr 28 10:21:32 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in: Do the CFLAGS thing.
-
-Fri Apr 10 22:34:52 1992 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (MINUS_G): Add macro and default to -g.
-
-Fri Mar 6 18:53:18 1992 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * chew.c: now has -w switch turn on warnings
-
-Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in, configure.in: removed traces of namesubdir,
- -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced
- copyrights to '92, changed some from Cygnus to FSF.
-
-Tue Dec 10 22:11:05 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Makefile.in: build chew into the current directory. Complete
- the MKDOC macro transition.
-
-Tue Dec 10 08:26:28 1991 Steve Chamberlain (sac at rtl.cygnus.com)
-
- * chew.c: don't core dump when can't open file
- * Makefile.in: get proto.str from the right place when built in
- odd directories
-
-Tue Dec 10 04:07:25 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Makefile.in: infodir belongs in datadir.
-
-Sat Dec 7 17:01:23 1991 Steve Chamberlain (sac at rtl.cygnus.com)
-
- * chew.c: Much modified
- * proto.str, doc.str: New files for extracting to product
- prototypes and documents respectively.
-
-
-Fri Dec 6 22:57:12 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Makefile.in: added standards.text support, host/site/target
- inclusion hooks, install using INSTALL_DATA rather than cp,
- don't echo on install.
-
-Thu Dec 5 22:46:17 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Makefile.in: idestdir and ddestdir go away. Added copyrights
- and shift gpl to v2. Added ChangeLog if it didn't exist. docdir
- and mandir now keyed off datadir by default.
-
-
-Local Variables:
-version-control: never
-End:
diff --git a/contrib/gdb/bfd/doc/Makefile.in b/contrib/gdb/bfd/doc/Makefile.in
deleted file mode 100644
index aa3a76c26ae5..000000000000
--- a/contrib/gdb/bfd/doc/Makefile.in
+++ /dev/null
@@ -1,311 +0,0 @@
-#
-# Makefile
-# Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-#
-
-VPATH = @srcdir@
-srcdir = @srcdir@
-
-prefix = @prefix@
-
-exec_prefix = @exec_prefix@
-bindir = $(exec_prefix)/bin
-libdir = $(exec_prefix)/lib
-
-datadir = $(prefix)/lib
-mandir = $(prefix)/man
-man1dir = $(mandir)/man1
-man2dir = $(mandir)/man2
-man3dir = $(mandir)/man3
-man4dir = $(mandir)/man4
-man5dir = $(mandir)/man5
-man6dir = $(mandir)/man6
-man7dir = $(mandir)/man7
-man8dir = $(mandir)/man8
-man9dir = $(mandir)/man9
-infodir = $(prefix)/info
-includedir = $(prefix)/include
-docdir = $(datadir)/doc
-
-MKDOC=./chew
-SHELL = /bin/sh
-
-INSTALL = `cd $(srcdir)/../..;pwd`/install.sh -c
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_DATA = $(INSTALL)
-
-MAKEINFO = makeinfo
-TEXI2DVI = texi2dvi
-CFLAGS = -g
-
-CC_FOR_BUILD = $(CC)
-
-#### Host, target, and site specific Makefile fragments come in here.
-###
-
-.c.o:
- $(CC) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include $(H_CFLAGS) $(CFLAGS) $<
-
-DOCFILES = aoutx.texi archive.texi archures.texi \
- bfd.texi cache.texi coffcode.texi \
- core.texi elf.texi elfcode.texi format.texi libbfd.texi \
- opncls.texi reloc.texi section.texi \
- syms.texi targets.texi init.texi hash.texi linker.texi
-
-PROTOS = archive.p archures.p bfd.p \
- core.p format.p \
- libbfd.p opncls.p reloc.p \
- section.p syms.p targets.p \
- format.p core.p init.p
-
-IPROTOS = cache.ip libbfd.ip reloc.ip init.ip archures.ip coffcode.ip
-
-# SRCDOC, SRCPROT, SRCIPROT only used to sidestep Sun Make bug in interaction
-# between VPATH and suffix rules. If you use GNU Make, perhaps other Makes,
-# you don't need these three:
-SRCDOC = $(srcdir)/../aoutx.h $(srcdir)/../archive.c \
- $(srcdir)/../archures.c $(srcdir)/../bfd.c \
- $(srcdir)/../cache.c $(srcdir)/../coffcode.h \
- $(srcdir)/../corefile.c $(srcdir)/../elf.c \
- $(srcdir)/../elfcode.h $(srcdir)/../format.c \
- $(srcdir)/../libbfd.c $(srcdir)/../opncls.c \
- $(srcdir)/../reloc.c $(srcdir)/../section.c \
- $(srcdir)/../syms.c $(srcdir)/../targets.c \
- $(srcdir)/../hash.c $(srcdir)/../linker.c
-
-SRCPROT = $(srcdir)/../archive.c $(srcdir)/../archures.c \
- $(srcdir)/../bfd.c $(srcdir)/../coffcode.h $(srcdir)/../corefile.c \
- $(srcdir)/../format.c $(srcdir)/../libbfd.c \
- $(srcdir)/../opncls.c $(srcdir)/../reloc.c \
- $(srcdir)/../section.c $(srcdir)/../syms.c \
- $(srcdir)/../targets.c $(srcdir)/../init.c
-
-SRCIPROT = $(srcdir)/../cache.c $(srcdir)/../libbfd.c \
- $(srcdir)/../reloc.c $(srcdir)/../cpu-h8300.c \
- $(srcdir)/../cpu-i960.c $(srcdir)/../archures.c \
- $(srcdir)/../init.c
-
-STAGESTUFF = $(DOCFILES) *.info*
-
-TEXIDIR = $(srcdir)/../../texinfo/fsf
-
-all install:
-
-info: bfd.info
-
-dvi: bfd.dvi
-
-install-info: info
- for i in *.info* ; do \
- $(INSTALL_DATA) $$i $(infodir)/$$i ; \
- done
-
-docs: $(MKDOC) protos bfd.info bfd.dvi bfd.ps
-
-$(MKDOC): chew.o
- $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(LOADLIBES) $(LDFLAGS)
-
-chew.o: chew.c
- $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
-
-protos: libbfd.h libcoff.h bfd.h
-
-
-# We can't replace these rules with an implicit rule, because
-# makes without VPATH support couldn't find the .h files in `..'.
-
-aoutx.texi: $(MKDOC) $(srcdir)/../aoutx.h $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../aoutx.h >aoutx.texi
-
-archive.texi: $(MKDOC) $(srcdir)/../archive.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../archive.c >archive.texi
-
-archures.texi: $(MKDOC) $(srcdir)/../archures.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../archures.c >archures.texi
-
-bfd.texi: $(MKDOC) $(srcdir)/../bfd.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../bfd.c >bfd.texi
-
-cache.texi: $(MKDOC) $(srcdir)/../cache.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../cache.c >cache.texi
-
-coffcode.texi: $(MKDOC) $(srcdir)/../coffcode.h $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../coffcode.h >coffcode.texi
-
-core.texi: $(MKDOC) $(srcdir)/../corefile.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../corefile.c >core.texi
-
-elf.texi: $(MKDOC) $(srcdir)/../elf.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elf.c >elf.texi
-
-elfcode.texi: $(MKDOC) $(srcdir)/../elfcode.h $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elfcode.h >elfcode.texi
-
-format.texi: $(MKDOC) $(srcdir)/../format.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../format.c >format.texi
-
-libbfd.texi: $(MKDOC) $(srcdir)/../libbfd.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../libbfd.c >libbfd.texi
-
-opncls.texi: $(MKDOC) $(srcdir)/../opncls.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../opncls.c >opncls.texi
-
-reloc.texi : $(MKDOC) $(srcdir)/../reloc.c
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../reloc.c >reloc.texi
-
-section.texi: $(MKDOC) $(srcdir)/../section.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../section.c >section.texi
-
-syms.texi : $(MKDOC) $(srcdir)/../syms.c
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../syms.c >syms.texi
-
-targets.texi: $(MKDOC) $(srcdir)/../targets.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../targets.c >targets.texi
-
-init.texi: $(MKDOC) $(srcdir)/../init.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../init.c >init.texi
-
-hash.texi: $(MKDOC) $(srcdir)/../hash.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../hash.c >hash.texi
-
-linker.texi: $(MKDOC) $(srcdir)/../linker.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../linker.c >linker.texi
-
-libbfd.h: $(srcdir)/../libbfd-in.h \
- $(srcdir)/../init.c \
- $(srcdir)/../libbfd.c \
- $(srcdir)/../cache.c \
- $(srcdir)/../reloc.c \
- $(srcdir)/../cpu-h8300.c \
- $(srcdir)/../cpu-i960.c \
- $(srcdir)/../archures.c \
- $(srcdir)/../elfcode.h \
- $(srcdir)/proto.str \
- $(MKDOC)
- cat $(srcdir)/../libbfd-in.h >libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../init.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../libbfd.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../cache.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../reloc.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../cpu-h8300.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../cpu-i960.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../archures.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../elf.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../elfcode.h >>libbfd.h
-
-libcoff.h: $(srcdir)/../libcoff-in.h \
- $(srcdir)/../coffcode.h \
- $(srcdir)/proto.str \
- $(MKDOC)
- cat $(srcdir)/../libcoff-in.h >libcoff.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../coffcode.h >>libcoff.h
-
-bfd.h: $(srcdir)/../bfd-in.h \
- $(srcdir)/../init.c \
- $(srcdir)/../opncls.c \
- $(srcdir)/../libbfd.c \
- $(srcdir)/../section.c \
- $(srcdir)/../archures.c \
- $(srcdir)/../reloc.c \
- $(srcdir)/../syms.c \
- $(srcdir)/../bfd.c \
- $(srcdir)/../archive.c \
- $(srcdir)/../corefile.c \
- $(srcdir)/../targets.c \
- $(srcdir)/../format.c \
- $(srcdir)/proto.str \
- $(MKDOC)
- cat $(srcdir)/../bfd-in.h >bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../init.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../opncls.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../libbfd.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../section.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archures.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../reloc.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../syms.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../bfd.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archive.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../corefile.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../targets.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../format.c >>bfd.h
- echo "#ifdef __cplusplus" >>bfd.h
- echo "}" >>bfd.h
- echo "#endif" >>bfd.h
- echo "#endif" >>bfd.h
-
-
-clean-info: clean
-
-mostlyclean:
- rm -rf *.log *.ps *~* *.dvi *# $(MKDOC) *.o
-
-clean: mostlyclean
- rm -rf $(STAGESTUFF)
- rm -f *.p *.ip bfd.?? bfd.??? bfd.h libbfd.h libcoff.h texput.log
-
-distclean: clean
- rm -f Makefile config.status
-
-maintainer-clean realclean: clean
- rm -f Makefile config.status
-
-bfd.info: $(DOCFILES) bfdsumm.texi bfd.texinfo
- $(MAKEINFO) -I$(srcdir) -o bfd.info $(srcdir)/bfd.texinfo
-
-bfd.dvi: $(DOCFILES) bfdsumm.texi bfd.texinfo
- $(TEXI2DVI) $(srcdir)/bfd.texinfo
-
-bfd.ps: bfd.dvi
- dvips bfd -o
-
-quickdoc: $(DOCFILES) bfdsumm.texi bfd.texinfo
- TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex bfd.texinfo
-
-stage1: force
- - mkdir stage1
- - mv -f $(STAGESTUFF) stage1
-
-stage2: force
- - mkdir stage2
- - mv -f $(STAGESTUFF) stage2
-
-stage3: force
- - mkdir stage3
- - mv -f $(STAGESTUFF) stage3
-
-against=stage2
-
-comparison: force
- for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i || exit 1 ; done
-
-de-stage1: force
- - (cd stage1 ; mv -f $(STAGESTUFF) ..)
- - rmdir stage1
-
-de-stage2: force
- - (cd stage2 ; mv -f $(STAGESTUFF) ..)
- - rmdir stage2
-
-de-stage3: force
- - (cd stage3 ; mv -f $(STAGESTUFF) ..)
- - rmdir stage3
-
-force:
-
-Makefile: $(srcdir)/Makefile.in
- cd .. && CONFIG_FILES=doc/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
diff --git a/contrib/gdb/bfd/doc/bfd.texinfo b/contrib/gdb/bfd/doc/bfd.texinfo
deleted file mode 100644
index af7bc10062d5..000000000000
--- a/contrib/gdb/bfd/doc/bfd.texinfo
+++ /dev/null
@@ -1,348 +0,0 @@
-\input texinfo.tex
-@setfilename bfd.info
-@c $Id: bfd.texinfo,v 1.28 1995/11/10 20:04:12 victoria Exp $
-@tex
-% NOTE LOCAL KLUGE TO AVOID TOO MUCH WHITESPACE
-\global\long\def\example{%
-\begingroup
-\let\aboveenvbreak=\par
-\let\afterenvbreak=\par
-\parskip=0pt
-\lisp}
-\global\long\def\Eexample{%
-\Elisp
-\endgroup
-\vskip -\parskip% to cancel out effect of following \par
-}
-@end tex
-@synindex fn cp
-
-@ifinfo
-@format
-START-INFO-DIR-ENTRY
-* Bfd: (bfd). The Binary File Descriptor library.
-END-INFO-DIR-ENTRY
-@end format
-@end ifinfo
-
-@ifinfo
-This file documents the BFD library.
-
-Copyright (C) 1991 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-@ignore
-Permission is granted to process this file through Tex and print the
-results, provided the printed document carries copying permission
-notice identical to this one except for the removal of this paragraph
-(this paragraph not being relevant to the printed manual).
-
-@end ignore
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, subject to the terms
-of the GNU General Public License, which includes the provision that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions.
-@end ifinfo
-@iftex
-@c@finalout
-@setchapternewpage on
-@c@setchapternewpage odd
-@settitle LIB BFD, the Binary File Descriptor Library
-@titlepage
-@title{libbfd}
-@subtitle{The Binary File Descriptor Library}
-@sp 1
-@subtitle First Edition---BFD version < 3.0
-@subtitle April 1991
-@author {Steve Chamberlain}
-@author {Cygnus Support}
-@page
-
-@tex
-\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
-\xdef\manvers{\$Revision: 1.28 $} % For use in headers, footers too
-{\parskip=0pt
-\hfill Cygnus Support\par
-\hfill sac\@cygnus.com\par
-\hfill {\it BFD}, \manvers\par
-\hfill \TeX{}info \texinfoversion\par
-}
-\global\parindent=0pt % Steve likes it this way
-@end tex
-
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1991 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, subject to the terms
-of the GNU General Public License, which includes the provision that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions.
-@end titlepage
-@end iftex
-
-@node Top, Overview, (dir), (dir)
-@ifinfo
-This file documents the binary file descriptor library libbfd.
-@end ifinfo
-
-@menu
-* Overview:: Overview of BFD
-* BFD front end:: BFD front end
-* BFD back ends:: BFD back ends
-* Index:: Index
-@end menu
-
-@node Overview, BFD front end, Top, Top
-@chapter Introduction
-@cindex BFD
-@cindex what is it?
-BFD is a package which allows applications to use the
-same routines to operate on object files whatever the object file
-format. A new object file format can be supported simply by
-creating a new BFD back end and adding it to the library.
-
-BFD is split into two parts: the front end, and the back ends (one for
-each object file format).
-@itemize @bullet
-@item The front end of BFD provides the interface to the user. It manages
-memory and various canonical data structures. The front end also
-decides which back end to use and when to call back end routines.
-@item The back ends provide BFD its view of the real world. Each back
-end provides a set of calls which the BFD front end can use to maintain
-its canonical form. The back ends also may keep around information for
-their own use, for greater efficiency.
-@end itemize
-@menu
-* History:: History
-* How It Works:: How It Works
-* What BFD Version 2 Can Do:: What BFD Version 2 Can Do
-@end menu
-
-@node History, How It Works, Overview, Overview
-@section History
-
-One spur behind BFD was the desire, on the part of the GNU 960 team at
-Intel Oregon, for interoperability of applications on their COFF and
-b.out file formats. Cygnus was providing GNU support for the team, and
-was contracted to provide the required functionality.
-
-The name came from a conversation David Wallace was having with Richard
-Stallman about the library: RMS said that it would be quite hard---David
-said ``BFD''. Stallman was right, but the name stuck.
-
-At the same time, Ready Systems wanted much the same thing, but for
-different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k
-coff.
-
-BFD was first implemented by members of Cygnus Support; Steve
-Chamberlain (@code{sac@@cygnus.com}), John Gilmore
-(@code{gnu@@cygnus.com}), K. Richard Pixley (@code{rich@@cygnus.com})
-and David Henkel-Wallace (@code{gumby@@cygnus.com}).
-
-
-
-@node How It Works, What BFD Version 2 Can Do, History, Overview
-@section How To Use BFD
-
-To use the library, include @file{bfd.h} and link with @file{libbfd.a}.
-
-BFD provides a common interface to the parts of an object file
-for a calling application.
-
-When an application sucessfully opens a target file (object, archive, or
-whatever), a pointer to an internal structure is returned. This pointer
-points to a structure called @code{bfd}, described in
-@file{bfd.h}. Our convention is to call this pointer a BFD, and
-instances of it within code @code{abfd}. All operations on
-the target object file are applied as methods to the BFD. The mapping is
-defined within @code{bfd.h} in a set of macros, all beginning
-with @samp{bfd_} to reduce namespace pollution.
-
-For example, this sequence does what you would probably expect:
-return the number of sections in an object file attached to a BFD
-@code{abfd}.
-
-@lisp
-@c @cartouche
-#include "bfd.h"
-
-unsigned int number_of_sections(abfd)
-bfd *abfd;
-@{
- return bfd_count_sections(abfd);
-@}
-@c @end cartouche
-@end lisp
-
-The abstraction used within BFD is that an object file has:
-
-@itemize @bullet
-@item
-a header,
-@item
-a number of sections containing raw data (@pxref{Sections}),
-@item
-a set of relocations (@pxref{Relocations}), and
-@item
-some symbol information (@pxref{Symbols}).
-@end itemize
-@noindent
-Also, BFDs opened for archives have the additional attribute of an index
-and contain subordinate BFDs. This approach is fine for a.out and coff,
-but loses efficiency when applied to formats such as S-records and
-IEEE-695.
-
-@node What BFD Version 2 Can Do, , How It Works, Overview
-@section What BFD Version 2 Can Do
-@include bfdsumm.texi
-
-@node BFD front end, BFD back ends, Overview, Top
-@chapter BFD front end
-@include bfd.texi
-
-@menu
-* Memory Usage::
-* Initialization::
-* Sections::
-* Symbols::
-* Archives::
-* Formats::
-* Relocations::
-* Core Files::
-* Targets::
-* Architectures::
-* Opening and Closing::
-* Internal::
-* File Caching::
-* Linker Functions::
-* Hash Tables::
-@end menu
-
-@node Memory Usage, Initialization, BFD front end, BFD front end
-@section Memory usage
-BFD keeps all of its internal structures in obstacks. There is one obstack
-per open BFD file, into which the current state is stored. When a BFD is
-closed, the obstack is deleted, and so everything which has been
-allocated by BFD for the closing file is thrown away.
-
-BFD does not free anything created by an application, but pointers into
-@code{bfd} structures become invalid on a @code{bfd_close}; for example,
-after a @code{bfd_close} the vector passed to
-@code{bfd_canonicalize_symtab} is still around, since it has been
-allocated by the application, but the data that it pointed to are
-lost.
-
-The general rule is to not close a BFD until all operations dependent
-upon data from the BFD have been completed, or all the data from within
-the file has been copied. To help with the management of memory, there
-is a function (@code{bfd_alloc_size}) which returns the number of bytes
-in obstacks associated with the supplied BFD. This could be used to
-select the greediest open BFD, close it to reclaim the memory, perform
-some operation and reopen the BFD again, to get a fresh copy of the data
-structures.
-
-@node Initialization, Sections, Memory Usage, BFD front end
-@include init.texi
-
-@node Sections, Symbols, Initialization, BFD front end
-@include section.texi
-
-@node Symbols, Archives, Sections, BFD front end
-@include syms.texi
-
-@node Archives, Formats, Symbols, BFD front end
-@include archive.texi
-
-@node Formats, Relocations, Archives, BFD front end
-@include format.texi
-
-@node Relocations, Core Files, Formats, BFD front end
-@include reloc.texi
-
-@node Core Files, Targets, Relocations, BFD front end
-@include core.texi
-
-@node Targets, Architectures, Core Files, BFD front end
-@include targets.texi
-
-@node Architectures, Opening and Closing, Targets, BFD front end
-@include archures.texi
-
-@node Opening and Closing, Internal, Architectures, BFD front end
-@include opncls.texi
-
-@node Internal, File Caching, Opening and Closing, BFD front end
-@include libbfd.texi
-
-@node File Caching, Linker Functions, Internal, BFD front end
-@include cache.texi
-
-@node Linker Functions, Hash Tables, File Caching, BFD front end
-@include linker.texi
-
-@node Hash Tables, , Linker Functions, BFD front end
-@include hash.texi
-
-@node BFD back ends, Index, BFD front end, Top
-@chapter BFD back ends
-@menu
-* What to Put Where::
-* aout :: a.out backends
-* coff :: coff backends
-* elf :: elf backends
-@ignore
-* oasys :: oasys backends
-* ieee :: ieee backend
-* srecord :: s-record backend
-@end ignore
-@end menu
-@node What to Put Where, aout, BFD back ends, BFD back ends
-All of BFD lives in one directory.
-
-@node aout, coff, What to Put Where, BFD back ends
-@include aoutx.texi
-
-@node coff, elf, aout, BFD back ends
-@include coffcode.texi
-
-@node elf, , coff, BFD back ends
-@include elf.texi
-@c Leave this out until the file has some actual contents...
-@c @include elfcode.texi
-
-@node Index, , BFD back ends , Top
-@unnumbered Index
-@printindex cp
-
-@tex
-% I think something like @colophon should be in texinfo. In the
-% meantime:
-\long\def\colophon{\hbox to0pt{}\vfill
-\centerline{The body of this manual is set in}
-\centerline{\fontname\tenrm,}
-\centerline{with headings in {\bf\fontname\tenbf}}
-\centerline{and examples in {\tt\fontname\tentt}.}
-\centerline{{\it\fontname\tenit\/} and}
-\centerline{{\sl\fontname\tensl\/}}
-\centerline{are used for emphasis.}\vfill}
-\page\colophon
-% Blame: doc@cygnus.com, 28mar91.
-@end tex
-
-@contents
-@bye
diff --git a/contrib/gdb/bfd/doc/bfdsumm.texi b/contrib/gdb/bfd/doc/bfdsumm.texi
deleted file mode 100644
index 844531aff8cb..000000000000
--- a/contrib/gdb/bfd/doc/bfdsumm.texi
+++ /dev/null
@@ -1,148 +0,0 @@
-@c This summary of BFD is shared by the BFD and LD docs.
-When an object file is opened, BFD subroutines automatically determine
-the format of the input object file. They then build a descriptor in
-memory with pointers to routines that will be used to access elements of
-the object file's data structures.
-
-As different information from the the object files is required,
-BFD reads from different sections of the file and processes them.
-For example, a very common operation for the linker is processing symbol
-tables. Each BFD back end provides a routine for converting
-between the object file's representation of symbols and an internal
-canonical format. When the linker asks for the symbol table of an object
-file, it calls through a memory pointer to the routine from the
-relevant BFD back end which reads and converts the table into a canonical
-form. The linker then operates upon the canonical form. When the link is
-finished and the linker writes the output file's symbol table,
-another BFD back end routine is called to take the newly
-created symbol table and convert it into the chosen output format.
-
-@menu
-* BFD information loss:: Information Loss
-* Canonical format:: The BFD canonical object-file format
-@end menu
-
-@node BFD information loss
-@subsection Information Loss
-
-@emph{Information can be lost during output.} The output formats
-supported by BFD do not provide identical facilities, and
-information which can be described in one form has nowhere to go in
-another format. One example of this is alignment information in
-@code{b.out}. There is nowhere in an @code{a.out} format file to store
-alignment information on the contained data, so when a file is linked
-from @code{b.out} and an @code{a.out} image is produced, alignment
-information will not propagate to the output file. (The linker will
-still use the alignment information internally, so the link is performed
-correctly).
-
-Another example is COFF section names. COFF files may contain an
-unlimited number of sections, each one with a textual section name. If
-the target of the link is a format which does not have many sections (e.g.,
-@code{a.out}) or has sections without names (e.g., the Oasys format), the
-link cannot be done simply. You can circumvent this problem by
-describing the desired input-to-output section mapping with the linker command
-language.
-
-@emph{Information can be lost during canonicalization.} The BFD
-internal canonical form of the external formats is not exhaustive; there
-are structures in input formats for which there is no direct
-representation internally. This means that the BFD back ends
-cannot maintain all possible data richness through the transformation
-between external to internal and back to external formats.
-
-This limitation is only a problem when an application reads one
-format and writes another. Each BFD back end is responsible for
-maintaining as much data as possible, and the internal BFD
-canonical form has structures which are opaque to the BFD core,
-and exported only to the back ends. When a file is read in one format,
-the canonical form is generated for BFD and the application. At the
-same time, the back end saves away any information which may otherwise
-be lost. If the data is then written back in the same format, the back
-end routine will be able to use the canonical form provided by the
-BFD core as well as the information it prepared earlier. Since
-there is a great deal of commonality between back ends,
-there is no information lost when
-linking or copying big endian COFF to little endian COFF, or @code{a.out} to
-@code{b.out}. When a mixture of formats is linked, the information is
-only lost from the files whose format differs from the destination.
-
-@node Canonical format
-@subsection The BFD canonical object-file format
-
-The greatest potential for loss of information occurs when there is the least
-overlap between the information provided by the source format, that
-stored by the canonical format, and that needed by the
-destination format. A brief description of the canonical form may help
-you understand which kinds of data you can count on preserving across
-conversions.
-@cindex BFD canonical format
-@cindex internal object-file format
-
-@table @emph
-@item files
-Information stored on a per-file basis includes target machine
-architecture, particular implementation format type, a demand pageable
-bit, and a write protected bit. Information like Unix magic numbers is
-not stored here---only the magic numbers' meaning, so a @code{ZMAGIC}
-file would have both the demand pageable bit and the write protected
-text bit set. The byte order of the target is stored on a per-file
-basis, so that big- and little-endian object files may be used with one
-another.
-
-@item sections
-Each section in the input file contains the name of the section, the
-section's original address in the object file, size and alignment
-information, various flags, and pointers into other BFD data
-structures.
-
-@item symbols
-Each symbol contains a pointer to the information for the object file
-which originally defined it, its name, its value, and various flag
-bits. When a BFD back end reads in a symbol table, it relocates all
-symbols to make them relative to the base of the section where they were
-defined. Doing this ensures that each symbol points to its containing
-section. Each symbol also has a varying amount of hidden private data
-for the BFD back end. Since the symbol points to the original file, the
-private data format for that symbol is accessible. @code{ld} can
-operate on a collection of symbols of wildly different formats without
-problems.
-
-Normal global and simple local symbols are maintained on output, so an
-output file (no matter its format) will retain symbols pointing to
-functions and to global, static, and common variables. Some symbol
-information is not worth retaining; in @code{a.out}, type information is
-stored in the symbol table as long symbol names. This information would
-be useless to most COFF debuggers; the linker has command line switches
-to allow users to throw it away.
-
-There is one word of type information within the symbol, so if the
-format supports symbol type information within symbols (for example, COFF,
-IEEE, Oasys) and the type is simple enough to fit within one word
-(nearly everything but aggregates), the information will be preserved.
-
-@item relocation level
-Each canonical BFD relocation record contains a pointer to the symbol to
-relocate to, the offset of the data to relocate, the section the data
-is in, and a pointer to a relocation type descriptor. Relocation is
-performed by passing messages through the relocation type
-descriptor and the symbol pointer. Therefore, relocations can be performed
-on output data using a relocation method that is only available in one of the
-input formats. For instance, Oasys provides a byte relocation format.
-A relocation record requesting this relocation type would point
-indirectly to a routine to perform this, so the relocation may be
-performed on a byte being written to a 68k COFF file, even though 68k COFF
-has no such relocation type.
-
-@item line numbers
-Object formats can contain, for debugging purposes, some form of mapping
-between symbols, source line numbers, and addresses in the output file.
-These addresses have to be relocated along with the symbol information.
-Each symbol with an associated list of line number records points to the
-first record of the list. The head of a line number list consists of a
-pointer to the symbol, which allows finding out the address of the
-function whose line number is being described. The rest of the list is
-made up of pairs: offsets into the section and line numbers. Any format
-which can simply derive this information can pass it successfully
-between formats (COFF, IEEE and Oasys).
-@end table
diff --git a/contrib/gdb/bfd/doc/chew.c b/contrib/gdb/bfd/doc/chew.c
deleted file mode 100644
index 5c04404f7a64..000000000000
--- a/contrib/gdb/bfd/doc/chew.c
+++ /dev/null
@@ -1,1551 +0,0 @@
-/* chew
- Copyright (C) 1990-1991 Free Software Foundation, Inc.
- Contributed by steve chamberlain @cygnus
-
-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. */
-
-/* Yet another way of extracting documentation from source.
- No, I haven't finished it yet, but I hope you people like it better
- than the old way
-
- sac
-
- Basically, this is a sort of string forth, maybe we should call it
- struth?
-
- You define new words thus:
- : <newword> <oldwords> ;
-
-*/
-
-/* Primitives provided by the program:
-
- Two stacks are provided, a string stack and an integer stack.
-
- Internal state variables:
- internal_wanted - indicates whether `-i' was passed
- internal_mode - user-settable
-
- Commands:
- push_text
- ! - pop top of integer stack for address, pop next for value; store
- @ - treat value on integer stack as the address of an integer; push
- that integer on the integer stack after popping the "address"
- hello - print "hello\n" to stdout
- stdout - put stdout marker on TOS
- stderr - put stderr marker on TOS
- print - print TOS-1 on TOS (eg: "hello\n" stdout print)
- skip_past_newline
- catstr - fn icatstr
- copy_past_newline - append input, up to and including newline into TOS
- dup - fn other_dup
- drop - discard TOS
- idrop - ditto
- remchar - delete last character from TOS
- get_stuff_in_command
- do_fancy_stuff - translate <<foo>> to @code{foo} in TOS
- bulletize - if "o" lines found, prepend @itemize @bullet to TOS
- and @item to each "o" line; append @end itemize
- courierize - put @example around . and | lines, translate {* *} { }
- exit - fn chew_exit
- swap
- outputdots - strip out lines without leading dots
- paramstuff - convert full declaration into "PARAMS" form if not already
- maybecatstr - do catstr if internal_mode == internal_wanted, discard
- value in any case
- translatecomments - turn {* and *} into comment delimiters
- kill_bogus_lines - get rid of extra newlines
- indent
- internalmode - pop from integer stack, set `internalmode' to that value
- print_stack_level - print current stack depth to stderr
- strip_trailing_newlines - go ahead, guess...
- [quoted string] - push string onto string stack
- [word starting with digit] - push atol(str) onto integer stack
-
- A command must be all upper-case, and alone on a line.
-
- Foo. */
-
-
-#include <ansidecl.h>
-#include "sysdep.h"
-#include <assert.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#define DEF_SIZE 5000
-#define STACK 50
-
-int internal_wanted;
-int internal_mode;
-
-int warning;
-
-/* Here is a string type ... */
-
-typedef struct buffer
-{
- char *ptr;
- unsigned long write_idx;
- unsigned long size;
-} string_type;
-
-
-#ifdef __STDC__
-static void init_string_with_size (string_type *, unsigned int);
-static void init_string (string_type *);
-static int find (string_type *, char *);
-static void write_buffer (string_type *, FILE *);
-static void delete_string (string_type *);
-static char *addr (string_type *, unsigned int);
-static char at (string_type *, unsigned int);
-static void catchar (string_type *, int);
-static void overwrite_string (string_type *, string_type *);
-static void catbuf (string_type *, char *, unsigned int);
-static void cattext (string_type *, char *);
-static void catstr (string_type *, string_type *);
-static unsigned int skip_white_and_starts (string_type *, unsigned int);
-#endif
-
-
-static void DEFUN(init_string_with_size,(buffer, size),
- string_type *buffer AND
- unsigned int size )
-{
- buffer->write_idx = 0;
- buffer->size = size;
- buffer->ptr = malloc(size);
-}
-
-static void DEFUN(init_string,(buffer),
- string_type *buffer)
-{
- init_string_with_size(buffer, DEF_SIZE);
-
-}
-
-static int DEFUN(find, (str, what),
- string_type *str AND
- char *what)
-{
- unsigned int i;
- char *p;
- p = what;
- for (i = 0; i < str->write_idx && *p; i++)
- {
- if (*p == str->ptr[i])
- p++;
- else
- p = what;
- }
- return (*p == 0);
-
-}
-
-static void DEFUN(write_buffer,(buffer, f),
- string_type *buffer AND
- FILE *f)
-{
- fwrite(buffer->ptr, buffer->write_idx, 1, f);
-}
-
-
-static void DEFUN(delete_string,(buffer),
- string_type *buffer)
-{
- free(buffer->ptr);
-}
-
-
-static char *DEFUN(addr, (buffer, idx),
- string_type *buffer AND
- unsigned int idx)
-{
- return buffer->ptr + idx;
-}
-
-static char DEFUN(at,(buffer, pos),
- string_type *buffer AND
- unsigned int pos)
-{
- if (pos >= buffer->write_idx)
- return 0;
- return buffer->ptr[pos];
-}
-
-static void DEFUN(catchar,(buffer, ch),
- string_type *buffer AND
- int ch)
-{
- if (buffer->write_idx == buffer->size)
- {
- buffer->size *=2;
- buffer->ptr = realloc(buffer->ptr, buffer->size);
- }
-
- buffer->ptr[buffer->write_idx ++ ] = ch;
-}
-
-
-static void DEFUN(overwrite_string,(dst, src),
- string_type *dst AND
- string_type *src)
-{
- free(dst->ptr);
- dst->size = src->size;
- dst->write_idx = src->write_idx;
- dst->ptr = src->ptr;
-}
-
-static void DEFUN(catbuf,(buffer, buf, len),
- string_type *buffer AND
- char *buf AND
- unsigned int len)
-{
- if (buffer->write_idx + len >= buffer->size)
- {
- while (buffer->write_idx + len >= buffer->size)
- buffer->size *= 2;
- buffer->ptr = realloc (buffer->ptr, buffer->size);
- }
- memcpy (buffer->ptr + buffer->write_idx, buf, len);
- buffer->write_idx += len;
-}
-
-static void DEFUN(cattext,(buffer, string),
- string_type *buffer AND
- char *string)
-{
- catbuf (buffer, string, (unsigned int) strlen (string));
-}
-
-static void DEFUN(catstr,(dst, src),
- string_type *dst AND
- string_type *src)
-{
- catbuf (dst, src->ptr, src->write_idx);
-}
-
-
-static unsigned int
-DEFUN(skip_white_and_stars,(src, idx),
- string_type *src AND
- unsigned int idx)
-{
- char c;
- while ((c = at(src,idx)),
- isspace (c)
- || (c == '*'
- /* Don't skip past end-of-comment or star as first
- character on its line. */
- && at(src,idx +1) != '/'
- && at(src,idx -1) != '\n'))
- idx++;
- return idx;
-}
-
-/***********************************************************************/
-
-
-string_type stack[STACK];
-string_type *tos;
-
-unsigned int idx = 0; /* Pos in input buffer */
-string_type *ptr; /* and the buffer */
-typedef void (*stinst_type)();
-stinst_type *pc;
-stinst_type sstack[STACK];
-stinst_type *ssp = &sstack[0];
-long istack[STACK];
-long *isp = &istack[0];
-
-typedef int *word_type;
-
-
-
-struct dict_struct
-{
- char *word;
- struct dict_struct *next;
- stinst_type *code;
- int code_length;
- int code_end;
- int var;
-
-};
-typedef struct dict_struct dict_type;
-#define WORD(x) static void x()
-
-static void
-die (msg)
- char *msg;
-{
- fprintf (stderr, "%s\n", msg);
- exit (1);
-}
-
-static void
-check_range ()
-{
- if (tos < stack)
- die ("underflow in string stack");
- if (tos >= stack + STACK)
- die ("overflow in string stack");
-}
-
-static void
-icheck_range ()
-{
- if (isp < istack)
- die ("underflow in integer stack");
- if (isp >= istack + STACK)
- die ("overflow in integer stack");
-}
-
-#ifdef __STDC__
-static void exec (dict_type *);
-static void call (void);
-static void remchar (void), strip_trailing_newlines (void), push_number (void);
-static void push_text (void);
-static void remove_noncomments (string_type *, string_type *);
-static void print_stack_level (void);
-static void paramstuff (void), translatecomments (void), manglecomments (void);
-static void outputdots (void), courierize (void), bulletize (void);
-static void do_fancy_stuff (void);
-static int iscommand (string_type *, unsigned int);
-static int copy_past_newline (string_type *, unsigned int, string_type *);
-static void icopy_past_newline (void), kill_bogus_lines (void), indent (void);
-static void get_stuff_in_command (void), swap (void), other_dup (void);
-static void drop (void), idrop (void);
-static void icatstr (void), skip_past_newline (void), internalmode (void);
-static void maybecatstr (void);
-static char *nextword (char *, char **);
-dict_type *lookup_word (char *);
-static void perform (void);
-dict_type *newentry (char *);
-unsigned int add_to_definition (dict_type *, stinst_type);
-void add_intrinsic (char *, void (*)());
-void add_var (char *);
-void compile (char *);
-static void bang (void);
-static void atsign (void);
-static void hello (void);
-static void stdout_ (void);
-static void stderr_ (void);
-static void print (void);
-static void read_in (string_type *, FILE *);
-static void usage (void);
-static void chew_exit (void);
-#endif
-
-static void DEFUN(exec,(word),
- dict_type *word)
-{
- pc = word->code;
- while (*pc)
- (*pc)();
-}
-WORD(call)
-{
- stinst_type *oldpc = pc;
- dict_type *e;
- e = (dict_type *)(pc [1]);
- exec(e);
- pc = oldpc + 2;
-
-}
-
-WORD(remchar)
-{
- if (tos->write_idx)
- tos->write_idx--;
- pc++;
-}
-
-static void
-strip_trailing_newlines ()
-{
- while ((isspace (at (tos, tos->write_idx - 1))
- || at (tos, tos->write_idx - 1) == '\n')
- && tos->write_idx > 0)
- tos->write_idx--;
- pc++;
-}
-
-WORD(push_number)
-{
- isp++;
- icheck_range ();
- pc++;
- *isp = (long)(*pc);
- pc++;
-}
-
-WORD(push_text)
-{
- tos++;
- check_range ();
- init_string(tos);
- pc++;
- cattext(tos,*((char **)pc));
- pc++;
-
-}
-
-
-/* This function removes everything not inside comments starting on
- the first char of the line from the string, also when copying
- comments, removes blank space and leading *'s.
- Blank lines are turned into one blank line. */
-
-static void
-DEFUN(remove_noncomments,(src,dst),
- string_type *src AND
- string_type *dst)
-{
- unsigned int idx = 0;
-
- while (at(src,idx))
- {
- /* Now see if we have a comment at the start of the line */
- if (at(src,idx) == '\n'
- && at(src,idx+1) == '/'
- && at(src,idx+2) == '*')
- {
- idx+=3;
-
- idx = skip_white_and_stars(src,idx);
-
- /* Remove leading dot */
- if (at(src, idx) == '.')
- idx++;
-
- /* Copy to the end of the line, or till the end of the
- comment */
- while (at(src, idx))
- {
- if (at(src, idx) == '\n')
- {
- /* end of line, echo and scrape of leading blanks */
- if (at(src,idx +1) == '\n')
- catchar(dst,'\n');
- catchar(dst,'\n');
- idx++;
- idx = skip_white_and_stars(src, idx);
- }
- else if (at(src, idx) == '*' && at(src,idx+1) == '/')
- {
- idx +=2 ;
- cattext(dst,"\nENDDD\n");
- break;
- }
- else
- {
- catchar(dst, at(src, idx));
- idx++;
- }
- }
- }
- else idx++;
- }
-}
-
-static void
-print_stack_level ()
-{
- fprintf (stderr, "current string stack depth = %d, ", tos - stack);
- fprintf (stderr, "current integer stack depth = %d\n", isp - istack);
- pc++;
-}
-
-/* turn:
- foobar name(stuff);
- into:
- foobar
- name PARAMS ((stuff));
- and a blank line.
- */
-
-static void
-DEFUN_VOID(paramstuff)
-{
- unsigned int openp;
- unsigned int fname;
- unsigned int idx;
- string_type out;
- init_string(&out);
-
-
- /* make sure that it's not already param'd or proto'd */
- if(find(tos,"PARAMS") || find(tos,"PROTO") || !find(tos,"(")) {
- catstr(&out,tos);
- }
- else
- {
- /* Find the open paren */
- for (openp = 0; at(tos, openp) != '(' && at(tos,openp); openp++)
- ;
-
- fname = openp;
- /* Step back to the fname */
- fname--;
- while (fname && isspace(at(tos, fname)))
- fname --;
- while (fname && !isspace(at(tos,fname)) && at(tos,fname) != '*')
- fname--;
-
- fname++;
-
- for (idx = 0; idx < fname; idx++) /* Output type */
- {
- catchar(&out, at(tos,idx));
- }
-
- cattext(&out, "\n"); /* Insert a newline between type and fnname */
-
- for (idx = fname; idx < openp; idx++) /* Output fnname */
- {
- catchar(&out, at(tos,idx));
- }
-
- cattext(&out," PARAMS (");
-
- while (at(tos,idx) && at(tos,idx) !=';')
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- cattext(&out,");\n\n");
- }
- overwrite_string(tos, &out);
- pc++;
-
-}
-
-
-
-/* turn {*
- and *} into comments */
-
-WORD(translatecomments)
-{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx))
- {
- if (at(tos,idx) == '{' && at(tos,idx+1) =='*')
- {
- cattext(&out,"/*");
- idx+=2;
- }
- else if (at(tos,idx) == '*' && at(tos,idx+1) =='}')
- {
- cattext(&out,"*/");
- idx+=2;
- }
- else
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- }
-
-
- overwrite_string(tos, &out);
-
- pc++;
-
-}
-
-/* turn everything not starting with a . into a comment */
-
-WORD(manglecomments)
-{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx))
- {
- if (at(tos,idx) == '\n' && at(tos,idx+1) =='*')
- {
- cattext(&out," /*");
- idx+=2;
- }
- else if (at(tos,idx) == '*' && at(tos,idx+1) =='}')
- {
- cattext(&out,"*/");
- idx+=2;
- }
- else
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- }
-
-
- overwrite_string(tos, &out);
-
- pc++;
-
-}
-
-/* Mod tos so that only lines with leading dots remain */
-static void
-DEFUN_VOID(outputdots)
-{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx))
- {
- if (at(tos, idx) == '\n' && at(tos, idx+1) == '.')
- {
- char c, c2;
- idx += 2;
-
- while ((c = at(tos, idx)) && c != '\n')
- {
- if (c == '{' && at(tos,idx+1) =='*')
- {
- cattext(&out," /*");
- idx+=2;
- }
- else if (c == '*' && at(tos,idx+1) =='}')
- {
- cattext(&out,"*/");
- idx+=2;
- }
- else
- {
- catchar(&out, c);
- idx++;
- }
- }
- catchar(&out,'\n');
- }
- else
- {
- idx++;
- }
- }
-
- overwrite_string(tos, &out);
- pc++;
-
-}
-
-/* Find lines starting with . and | and put example around them on tos */
-WORD(courierize)
-{
- string_type out;
- unsigned int idx = 0;
- int command = 0;
-
- init_string(&out);
-
- while (at(tos, idx))
- {
- if (at(tos, idx) == '\n'
- && (at(tos, idx +1 ) == '.'
- || at(tos,idx+1) == '|'))
- {
- cattext(&out,"\n@example\n");
- do
- {
- idx += 2;
-
- while (at(tos, idx) && at(tos, idx)!='\n')
- {
- if (at(tos,idx)=='{' && at(tos,idx+1) =='*')
- {
- cattext(&out," /*");
- idx+=2;
- }
- else if (at(tos,idx)=='*' && at(tos,idx+1) =='}')
- {
- cattext(&out,"*/");
- idx+=2;
- }
- else if (at(tos,idx) == '{' && !command)
- {
- cattext(&out,"@{");
- idx++;
- }
- else if (at(tos,idx) == '}' && !command)
- {
- cattext(&out,"@}");
- idx++;
- }
- else
- {
- if (at(tos,idx) == '@')
- command = 1;
- else if (isspace(at(tos,idx)) || at(tos,idx) == '}')
- command = 0;
- catchar(&out, at(tos, idx));
- idx++;
- }
-
- }
- catchar(&out,'\n');
- }
- while (at(tos, idx) == '\n'
- && (at(tos, idx+1) == '.')
- || (at(tos,idx+1) == '|'));
- cattext(&out,"@end example");
- }
- else
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- }
-
- overwrite_string(tos, &out);
- pc++;
-
-
-}
-
-/* Finds any lines starting with "o ", if there are any, then turns
- on @itemize @bullet, and @items each of them. Then ends with @end
- itemize, inplace at TOS*/
-
-
-WORD(bulletize)
-{
- unsigned int idx = 0;
- int on = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx)) {
- if (at(tos, idx) == '@' &&
- at(tos, idx+1) == '*')
- {
- cattext(&out,"*");
- idx+=2;
- }
-
-else
- if (at(tos, idx) == '\n' &&
- at(tos, idx+1) == 'o' &&
- isspace(at(tos, idx +2)))
- {
- if (!on)
- {
- cattext(&out,"\n@itemize @bullet\n");
- on = 1;
-
- }
- cattext(&out,"\n@item\n");
- idx+=3;
- }
- else
- {
- catchar(&out, at(tos, idx));
- if (on && at(tos, idx) == '\n' &&
- at(tos, idx+1) == '\n' &&
- at(tos, idx+2) != 'o')
- {
- cattext(&out, "@end itemize");
- on = 0;
- }
- idx++;
-
- }
- }
- if (on)
- {
- cattext(&out,"@end itemize\n");
- }
-
- delete_string(tos);
- *tos = out;
- pc++;
-
-}
-
-/* Turn <<foo>> into @code{foo} in place at TOS*/
-
-
-WORD(do_fancy_stuff)
-{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
- while (at(tos, idx))
- {
- if (at(tos, idx) == '<'
- && at(tos, idx+1) == '<'
- && !isspace(at(tos,idx + 2)))
- {
- /* This qualifies as a << startup */
- idx +=2;
- cattext(&out,"@code{");
- while(at(tos,idx) &&
- at(tos,idx) != '>' )
- {
- catchar(&out, at(tos, idx));
- idx++;
-
- }
- cattext(&out,"}");
- idx+=2;
- }
- else
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- }
- delete_string(tos);
- *tos = out;
- pc++;
-
-}
-/* A command is all upper case,and alone on a line */
-static int
-DEFUN( iscommand,(ptr, idx),
- string_type *ptr AND
- unsigned int idx)
-{
- unsigned int len = 0;
- while (at(ptr,idx)) {
- if (isupper(at(ptr,idx)) || at(ptr,idx) == ' ' ||
- at(ptr,idx) == '_')
- {
- len++;
- idx++;
- }
- else if(at(ptr,idx) == '\n')
- {
- if (len > 3) return 1;
- return 0;
- }
- else return 0;
- }
- return 0;
-
-}
-
-
-DEFUN(copy_past_newline,(ptr, idx, dst),
- string_type *ptr AND
- unsigned int idx AND
- string_type *dst)
-{
- while (at(ptr, idx) && at(ptr, idx) != '\n')
- {
- catchar(dst, at(ptr, idx));
- idx++;
-
- }
- catchar(dst, at(ptr, idx));
- idx++;
- return idx;
-
-}
-
-WORD(icopy_past_newline)
-{
- tos++;
- check_range ();
- init_string(tos);
- idx = copy_past_newline(ptr, idx, tos);
- pc++;
-}
-
-/* indent
- Take the string at the top of the stack, do some prettying */
-
-
-WORD(kill_bogus_lines)
-{
- int sl ;
-
- int nl = 0;
- int idx = 0;
- int c;
- int dot = 0 ;
-
- string_type out;
- init_string(&out);
- /* Drop leading nl */
- while (at(tos,idx) == '\n')
- {
- idx++;
- }
- c = idx;
-
- /* Find the last char */
- while (at(tos,idx))
- {
- idx++;
- }
-
- /* find the last non white before the nl */
- idx--;
-
- while (idx && isspace(at(tos,idx)))
- idx--;
- idx++;
-
- /* Copy buffer upto last char, but blank lines before and after
- dots don't count */
- sl = 1;
-
- while (c < idx)
- {
- if (at(tos,c) == '\n'
- && at(tos,c+1) == '\n'
- && at(tos,c+2) == '.')
- {
- /* Ignore two newlines before a dot*/
- c++;
- }
- else if (at(tos,c) == '.' && sl)
- {
- /* remember that this line started with a dot */
- dot=2;
- }
- else if (at(tos,c) == '\n'
- && at(tos,c+1) == '\n'
- && dot)
- {
- c++;
- /* Ignore two newlines when last line was dot */
- }
-
- catchar(&out, at(tos,c));
- if (at(tos,c) == '\n')
- {
- sl = 1;
-
- if (dot == 2)dot=1;else dot = 0;
- }
-
- c++;
-
- }
-
- /* Append nl*/
- catchar(&out, '\n');
- pc++;
- delete_string(tos);
- *tos = out;
-
-
-}
-
-WORD(indent)
-{
- string_type out;
- int tab = 0;
- int idx = 0;
- int ol =0;
- init_string(&out);
- while (at(tos,idx)) {
- switch (at(tos,idx))
- {
- case '\n':
- cattext(&out,"\n");
- idx++;
- if (tab)
- {
- cattext(&out," ");
- }
- ol = 0;
- break;
- case '(':
- tab++;
- if (ol == 0)
- cattext(&out," ");
- idx++;
- cattext(&out,"(");
- ol = 1;
- break;
- case ')':
- tab--;
- cattext(&out,")");
- idx++;
- ol=1;
-
- break;
- default:
- catchar(&out,at(tos,idx));
- ol=1;
-
- idx++;
- break;
- }
- }
-
- pc++;
- delete_string(tos);
- *tos = out;
-
-}
-
-
-WORD(get_stuff_in_command)
-{
- tos++;
- check_range ();
- init_string(tos);
-
- while (at(ptr, idx)) {
- if (iscommand(ptr, idx)) break;
- idx = copy_past_newline(ptr, idx, tos);
- }
- pc++;
-}
-
-WORD(swap)
-{
- string_type t;
-
- t = tos[0];
- tos[0] = tos[-1];
- tos[-1] =t;
- pc++;
-
-}
-
-WORD(other_dup)
-{
- tos++;
- check_range ();
- init_string(tos);
- catstr(tos, tos-1);
- pc++;
-}
-
-WORD(drop)
-{
- tos--;
- check_range ();
- pc++;
-}
-
-WORD(idrop)
-{
- isp--;
- icheck_range ();
- pc++;
-}
-
-WORD(icatstr)
-{
- tos--;
- check_range ();
- catstr(tos, tos+1);
- delete_string(tos+1);
- pc++;
-}
-
-WORD(skip_past_newline)
-{
- while (at(ptr,idx)
- && at(ptr,idx) != '\n')
- idx++;
- idx++;
- pc++;
-}
-
-
-WORD(internalmode)
-{
- internal_mode = *(isp);
- isp--;
- icheck_range ();
- pc++;
-}
-
-WORD(maybecatstr)
-{
- if (internal_wanted == internal_mode)
- {
- catstr(tos-1, tos);
- }
- delete_string(tos);
- tos--;
- check_range ();
- pc++;
-}
-
-char *
-DEFUN(nextword,(string, word),
- char *string AND
- char **word)
-{
- char *word_start;
- int idx;
- char *dst;
- char *src;
-
- int length = 0;
-
- while (isspace(*string) || *string == '-') {
- if (*string == '-')
- {
- while (*string && *string != '\n')
- string++;
-
- }
- else {
- string++;
- }
- }
- if (!*string) return 0;
-
- word_start = string;
- if (*string == '"')
- {
- do
- {
- string++;
- length++;
- if (*string == '\\')
- {
- string += 2;
- length += 2;
- }
- }
- while (*string != '"');
- }
- else
- {
- while (!isspace(*string))
- {
- string++;
- length++;
-
- }
- }
-
- *word = malloc(length + 1);
-
- dst = *word;
- src = word_start;
-
-
- for (idx= 0; idx < length; idx++)
- {
- if (src[idx] == '\\')
- switch (src[idx+1])
- {
- case 'n':
- *dst++ = '\n';
- idx++;
- break;
- case '"':
- case '\\':
- *dst++ = src[idx+1];
- idx++;
- break;
- default:
- *dst++ = '\\';
- break;
- }
- else
- *dst++ = src[idx];
- }
- *dst++ = 0;
-
-
-
-
-
- if(*string)
- return string + 1;
- else
- return 0;
-
-}
-dict_type *root;
-dict_type *
-DEFUN(lookup_word,(word),
- char *word)
-{
- dict_type *ptr = root;
- while (ptr) {
- if (strcmp(ptr->word, word) == 0) return ptr;
- ptr = ptr->next;
-
- }
- if (warning)
- fprintf(stderr,"Can't find %s\n",word);
- return 0;
-
-
-}
-
-static void DEFUN_VOID(perform)
-{
- tos = stack;
-
- while (at(ptr, idx)) {
- /* It's worth looking through the command list */
- if (iscommand(ptr, idx))
- {
- unsigned int i;
- int found = 0;
-
- char *next;
- dict_type *word ;
-
- (void) nextword(addr(ptr, idx), &next);
-
-
- word = lookup_word(next);
-
-
-
-
- if (word)
- {
- exec(word);
- }
- else
- {
- if (warning)
- fprintf(stderr,"warning, %s is not recognised\n", next);
- skip_past_newline();
- }
-
- }
- else skip_past_newline();
-
- }
-}
-
-dict_type *
-DEFUN(newentry,(word),
- char *word)
-{
- dict_type *new = (dict_type *)malloc(sizeof(dict_type));
- new->word = word;
- new->next = root;
- root = new;
- new->code = (stinst_type *)malloc(sizeof(stinst_type ));
- new->code_length = 1;
- new->code_end = 0;
- return new;
-
-}
-
-
-unsigned int
-DEFUN(add_to_definition,(entry, word),
- dict_type *entry AND
- stinst_type word)
-{
- if (entry->code_end == entry->code_length)
- {
- entry->code_length += 2;
- entry->code =
- (stinst_type *) realloc((char *)(entry->code),
- entry->code_length *sizeof(word_type));
- }
- entry->code[entry->code_end] = word;
-
-return entry->code_end++;
-}
-
-
-
-
-
-
-
-void
-DEFUN(add_intrinsic,(name, func),
- char *name AND
- void (*func)())
-{
- dict_type *new = newentry(name);
- add_to_definition(new, func);
- add_to_definition(new, 0);
-}
-
-void
-DEFUN(add_var,(name),
- char *name)
-{
- dict_type *new = newentry(name);
- add_to_definition(new, push_number);
- add_to_definition(new, (stinst_type)(&(new->var)));
- add_to_definition(new,0);
-}
-
-
-void
-DEFUN(compile, (string),
- char *string)
-{
- int jstack[STACK];
- int *jptr = jstack;
- /* add words to the dictionary */
- char *word;
- string = nextword(string, &word);
- while (string && *string && word[0])
- {
- if (strcmp(word,"var")==0)
- {
- string=nextword(string, &word);
-
- add_var(word);
- string=nextword(string, &word);
- }
-else
-
- if (word[0] == ':')
- {
- dict_type *ptr;
- /* Compile a word and add to dictionary */
- string = nextword(string, &word);
-
- ptr = newentry(word);
- string = nextword(string, &word);
- while (word[0] != ';' )
- {
- switch (word[0])
- {
- case '"':
- /* got a string, embed magic push string
- function */
- add_to_definition(ptr, push_text);
- add_to_definition(ptr, (stinst_type)(word+1));
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- /* Got a number, embedd the magic push number
- function */
- add_to_definition(ptr, push_number);
- add_to_definition(ptr, (stinst_type)atol(word));
- break;
- default:
- add_to_definition(ptr, call);
- add_to_definition(ptr, (stinst_type)lookup_word(word));
- }
-
- string = nextword(string, &word);
- }
- add_to_definition(ptr,0);
- string = nextword(string, &word);
- }
- else
- {
- fprintf(stderr,"syntax error at %s\n",string-1);
- }
- }
-
-}
-
-
-static void DEFUN_VOID(bang)
-{
- *(long *)((isp[0])) = isp[-1];
- isp-=2;
- icheck_range ();
- pc++;
-}
-
-WORD(atsign)
-{
- isp[0] = *(long *)(isp[0]);
- pc++;
-}
-
-WORD(hello)
-{
- printf("hello\n");
- pc++;
-}
-
-WORD(stdout_)
-{
- isp++;
- icheck_range ();
- *isp = 1;
- pc++;
-}
-
-WORD(stderr_)
-{
- isp++;
- icheck_range ();
- *isp = 2;
- pc++;
-}
-
-WORD(print)
-{
- if (*isp == 1)
- write_buffer (tos, stdout);
- else if (*isp == 2)
- write_buffer (tos, stderr);
- else
- fprintf (stderr, "print: illegal print destination `%d'\n", *isp);
- isp--;
- tos--;
- icheck_range ();
- check_range ();
- pc++;
-}
-
-
-static void DEFUN(read_in, (str, file),
- string_type *str AND
- FILE *file)
-{
- char buff[10000];
- unsigned int r;
- do
- {
- r = fread(buff, 1, sizeof(buff), file);
- catbuf(str, buff, r);
- }
- while (r);
- buff[0] = 0;
-
- catbuf(str, buff,1);
-}
-
-
-static void DEFUN_VOID(usage)
-{
- fprintf(stderr,"usage: -[d|i|g] <file >file\n");
- exit(33);
-}
-
-/* There is no reliable way to declare exit. Sometimes it returns
- int, and sometimes it returns void. Sometimes it changes between
- OS releases. Trying to get it declared correctly in the hosts file
- is a pointless waste of time. */
-
-static void
-chew_exit ()
-{
- exit (0);
-}
-
-int DEFUN(main,(ac,av),
-int ac AND
-char *av[])
-{
- unsigned int i;
- string_type buffer;
- string_type pptr;
-
- init_string(&buffer);
- init_string(&pptr);
- init_string(stack+0);
- tos=stack+1;
- ptr = &pptr;
-
- add_intrinsic("push_text", push_text);
- add_intrinsic("!", bang);
- add_intrinsic("@", atsign);
- add_intrinsic("hello",hello);
- add_intrinsic("stdout",stdout_);
- add_intrinsic("stderr",stderr_);
- add_intrinsic("print",print);
- add_intrinsic("skip_past_newline", skip_past_newline );
- add_intrinsic("catstr", icatstr );
- add_intrinsic("copy_past_newline", icopy_past_newline );
- add_intrinsic("dup", other_dup );
- add_intrinsic("drop", drop);
- add_intrinsic("idrop", idrop);
- add_intrinsic("remchar", remchar );
- add_intrinsic("get_stuff_in_command", get_stuff_in_command );
- add_intrinsic("do_fancy_stuff", do_fancy_stuff );
- add_intrinsic("bulletize", bulletize );
- add_intrinsic("courierize", courierize );
- /* If the following line gives an error, exit() is not declared in the
- ../hosts/foo.h file for this host. Fix it there, not here! */
- /* No, don't fix it anywhere; see comment on chew_exit--Ian Taylor. */
- add_intrinsic("exit", chew_exit );
- add_intrinsic("swap", swap );
- add_intrinsic("outputdots", outputdots );
- add_intrinsic("paramstuff", paramstuff );
- add_intrinsic("maybecatstr", maybecatstr );
- add_intrinsic("translatecomments", translatecomments );
- add_intrinsic("kill_bogus_lines", kill_bogus_lines);
- add_intrinsic("indent", indent);
- add_intrinsic("internalmode", internalmode);
- add_intrinsic("print_stack_level", print_stack_level);
- add_intrinsic("strip_trailing_newlines", strip_trailing_newlines);
-
- /* Put a nl at the start */
- catchar(&buffer,'\n');
-
- read_in(&buffer, stdin);
- remove_noncomments(&buffer, ptr);
- for (i= 1; i < ac; i++)
- {
- if (av[i][0] == '-')
- {
- if (av[i][1] == 'f')
- {
- string_type b;
- FILE *f;
- init_string(&b);
-
- f = fopen(av[i+1],"r");
- if (!f)
- {
- fprintf(stderr,"Can't open the input file %s\n",av[i+1]);
- return 33;
- }
-
- read_in(&b, f);
- compile(b.ptr);
- perform();
- }
- else if (av[i][1] == 'i')
- {
- internal_wanted = 1;
- }
- else if (av[i][1] == 'w')
- {
- warning = 1;
- }
- }
- }
- write_buffer(stack+0, stdout);
- if (tos != stack)
- {
- fprintf (stderr, "finishing with current stack level %d\n", tos - stack);
- return 1;
- }
- return 0;
-}
diff --git a/contrib/gdb/bfd/doc/doc.str b/contrib/gdb/bfd/doc/doc.str
deleted file mode 100644
index 93685996e063..000000000000
--- a/contrib/gdb/bfd/doc/doc.str
+++ /dev/null
@@ -1,158 +0,0 @@
-: DOCDD
- skip_past_newline
- get_stuff_in_command kill_bogus_lines catstr
- ;
-
-: ENDDD
- skip_past_newline
- ;
-
-: EXAMPLE
- skip_past_newline
- get_stuff_in_command kill_bogus_lines do_fancy_stuff translatecomments
- courierize catstr
-
- ;
-
-: INODE
- "@node " catstr skip_past_newline copy_past_newline catstr
- ;
-
-: CODE_FRAGMENT
- EXAMPLE
- ;
-
-: COMMENT
- skip_past_newline
- get_stuff_in_command
- drop
- ;
-
-: SYNOPSIS
- skip_past_newline
- "@strong{Synopsis}\n" catstr
- "@example\n" catstr
- get_stuff_in_command
- kill_bogus_lines
- indent
- catstr
- "@end example\n" catstr
-
- ;
-
-: func
- "@findex " - a
- skip_past_newline
- copy_past_newline
- dup - a x x
- "@subsubsection @code{" - a x x b
- swap
- remchar
- "}\n" - a x b x c
- catstr catstr catstr catstr catstr
- ;
-
-: FUNCTION
- "@findex " - a
- skip_past_newline
- copy_past_newline
- dup - a x x
- "@subsubsection @code{" - a x x b
- swap
- remchar
- "}\n" - a x b x c
- catstr catstr catstr catstr catstr
- ;
-
-: bodytext
- get_stuff_in_command
- bulletize
- kill_bogus_lines
- do_fancy_stuff
- courierize
- catstr
- "@*\n" catstr
- ;
-
-: asection
- skip_past_newline
- catstr
- copy_past_newline
- do_fancy_stuff catstr
- bodytext
- ;
-
-: SECTION
- "@section " asection ;
-
-: SUBSECTION
- "@subsection " asection ;
-
-: SUBSUBSECTION
- "@subsubsection " asection ;
-
-: subhead
- skip_past_newline
- bodytext
- ;
-
-
-
-
-: DESCRIPTION
- "@strong{Description}@*\n" catstr subhead ;
-
-: RETURNS
- "@strong{Returns}@*\n" catstr subhead ;
-
-: INTERNAL_FUNCTION
- func ;
-
-
-: INTERNAL_DEFINITION
- func ;
-
-
-: INTERNAL
- func ;
-
-: TYPEDEF
- FUNCTION ;
-
-: SENUM
- skip_past_newline
- "Here are the possible values for @code{enum "
- copy_past_newline remchar catstr
- "}:\n\n" catstr catstr
- ;
-: ENUM
- skip_past_newline
- "@deffn {} "
- copy_past_newline catstr catstr
- ;
-: ENUMX
- skip_past_newline
- "@deffnx {} "
- copy_past_newline catstr
- catstr
- ;
-: ENUMEQ
- skip_past_newline
- "@deffn {} "
- copy_past_newline catstr catstr
- skip_past_newline
- ;
-: ENUMEQX
- skip_past_newline
- "@deffnx {} "
- copy_past_newline catstr
- catstr
- skip_past_newline
- ;
-: ENUMDOC
- skip_past_newline
- get_stuff_in_command
- strip_trailing_newlines
- catstr
- "\n@end deffn\n" catstr
- ;
diff --git a/contrib/gdb/bfd/doc/proto.str b/contrib/gdb/bfd/doc/proto.str
deleted file mode 100644
index 8431c16bd57f..000000000000
--- a/contrib/gdb/bfd/doc/proto.str
+++ /dev/null
@@ -1,135 +0,0 @@
-
-: SYNOPSIS
- skip_past_newline
- get_stuff_in_command
- paramstuff
- indent
- maybecatstr
-;
-
-: ignore
- skip_past_newline
- get_stuff_in_command
- outputdots
- maybecatstr
- ;
-
-: CODE_FRAGMENT
- ignore ;
-
-: external
- 0 internalmode ignore ;
-
-: internal
- 1 internalmode ignore ;
-
-- input stack { a b } output b if internal, a if external
-: ifinternal
- "" swap 1 internalmode maybecatstr
- swap
- "" swap 0 internalmode maybecatstr
- catstr
- ;
-
-- Put note in output string, regardless of internal mode.
-: COMMENT
- skip_past_newline
- get_stuff_in_command
- translatecomments
- catstr
- ;
-
-- SENUM enum-type-name
-- ENUM enum-name
-- ENUMX addl-enum-name
-- ENUMDOC doc for preceding enums
-- ENDSENUM max-enum-name
-
-: make_enum_header
- dup
- "enum " swap catstr
- " {\n" catstr
- swap " _dummy_first_" swap catstr catstr
- ",\n" catstr
- ;
-: make_string_table_header
- dup
- "#ifdef _BFD_MAKE_TABLE_" swap catstr swap
- "\n\nstatic const char *const " swap catstr catstr
- "_names[] = { \"@@uninitialized@@\",\n" catstr
- ;
-: SENUM
- skip_past_newline
- copy_past_newline
- remchar
- dup
- make_enum_header
- swap
- make_string_table_header
- ifinternal
- catstr
- get_stuff_in_command catstr
- translatecomments ;
-: ENDSENUM
- skip_past_newline
- copy_past_newline strip_trailing_newlines
- dup
- " " swap catstr " };\n" catstr swap
- " \"@@overflow: " swap catstr "@@\",\n};\n#endif\n\n" catstr
- ifinternal
- catstr
- ;
-: make_enumerator
- " " swap catstr
- ",\n" catstr
- ;
-: make_enumerator_string
- " \"" swap catstr
- "\",\n" catstr
- ;
-: ENUM
- skip_past_newline
- copy_past_newline
- remchar
- dup
- make_enumerator
- swap
- make_enumerator_string
- ifinternal
- ;
-: ENUMX ENUM catstr ;
-: ENUMEQ
- skip_past_newline
- "#define "
- copy_past_newline remchar
- catstr
- " "
- catstr
- copy_past_newline
- catstr
- "" swap 0 internalmode maybecatstr
- ;
-: ENUMEQX ENUMEQ catstr ;
-: ENUMDOC
- skip_past_newline
- get_stuff_in_command
- strip_trailing_newlines
- "\n{* " swap catstr " *}\n" catstr
- translatecomments
- - discard it if we're doing internal mode
- "" swap 0 internalmode maybecatstr
- swap
- catstr catstr
- ;
-: ENDDD external ;
-: SECTION ignore ;
-: SUBSECTION ignore ;
-: SUBSUBSECTION ignore ;
-: INTERNAL_DEFINITION internal ;
-: DESCRIPTION ignore ;
-: FUNCTION external ;
-: RETURNS ignore ;
-: TYPEDEF external ;
-: INTERNAL_FUNCTION internal ;
-: INTERNAL internal ;
-: INODE ignore ;
diff --git a/contrib/gdb/bfd/ecoff.c b/contrib/gdb/bfd/ecoff.c
deleted file mode 100644
index e219ff77a230..000000000000
--- a/contrib/gdb/bfd/ecoff.c
+++ /dev/null
@@ -1,4740 +0,0 @@
-/* Generic ECOFF (Extended-COFF) routines.
- 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 "aout/ar.h"
-#include "aout/ranlib.h"
-#include "aout/stab_gnu.h"
-
-/* FIXME: We need the definitions of N_SET[ADTB], but aout64.h defines
- some other stuff which we don't want and which conflicts with stuff
- we do want. */
-#include "libaout.h"
-#include "aout/aout64.h"
-#undef N_ABS
-#undef exec_hdr
-#undef obj_sym_filepos
-
-#include "coff/internal.h"
-#include "coff/sym.h"
-#include "coff/symconst.h"
-#include "coff/ecoff.h"
-#include "libcoff.h"
-#include "libecoff.h"
-
-/* Prototypes for static functions. */
-
-static int ecoff_get_magic PARAMS ((bfd *abfd));
-static long ecoff_sec_to_styp_flags PARAMS ((const char *name,
- flagword flags));
-static boolean ecoff_slurp_symbolic_header PARAMS ((bfd *abfd));
-static boolean ecoff_set_symbol_info PARAMS ((bfd *abfd, SYMR *ecoff_sym,
- asymbol *asym, int ext, int weak));
-static void ecoff_emit_aggregate PARAMS ((bfd *abfd, FDR *fdr,
- char *string,
- RNDXR *rndx, long isym,
- const char *which));
-static char *ecoff_type_to_string PARAMS ((bfd *abfd, FDR *fdr,
- unsigned int indx));
-static boolean ecoff_slurp_reloc_table PARAMS ((bfd *abfd, asection *section,
- asymbol **symbols));
-static int ecoff_sort_hdrs PARAMS ((const PTR, const PTR));
-static boolean ecoff_compute_section_file_positions PARAMS ((bfd *abfd));
-static bfd_size_type ecoff_compute_reloc_file_positions PARAMS ((bfd *abfd));
-static boolean ecoff_get_extr PARAMS ((asymbol *, EXTR *));
-static void ecoff_set_index PARAMS ((asymbol *, bfd_size_type));
-static unsigned int ecoff_armap_hash PARAMS ((CONST char *s,
- unsigned int *rehash,
- unsigned int size,
- unsigned int hlog));
-
-/* This stuff is somewhat copied from coffcode.h. */
-
-static asection bfd_debug_section = { "*DEBUG*" };
-
-/* Create an ECOFF object. */
-
-boolean
-_bfd_ecoff_mkobject (abfd)
- bfd *abfd;
-{
- abfd->tdata.ecoff_obj_data = ((struct ecoff_tdata *)
- bfd_zalloc (abfd, sizeof (ecoff_data_type)));
- if (abfd->tdata.ecoff_obj_data == NULL)
- return false;
-
- return true;
-}
-
-/* This is a hook called by coff_real_object_p to create any backend
- specific information. */
-
-PTR
-_bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr)
- bfd *abfd;
- PTR filehdr;
- PTR aouthdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
- struct internal_aouthdr *internal_a = (struct internal_aouthdr *) aouthdr;
- ecoff_data_type *ecoff;
-
- if (_bfd_ecoff_mkobject (abfd) == false)
- return NULL;
-
- ecoff = ecoff_data (abfd);
- ecoff->gp_size = 8;
- ecoff->sym_filepos = internal_f->f_symptr;
-
- if (internal_a != (struct internal_aouthdr *) NULL)
- {
- int i;
-
- ecoff->text_start = internal_a->text_start;
- ecoff->text_end = internal_a->text_start + internal_a->tsize;
- ecoff->gp = internal_a->gp_value;
- ecoff->gprmask = internal_a->gprmask;
- for (i = 0; i < 4; i++)
- ecoff->cprmask[i] = internal_a->cprmask[i];
- ecoff->fprmask = internal_a->fprmask;
- if (internal_a->magic == ECOFF_AOUT_ZMAGIC)
- abfd->flags |= D_PAGED;
- else
- abfd->flags &=~ D_PAGED;
- }
-
- /* It turns out that no special action is required by the MIPS or
- Alpha ECOFF backends. They have different information in the
- a.out header, but we just copy it all (e.g., gprmask, cprmask and
- fprmask) and let the swapping routines ensure that only relevant
- information is written out. */
-
- return (PTR) ecoff;
-}
-
-/* Initialize a new section. */
-
-boolean
-_bfd_ecoff_new_section_hook (abfd, section)
- bfd *abfd;
- asection *section;
-{
- /* For the .pdata section, which has a special meaning on the Alpha,
- we set the alignment power to 3. We correct this later in
- ecoff_compute_section_file_positions. We do this hackery because
- we need to know the exact unaligned size of the .pdata section in
- order to set the lnnoptr field correctly. For every other
- section we use an alignment power of 4; this could be made target
- dependent by adding a field to ecoff_backend_data, but 4 appears
- to be correct for both the MIPS and the Alpha. */
- if (strcmp (section->name, _PDATA) == 0)
- section->alignment_power = 3;
- else
- section->alignment_power = 4;
-
- if (strcmp (section->name, _TEXT) == 0)
- section->flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
- else if (strcmp (section->name, _DATA) == 0
- || strcmp (section->name, _SDATA) == 0)
- section->flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
- else if (strcmp (section->name, _RDATA) == 0
- || strcmp (section->name, _LIT8) == 0
- || strcmp (section->name, _LIT4) == 0
- || strcmp (section->name, _RCONST) == 0)
- section->flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
- else if (strcmp (section->name, _BSS) == 0
- || strcmp (section->name, _SBSS) == 0)
- section->flags |= SEC_ALLOC;
- else if (strcmp (section->name, _LIB) == 0)
- {
- /* An Irix 4 shared libary. */
- section->flags |= SEC_COFF_SHARED_LIBRARY;
- }
-
- /* Probably any other section name is SEC_NEVER_LOAD, but I'm
- uncertain about .init on some systems and I don't know how shared
- libraries work. */
-
- return true;
-}
-
-/* Determine the machine architecture and type. This is called from
- the generic COFF routines. It is the inverse of ecoff_get_magic,
- below. This could be an ECOFF backend routine, with one version
- for each target, but there aren't all that many ECOFF targets. */
-
-boolean
-_bfd_ecoff_set_arch_mach_hook (abfd, filehdr)
- bfd *abfd;
- PTR filehdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
- enum bfd_architecture arch;
- unsigned long mach;
-
- switch (internal_f->f_magic)
- {
- case MIPS_MAGIC_1:
- case MIPS_MAGIC_LITTLE:
- case MIPS_MAGIC_BIG:
- arch = bfd_arch_mips;
- mach = 3000;
- break;
-
- case MIPS_MAGIC_LITTLE2:
- case MIPS_MAGIC_BIG2:
- /* MIPS ISA level 2: the r6000 */
- arch = bfd_arch_mips;
- mach = 6000;
- break;
-
- case MIPS_MAGIC_LITTLE3:
- case MIPS_MAGIC_BIG3:
- /* MIPS ISA level 3: the r4000 */
- arch = bfd_arch_mips;
- mach = 4000;
- break;
-
- case ALPHA_MAGIC:
- arch = bfd_arch_alpha;
- mach = 0;
- break;
-
- default:
- arch = bfd_arch_obscure;
- mach = 0;
- break;
- }
-
- return bfd_default_set_arch_mach (abfd, arch, mach);
-}
-
-/* Get the magic number to use based on the architecture and machine.
- This is the inverse of _bfd_ecoff_set_arch_mach_hook, above. */
-
-static int
-ecoff_get_magic (abfd)
- bfd *abfd;
-{
- int big, little;
-
- switch (bfd_get_arch (abfd))
- {
- case bfd_arch_mips:
- switch (bfd_get_mach (abfd))
- {
- default:
- case 0:
- case 3000:
- big = MIPS_MAGIC_BIG;
- little = MIPS_MAGIC_LITTLE;
- break;
-
- case 6000:
- big = MIPS_MAGIC_BIG2;
- little = MIPS_MAGIC_LITTLE2;
- break;
-
- case 4000:
- big = MIPS_MAGIC_BIG3;
- little = MIPS_MAGIC_LITTLE3;
- break;
- }
-
- return bfd_big_endian (abfd) ? big : little;
-
- case bfd_arch_alpha:
- return ALPHA_MAGIC;
-
- default:
- abort ();
- return 0;
- }
-}
-
-/* Get the section s_flags to use for a section. */
-
-static long
-ecoff_sec_to_styp_flags (name, flags)
- const char *name;
- flagword flags;
-{
- long styp;
-
- styp = 0;
-
- if (strcmp (name, _TEXT) == 0)
- styp = STYP_TEXT;
- else if (strcmp (name, _DATA) == 0)
- styp = STYP_DATA;
- else if (strcmp (name, _SDATA) == 0)
- styp = STYP_SDATA;
- else if (strcmp (name, _RDATA) == 0)
- styp = STYP_RDATA;
- else if (strcmp (name, _LITA) == 0)
- styp = STYP_LITA;
- else if (strcmp (name, _LIT8) == 0)
- styp = STYP_LIT8;
- else if (strcmp (name, _LIT4) == 0)
- styp = STYP_LIT4;
- else if (strcmp (name, _BSS) == 0)
- styp = STYP_BSS;
- else if (strcmp (name, _SBSS) == 0)
- styp = STYP_SBSS;
- else if (strcmp (name, _INIT) == 0)
- styp = STYP_ECOFF_INIT;
- else if (strcmp (name, _FINI) == 0)
- styp = STYP_ECOFF_FINI;
- else if (strcmp (name, _PDATA) == 0)
- styp = STYP_PDATA;
- else if (strcmp (name, _XDATA) == 0)
- styp = STYP_XDATA;
- else if (strcmp (name, _LIB) == 0)
- styp = STYP_ECOFF_LIB;
- else if (strcmp (name, _GOT) == 0)
- styp = STYP_GOT;
- else if (strcmp (name, _HASH) == 0)
- styp = STYP_HASH;
- else if (strcmp (name, _DYNAMIC) == 0)
- styp = STYP_DYNAMIC;
- else if (strcmp (name, _LIBLIST) == 0)
- styp = STYP_LIBLIST;
- else if (strcmp (name, _RELDYN) == 0)
- styp = STYP_RELDYN;
- else if (strcmp (name, _CONFLIC) == 0)
- styp = STYP_CONFLIC;
- else if (strcmp (name, _DYNSTR) == 0)
- styp = STYP_DYNSTR;
- else if (strcmp (name, _DYNSYM) == 0)
- styp = STYP_DYNSYM;
- else if (strcmp (name, _COMMENT) == 0)
- {
- styp = STYP_COMMENT;
- flags &=~ SEC_NEVER_LOAD;
- }
- else if (strcmp (name, _RCONST) == 0)
- styp = STYP_RCONST;
- else if (flags & SEC_CODE)
- styp = STYP_TEXT;
- else if (flags & SEC_DATA)
- styp = STYP_DATA;
- else if (flags & SEC_READONLY)
- styp = STYP_RDATA;
- else if (flags & SEC_LOAD)
- styp = STYP_REG;
- else
- styp = STYP_BSS;
-
- if (flags & SEC_NEVER_LOAD)
- styp |= STYP_NOLOAD;
-
- return styp;
-}
-
-/* Get the BFD flags to use for a section. */
-
-/*ARGSUSED*/
-flagword
-_bfd_ecoff_styp_to_sec_flags (abfd, hdr, name)
- bfd *abfd;
- PTR hdr;
- const char *name;
-{
- struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
- long styp_flags = internal_s->s_flags;
- flagword sec_flags=0;
-
- if (styp_flags & STYP_NOLOAD)
- sec_flags |= SEC_NEVER_LOAD;
-
- /* For 386 COFF, at least, an unloadable text or data section is
- actually a shared library section. */
- if ((styp_flags & STYP_TEXT)
- || (styp_flags & STYP_ECOFF_INIT)
- || (styp_flags & STYP_ECOFF_FINI)
- || (styp_flags & STYP_DYNAMIC)
- || (styp_flags & STYP_LIBLIST)
- || (styp_flags & STYP_RELDYN)
- || styp_flags == STYP_CONFLIC
- || (styp_flags & STYP_DYNSTR)
- || (styp_flags & STYP_DYNSYM)
- || (styp_flags & STYP_HASH))
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
- }
- else if ((styp_flags & STYP_DATA)
- || (styp_flags & STYP_RDATA)
- || (styp_flags & STYP_SDATA)
- || styp_flags == STYP_PDATA
- || styp_flags == STYP_XDATA
- || (styp_flags & STYP_GOT)
- || styp_flags == STYP_RCONST)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
- if ((styp_flags & STYP_RDATA)
- || styp_flags == STYP_PDATA
- || styp_flags == STYP_RCONST)
- sec_flags |= SEC_READONLY;
- }
- else if ((styp_flags & STYP_BSS)
- || (styp_flags & STYP_SBSS))
- {
- sec_flags |= SEC_ALLOC;
- }
- else if ((styp_flags & STYP_INFO) || styp_flags == STYP_COMMENT)
- {
- sec_flags |= SEC_NEVER_LOAD;
- }
- else if ((styp_flags & STYP_LITA)
- || (styp_flags & STYP_LIT8)
- || (styp_flags & STYP_LIT4))
- {
- sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
- }
- else if (styp_flags & STYP_ECOFF_LIB)
- {
- sec_flags |= SEC_COFF_SHARED_LIBRARY;
- }
- else
- {
- sec_flags |= SEC_ALLOC | SEC_LOAD;
- }
-
- return sec_flags;
-}
-
-/* Read in the symbolic header for an ECOFF object file. */
-
-static boolean
-ecoff_slurp_symbolic_header (abfd)
- bfd *abfd;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- bfd_size_type external_hdr_size;
- PTR raw = NULL;
- HDRR *internal_symhdr;
-
- /* See if we've already read it in. */
- if (ecoff_data (abfd)->debug_info.symbolic_header.magic ==
- backend->debug_swap.sym_magic)
- return true;
-
- /* See whether there is a symbolic header. */
- if (ecoff_data (abfd)->sym_filepos == 0)
- {
- bfd_get_symcount (abfd) = 0;
- return true;
- }
-
- /* At this point bfd_get_symcount (abfd) holds the number of symbols
- as read from the file header, but on ECOFF this is always the
- size of the symbolic information header. It would be cleaner to
- handle this when we first read the file in coffgen.c. */
- external_hdr_size = backend->debug_swap.external_hdr_size;
- if (bfd_get_symcount (abfd) != external_hdr_size)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- /* Read the symbolic information header. */
- raw = (PTR) bfd_malloc ((size_t) external_hdr_size);
- if (raw == NULL)
- goto error_return;
-
- if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) == -1
- || (bfd_read (raw, external_hdr_size, 1, abfd)
- != external_hdr_size))
- goto error_return;
- internal_symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
- (*backend->debug_swap.swap_hdr_in) (abfd, raw, internal_symhdr);
-
- if (internal_symhdr->magic != backend->debug_swap.sym_magic)
- {
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- /* Now we can get the correct number of symbols. */
- bfd_get_symcount (abfd) = (internal_symhdr->isymMax
- + internal_symhdr->iextMax);
-
- if (raw != NULL)
- free (raw);
- return true;
- error_return:
- if (raw != NULL)
- free (raw);
- return false;
-}
-
-/* Read in and swap the important symbolic information for an ECOFF
- object file. This is called by gdb via the read_debug_info entry
- point in the backend structure. */
-
-/*ARGSUSED*/
-boolean
-_bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug)
- bfd *abfd;
- asection *ignore;
- struct ecoff_debug_info *debug;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- HDRR *internal_symhdr;
- bfd_size_type raw_base;
- bfd_size_type raw_size;
- PTR raw;
- bfd_size_type external_fdr_size;
- char *fraw_src;
- char *fraw_end;
- struct fdr *fdr_ptr;
- bfd_size_type raw_end;
- bfd_size_type cb_end;
-
- BFD_ASSERT (debug == &ecoff_data (abfd)->debug_info);
-
- /* Check whether we've already gotten it, and whether there's any to
- get. */
- if (ecoff_data (abfd)->raw_syments != (PTR) NULL)
- return true;
- if (ecoff_data (abfd)->sym_filepos == 0)
- {
- bfd_get_symcount (abfd) = 0;
- return true;
- }
-
- if (! ecoff_slurp_symbolic_header (abfd))
- return false;
-
- internal_symhdr = &debug->symbolic_header;
-
- /* Read all the symbolic information at once. */
- raw_base = (ecoff_data (abfd)->sym_filepos
- + backend->debug_swap.external_hdr_size);
-
- /* Alpha ecoff makes the determination of raw_size difficult. It has
- an undocumented debug data section between the symhdr and the first
- documented section. And the ordering of the sections varies between
- statically and dynamically linked executables.
- If bfd supports SEEK_END someday, this code could be simplified. */
-
- raw_end = 0;
-
-#define UPDATE_RAW_END(start, count, size) \
- cb_end = internal_symhdr->start + internal_symhdr->count * (size); \
- if (cb_end > raw_end) \
- raw_end = cb_end
-
- UPDATE_RAW_END (cbLineOffset, cbLine, sizeof (unsigned char));
- UPDATE_RAW_END (cbDnOffset, idnMax, backend->debug_swap.external_dnr_size);
- UPDATE_RAW_END (cbPdOffset, ipdMax, backend->debug_swap.external_pdr_size);
- UPDATE_RAW_END (cbSymOffset, isymMax, backend->debug_swap.external_sym_size);
- UPDATE_RAW_END (cbOptOffset, ioptMax, backend->debug_swap.external_opt_size);
- UPDATE_RAW_END (cbAuxOffset, iauxMax, sizeof (union aux_ext));
- UPDATE_RAW_END (cbSsOffset, issMax, sizeof (char));
- UPDATE_RAW_END (cbSsExtOffset, issExtMax, sizeof (char));
- UPDATE_RAW_END (cbFdOffset, ifdMax, backend->debug_swap.external_fdr_size);
- UPDATE_RAW_END (cbRfdOffset, crfd, backend->debug_swap.external_rfd_size);
- UPDATE_RAW_END (cbExtOffset, iextMax, backend->debug_swap.external_ext_size);
-
-#undef UPDATE_RAW_END
-
- raw_size = raw_end - raw_base;
- if (raw_size == 0)
- {
- ecoff_data (abfd)->sym_filepos = 0;
- return true;
- }
- raw = (PTR) bfd_alloc (abfd, raw_size);
- if (raw == NULL)
- return false;
- if (bfd_seek (abfd,
- (ecoff_data (abfd)->sym_filepos
- + backend->debug_swap.external_hdr_size),
- SEEK_SET) != 0
- || bfd_read (raw, raw_size, 1, abfd) != raw_size)
- {
- bfd_release (abfd, raw);
- return false;
- }
-
- ecoff_data (abfd)->raw_syments = raw;
-
- /* Get pointers for the numeric offsets in the HDRR structure. */
-#define FIX(off1, off2, type) \
- if (internal_symhdr->off1 == 0) \
- debug->off2 = (type) NULL; \
- else \
- debug->off2 = (type) ((char *) raw \
- + (internal_symhdr->off1 \
- - raw_base))
- FIX (cbLineOffset, line, unsigned char *);
- FIX (cbDnOffset, external_dnr, PTR);
- FIX (cbPdOffset, external_pdr, PTR);
- FIX (cbSymOffset, external_sym, PTR);
- FIX (cbOptOffset, external_opt, PTR);
- FIX (cbAuxOffset, external_aux, union aux_ext *);
- FIX (cbSsOffset, ss, char *);
- FIX (cbSsExtOffset, ssext, char *);
- FIX (cbFdOffset, external_fdr, PTR);
- FIX (cbRfdOffset, external_rfd, PTR);
- FIX (cbExtOffset, external_ext, PTR);
-#undef FIX
-
- /* I don't want to always swap all the data, because it will just
- waste time and most programs will never look at it. The only
- time the linker needs most of the debugging information swapped
- is when linking big-endian and little-endian MIPS object files
- together, which is not a common occurrence.
-
- We need to look at the fdr to deal with a lot of information in
- the symbols, so we swap them here. */
- debug->fdr = (struct fdr *) bfd_alloc (abfd,
- (internal_symhdr->ifdMax *
- sizeof (struct fdr)));
- if (debug->fdr == NULL)
- return false;
- external_fdr_size = backend->debug_swap.external_fdr_size;
- fdr_ptr = debug->fdr;
- fraw_src = (char *) debug->external_fdr;
- fraw_end = fraw_src + internal_symhdr->ifdMax * external_fdr_size;
- for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
- (*backend->debug_swap.swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
-
- return true;
-}
-
-/* ECOFF symbol table routines. The ECOFF symbol table is described
- in gcc/mips-tfile.c. */
-
-/* ECOFF 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. */
-static asection ecoff_scom_section;
-static asymbol ecoff_scom_symbol;
-static asymbol *ecoff_scom_symbol_ptr;
-
-/* Create an empty symbol. */
-
-asymbol *
-_bfd_ecoff_make_empty_symbol (abfd)
- bfd *abfd;
-{
- ecoff_symbol_type *new;
-
- new = (ecoff_symbol_type *) bfd_alloc (abfd, sizeof (ecoff_symbol_type));
- if (new == (ecoff_symbol_type *) NULL)
- return (asymbol *) NULL;
- memset ((PTR) new, 0, sizeof *new);
- new->symbol.section = (asection *) NULL;
- new->fdr = (FDR *) NULL;
- new->local = false;
- new->native = NULL;
- new->symbol.the_bfd = abfd;
- return &new->symbol;
-}
-
-/* Set the BFD flags and section for an ECOFF symbol. */
-
-static boolean
-ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, weak)
- bfd *abfd;
- SYMR *ecoff_sym;
- asymbol *asym;
- int ext;
- int weak;
-{
- asym->the_bfd = abfd;
- asym->value = ecoff_sym->value;
- asym->section = &bfd_debug_section;
- asym->udata.i = 0;
-
- /* Most symbol types are just for debugging. */
- switch (ecoff_sym->st)
- {
- case stGlobal:
- case stStatic:
- case stLabel:
- case stProc:
- case stStaticProc:
- break;
- case stNil:
- if (ECOFF_IS_STAB (ecoff_sym))
- {
- asym->flags = BSF_DEBUGGING;
- return true;
- }
- break;
- default:
- asym->flags = BSF_DEBUGGING;
- return true;
- }
-
- if (weak)
- asym->flags = BSF_EXPORT | BSF_WEAK;
- else if (ext)
- asym->flags = BSF_EXPORT | BSF_GLOBAL;
- else
- {
- asym->flags = BSF_LOCAL;
- /* Normally, a local stProc symbol will have a corresponding
- external symbol. We mark the local symbol as a debugging
- symbol, in order to prevent nm from printing both out.
- Similarly, we mark stLabel and stabs symbols as debugging
- symbols. In both cases, we do want to set the value
- correctly based on the symbol class. */
- if (ecoff_sym->st == stProc
- || ecoff_sym->st == stLabel
- || ECOFF_IS_STAB (ecoff_sym))
- asym->flags |= BSF_DEBUGGING;
- }
- switch (ecoff_sym->sc)
- {
- case scNil:
- /* Used for compiler generated labels. Leave them in the
- debugging section, and mark them as local. If BSF_DEBUGGING
- is set, then nm does not display them for some reason. If no
- flags are set then the linker whines about them. */
- asym->flags = BSF_LOCAL;
- break;
- case scText:
- asym->section = bfd_make_section_old_way (abfd, ".text");
- asym->value -= asym->section->vma;
- break;
- case scData:
- asym->section = bfd_make_section_old_way (abfd, ".data");
- asym->value -= asym->section->vma;
- break;
- case scBss:
- asym->section = bfd_make_section_old_way (abfd, ".bss");
- asym->value -= asym->section->vma;
- break;
- case scRegister:
- asym->flags = BSF_DEBUGGING;
- break;
- case scAbs:
- asym->section = bfd_abs_section_ptr;
- break;
- case scUndefined:
- asym->section = bfd_und_section_ptr;
- asym->flags = 0;
- asym->value = 0;
- break;
- case scCdbLocal:
- case scBits:
- case scCdbSystem:
- case scRegImage:
- case scInfo:
- case scUserStruct:
- asym->flags = BSF_DEBUGGING;
- break;
- case scSData:
- asym->section = bfd_make_section_old_way (abfd, ".sdata");
- asym->value -= asym->section->vma;
- break;
- case scSBss:
- asym->section = bfd_make_section_old_way (abfd, ".sbss");
- asym->value -= asym->section->vma;
- break;
- case scRData:
- asym->section = bfd_make_section_old_way (abfd, ".rdata");
- asym->value -= asym->section->vma;
- break;
- case scVar:
- asym->flags = BSF_DEBUGGING;
- break;
- case scCommon:
- if (asym->value > ecoff_data (abfd)->gp_size)
- {
- asym->section = bfd_com_section_ptr;
- asym->flags = 0;
- break;
- }
- /* Fall through. */
- case scSCommon:
- if (ecoff_scom_section.name == NULL)
- {
- /* Initialize the small common section. */
- ecoff_scom_section.name = SCOMMON;
- ecoff_scom_section.flags = SEC_IS_COMMON;
- ecoff_scom_section.output_section = &ecoff_scom_section;
- ecoff_scom_section.symbol = &ecoff_scom_symbol;
- ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
- ecoff_scom_symbol.name = SCOMMON;
- ecoff_scom_symbol.flags = BSF_SECTION_SYM;
- ecoff_scom_symbol.section = &ecoff_scom_section;
- ecoff_scom_symbol_ptr = &ecoff_scom_symbol;
- }
- asym->section = &ecoff_scom_section;
- asym->flags = 0;
- break;
- case scVarRegister:
- case scVariant:
- asym->flags = BSF_DEBUGGING;
- break;
- case scSUndefined:
- asym->section = bfd_und_section_ptr;
- asym->flags = 0;
- asym->value = 0;
- break;
- case scInit:
- asym->section = bfd_make_section_old_way (abfd, ".init");
- asym->value -= asym->section->vma;
- break;
- case scBasedVar:
- case scXData:
- case scPData:
- asym->flags = BSF_DEBUGGING;
- break;
- case scFini:
- asym->section = bfd_make_section_old_way (abfd, ".fini");
- asym->value -= asym->section->vma;
- break;
- case scRConst:
- asym->section = bfd_make_section_old_way (abfd, ".rconst");
- asym->value -= asym->section->vma;
- break;
- default:
- break;
- }
-
- /* Look for special constructors symbols and make relocation entries
- in a special construction section. These are produced by the
- -fgnu-linker argument to g++. */
- if (ECOFF_IS_STAB (ecoff_sym))
- {
- switch (ECOFF_UNMARK_STAB (ecoff_sym->index))
- {
- default:
- break;
-
- case N_SETA:
- case N_SETT:
- case N_SETD:
- case N_SETB:
- {
- const char *name;
- asection *section;
- arelent_chain *reloc_chain;
- unsigned int bitsize;
-
- /* Get a section with the same name as the symbol (usually
- __CTOR_LIST__ or __DTOR_LIST__). FIXME: gcc uses the
- name ___CTOR_LIST (three underscores). We need
- __CTOR_LIST (two underscores), since ECOFF doesn't use
- a leading underscore. This should be handled by gcc,
- but instead we do it here. Actually, this should all
- be done differently anyhow. */
- name = bfd_asymbol_name (asym);
- if (name[0] == '_' && name[1] == '_' && name[2] == '_')
- {
- ++name;
- asym->name = name;
- }
- section = bfd_get_section_by_name (abfd, name);
- if (section == (asection *) NULL)
- {
- char *copy;
-
- copy = (char *) bfd_alloc (abfd, strlen (name) + 1);
- if (!copy)
- return false;
- strcpy (copy, name);
- section = bfd_make_section (abfd, copy);
- }
-
- /* Build a reloc pointing to this constructor. */
- reloc_chain =
- (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
- if (!reloc_chain)
- return false;
- reloc_chain->relent.sym_ptr_ptr =
- bfd_get_section (asym)->symbol_ptr_ptr;
- reloc_chain->relent.address = section->_raw_size;
- reloc_chain->relent.addend = asym->value;
- reloc_chain->relent.howto =
- ecoff_backend (abfd)->constructor_reloc;
-
- /* Set up the constructor section to hold the reloc. */
- section->flags = SEC_CONSTRUCTOR;
- ++section->reloc_count;
-
- /* Constructor sections must be rounded to a boundary
- based on the bitsize. These are not real sections--
- they are handled specially by the linker--so the ECOFF
- 16 byte alignment restriction does not apply. */
- bitsize = ecoff_backend (abfd)->constructor_bitsize;
- section->alignment_power = 1;
- while ((1 << section->alignment_power) < bitsize / 8)
- ++section->alignment_power;
-
- reloc_chain->next = section->constructor_chain;
- section->constructor_chain = reloc_chain;
- section->_raw_size += bitsize / 8;
-
- /* Mark the symbol as a constructor. */
- asym->flags |= BSF_CONSTRUCTOR;
- }
- break;
- }
- }
- return true;
-}
-
-/* Read an ECOFF symbol table. */
-
-boolean
-_bfd_ecoff_slurp_symbol_table (abfd)
- bfd *abfd;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- const bfd_size_type external_ext_size
- = backend->debug_swap.external_ext_size;
- const bfd_size_type external_sym_size
- = backend->debug_swap.external_sym_size;
- void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
- = backend->debug_swap.swap_ext_in;
- void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *))
- = backend->debug_swap.swap_sym_in;
- bfd_size_type internal_size;
- ecoff_symbol_type *internal;
- ecoff_symbol_type *internal_ptr;
- char *eraw_src;
- char *eraw_end;
- FDR *fdr_ptr;
- FDR *fdr_end;
-
- /* If we've already read in the symbol table, do nothing. */
- if (ecoff_data (abfd)->canonical_symbols != NULL)
- return true;
-
- /* Get the symbolic information. */
- if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL,
- &ecoff_data (abfd)->debug_info))
- return false;
- if (bfd_get_symcount (abfd) == 0)
- return true;
-
- internal_size = bfd_get_symcount (abfd) * sizeof (ecoff_symbol_type);
- internal = (ecoff_symbol_type *) bfd_alloc (abfd, internal_size);
- if (internal == NULL)
- return false;
-
- internal_ptr = internal;
- eraw_src = (char *) ecoff_data (abfd)->debug_info.external_ext;
- eraw_end = (eraw_src
- + (ecoff_data (abfd)->debug_info.symbolic_header.iextMax
- * external_ext_size));
- for (; eraw_src < eraw_end; eraw_src += external_ext_size, internal_ptr++)
- {
- EXTR internal_esym;
-
- (*swap_ext_in) (abfd, (PTR) eraw_src, &internal_esym);
- internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ssext
- + internal_esym.asym.iss);
- if (!ecoff_set_symbol_info (abfd, &internal_esym.asym,
- &internal_ptr->symbol, 1,
- internal_esym.weakext))
- return false;
- /* The alpha uses a negative ifd field for section symbols. */
- if (internal_esym.ifd >= 0)
- internal_ptr->fdr = (ecoff_data (abfd)->debug_info.fdr
- + internal_esym.ifd);
- else
- internal_ptr->fdr = NULL;
- internal_ptr->local = false;
- internal_ptr->native = (PTR) eraw_src;
- }
-
- /* The local symbols must be accessed via the fdr's, because the
- string and aux indices are relative to the fdr information. */
- fdr_ptr = ecoff_data (abfd)->debug_info.fdr;
- fdr_end = fdr_ptr + ecoff_data (abfd)->debug_info.symbolic_header.ifdMax;
- for (; fdr_ptr < fdr_end; fdr_ptr++)
- {
- char *lraw_src;
- char *lraw_end;
-
- lraw_src = ((char *) ecoff_data (abfd)->debug_info.external_sym
- + fdr_ptr->isymBase * external_sym_size);
- lraw_end = lraw_src + fdr_ptr->csym * external_sym_size;
- for (;
- lraw_src < lraw_end;
- lraw_src += external_sym_size, internal_ptr++)
- {
- SYMR internal_sym;
-
- (*swap_sym_in) (abfd, (PTR) lraw_src, &internal_sym);
- internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ss
- + fdr_ptr->issBase
- + internal_sym.iss);
- if (!ecoff_set_symbol_info (abfd, &internal_sym,
- &internal_ptr->symbol, 0, 0))
- return false;
- internal_ptr->fdr = fdr_ptr;
- internal_ptr->local = true;
- internal_ptr->native = (PTR) lraw_src;
- }
- }
-
- ecoff_data (abfd)->canonical_symbols = internal;
-
- return true;
-}
-
-/* Return the amount of space needed for the canonical symbols. */
-
-long
-_bfd_ecoff_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL,
- &ecoff_data (abfd)->debug_info))
- return -1;
-
- if (bfd_get_symcount (abfd) == 0)
- return 0;
-
- return (bfd_get_symcount (abfd) + 1) * (sizeof (ecoff_symbol_type *));
-}
-
-/* Get the canonical symbols. */
-
-long
-_bfd_ecoff_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- unsigned int counter = 0;
- ecoff_symbol_type *symbase;
- ecoff_symbol_type **location = (ecoff_symbol_type **) alocation;
-
- if (_bfd_ecoff_slurp_symbol_table (abfd) == false)
- return -1;
- if (bfd_get_symcount (abfd) == 0)
- return 0;
-
- symbase = ecoff_data (abfd)->canonical_symbols;
- while (counter < bfd_get_symcount (abfd))
- {
- *(location++) = symbase++;
- counter++;
- }
- *location++ = (ecoff_symbol_type *) NULL;
- return bfd_get_symcount (abfd);
-}
-
-/* Turn ECOFF type information into a printable string.
- ecoff_emit_aggregate and ecoff_type_to_string are from
- gcc/mips-tdump.c, with swapping added and used_ptr removed. */
-
-/* Write aggregate information to a string. */
-
-static void
-ecoff_emit_aggregate (abfd, fdr, string, rndx, isym, which)
- bfd *abfd;
- FDR *fdr;
- char *string;
- RNDXR *rndx;
- long isym;
- const char *which;
-{
- const struct ecoff_debug_swap * const debug_swap =
- &ecoff_backend (abfd)->debug_swap;
- struct ecoff_debug_info * const debug_info = &ecoff_data (abfd)->debug_info;
- unsigned int ifd = rndx->rfd;
- unsigned int indx = rndx->index;
- const char *name;
-
- if (ifd == 0xfff)
- ifd = isym;
-
- /* An ifd of -1 is an opaque type. An escaped index of 0 is a
- struct return type of a procedure compiled without -g. */
- if (ifd == 0xffffffff
- || (rndx->rfd == 0xfff && indx == 0))
- name = "<undefined>";
- else if (indx == indexNil)
- name = "<no name>";
- else
- {
- SYMR sym;
-
- if (debug_info->external_rfd == NULL)
- fdr = debug_info->fdr + ifd;
- else
- {
- RFDT rfd;
-
- (*debug_swap->swap_rfd_in) (abfd,
- ((char *) debug_info->external_rfd
- + ((fdr->rfdBase + ifd)
- * debug_swap->external_rfd_size)),
- &rfd);
- fdr = debug_info->fdr + rfd;
- }
-
- indx += fdr->isymBase;
-
- (*debug_swap->swap_sym_in) (abfd,
- ((char *) debug_info->external_sym
- + indx * debug_swap->external_sym_size),
- &sym);
-
- name = debug_info->ss + fdr->issBase + sym.iss;
- }
-
- sprintf (string,
- "%s %s { ifd = %u, index = %lu }",
- which, name, ifd,
- ((long) indx
- + debug_info->symbolic_header.iextMax));
-}
-
-/* Convert the type information to string format. */
-
-static char *
-ecoff_type_to_string (abfd, fdr, indx)
- bfd *abfd;
- FDR *fdr;
- unsigned int indx;
-{
- union aux_ext *aux_ptr;
- int bigendian;
- AUXU u;
- struct qual {
- unsigned int type;
- int low_bound;
- int high_bound;
- int stride;
- } qualifiers[7];
- unsigned int basic_type;
- int i;
- char buffer1[1024];
- static char buffer2[1024];
- char *p1 = buffer1;
- char *p2 = buffer2;
- RNDXR rndx;
-
- aux_ptr = ecoff_data (abfd)->debug_info.external_aux + fdr->iauxBase;
- bigendian = fdr->fBigendian;
-
- for (i = 0; i < 7; i++)
- {
- qualifiers[i].low_bound = 0;
- qualifiers[i].high_bound = 0;
- qualifiers[i].stride = 0;
- }
-
- if (AUX_GET_ISYM (bigendian, &aux_ptr[indx]) == (bfd_vma) -1)
- return "-1 (no type)";
- _bfd_ecoff_swap_tir_in (bigendian, &aux_ptr[indx++].a_ti, &u.ti);
-
- basic_type = u.ti.bt;
- qualifiers[0].type = u.ti.tq0;
- qualifiers[1].type = u.ti.tq1;
- qualifiers[2].type = u.ti.tq2;
- qualifiers[3].type = u.ti.tq3;
- qualifiers[4].type = u.ti.tq4;
- qualifiers[5].type = u.ti.tq5;
- qualifiers[6].type = tqNil;
-
- /*
- * Go get the basic type.
- */
- switch (basic_type)
- {
- case btNil: /* undefined */
- strcpy (p1, "nil");
- break;
-
- case btAdr: /* address - integer same size as pointer */
- strcpy (p1, "address");
- break;
-
- case btChar: /* character */
- strcpy (p1, "char");
- break;
-
- case btUChar: /* unsigned character */
- strcpy (p1, "unsigned char");
- break;
-
- case btShort: /* short */
- strcpy (p1, "short");
- break;
-
- case btUShort: /* unsigned short */
- strcpy (p1, "unsigned short");
- break;
-
- case btInt: /* int */
- strcpy (p1, "int");
- break;
-
- case btUInt: /* unsigned int */
- strcpy (p1, "unsigned int");
- break;
-
- case btLong: /* long */
- strcpy (p1, "long");
- break;
-
- case btULong: /* unsigned long */
- strcpy (p1, "unsigned long");
- break;
-
- case btFloat: /* float (real) */
- strcpy (p1, "float");
- break;
-
- case btDouble: /* Double (real) */
- strcpy (p1, "double");
- break;
-
- /* Structures add 1-2 aux words:
- 1st word is [ST_RFDESCAPE, offset] pointer to struct def;
- 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
-
- case btStruct: /* Structure (Record) */
- _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
- ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
- (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
- "struct");
- indx++; /* skip aux words */
- break;
-
- /* Unions add 1-2 aux words:
- 1st word is [ST_RFDESCAPE, offset] pointer to union def;
- 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
-
- case btUnion: /* Union */
- _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
- ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
- (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
- "union");
- indx++; /* skip aux words */
- break;
-
- /* Enumerations add 1-2 aux words:
- 1st word is [ST_RFDESCAPE, offset] pointer to enum def;
- 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
-
- case btEnum: /* Enumeration */
- _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
- ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
- (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
- "enum");
- indx++; /* skip aux words */
- break;
-
- case btTypedef: /* defined via a typedef, isymRef points */
- strcpy (p1, "typedef");
- break;
-
- case btRange: /* subrange of int */
- strcpy (p1, "subrange");
- break;
-
- case btSet: /* pascal sets */
- strcpy (p1, "set");
- break;
-
- case btComplex: /* fortran complex */
- strcpy (p1, "complex");
- break;
-
- case btDComplex: /* fortran double complex */
- strcpy (p1, "double complex");
- break;
-
- case btIndirect: /* forward or unnamed typedef */
- strcpy (p1, "forward/unamed typedef");
- break;
-
- case btFixedDec: /* Fixed Decimal */
- strcpy (p1, "fixed decimal");
- break;
-
- case btFloatDec: /* Float Decimal */
- strcpy (p1, "float decimal");
- break;
-
- case btString: /* Varying Length Character String */
- strcpy (p1, "string");
- break;
-
- case btBit: /* Aligned Bit String */
- strcpy (p1, "bit");
- break;
-
- case btPicture: /* Picture */
- strcpy (p1, "picture");
- break;
-
- case btVoid: /* Void */
- strcpy (p1, "void");
- break;
-
- default:
- sprintf (p1, "Unknown basic type %d", (int) basic_type);
- break;
- }
-
- p1 += strlen (buffer1);
-
- /*
- * If this is a bitfield, get the bitsize.
- */
- if (u.ti.fBitfield)
- {
- int bitsize;
-
- bitsize = AUX_GET_WIDTH (bigendian, &aux_ptr[indx++]);
- sprintf (p1, " : %d", bitsize);
- p1 += strlen (buffer1);
- }
-
-
- /*
- * Deal with any qualifiers.
- */
- if (qualifiers[0].type != tqNil)
- {
- /*
- * Snarf up any array bounds in the correct order. Arrays
- * store 5 successive words in the aux. table:
- * word 0 RNDXR to type of the bounds (ie, int)
- * word 1 Current file descriptor index
- * word 2 low bound
- * word 3 high bound (or -1 if [])
- * word 4 stride size in bits
- */
- for (i = 0; i < 7; i++)
- {
- if (qualifiers[i].type == tqArray)
- {
- qualifiers[i].low_bound =
- AUX_GET_DNLOW (bigendian, &aux_ptr[indx+2]);
- qualifiers[i].high_bound =
- AUX_GET_DNHIGH (bigendian, &aux_ptr[indx+3]);
- qualifiers[i].stride =
- AUX_GET_WIDTH (bigendian, &aux_ptr[indx+4]);
- indx += 5;
- }
- }
-
- /*
- * Now print out the qualifiers.
- */
- for (i = 0; i < 6; i++)
- {
- switch (qualifiers[i].type)
- {
- case tqNil:
- case tqMax:
- break;
-
- case tqPtr:
- strcpy (p2, "ptr to ");
- p2 += sizeof ("ptr to ")-1;
- break;
-
- case tqVol:
- strcpy (p2, "volatile ");
- p2 += sizeof ("volatile ")-1;
- break;
-
- case tqFar:
- strcpy (p2, "far ");
- p2 += sizeof ("far ")-1;
- break;
-
- case tqProc:
- strcpy (p2, "func. ret. ");
- p2 += sizeof ("func. ret. ");
- break;
-
- case tqArray:
- {
- int first_array = i;
- int j;
-
- /* Print array bounds reversed (ie, in the order the C
- programmer writes them). C is such a fun language.... */
-
- while (i < 5 && qualifiers[i+1].type == tqArray)
- i++;
-
- for (j = i; j >= first_array; j--)
- {
- strcpy (p2, "array [");
- p2 += sizeof ("array [")-1;
- if (qualifiers[j].low_bound != 0)
- sprintf (p2,
- "%ld:%ld {%ld bits}",
- (long) qualifiers[j].low_bound,
- (long) qualifiers[j].high_bound,
- (long) qualifiers[j].stride);
-
- else if (qualifiers[j].high_bound != -1)
- sprintf (p2,
- "%ld {%ld bits}",
- (long) (qualifiers[j].high_bound + 1),
- (long) (qualifiers[j].stride));
-
- else
- sprintf (p2, " {%ld bits}", (long) (qualifiers[j].stride));
-
- p2 += strlen (p2);
- strcpy (p2, "] of ");
- p2 += sizeof ("] of ")-1;
- }
- }
- break;
- }
- }
- }
-
- strcpy (p2, buffer1);
- return buffer2;
-}
-
-/* Return information about ECOFF symbol SYMBOL in RET. */
-
-/*ARGSUSED*/
-void
-_bfd_ecoff_get_symbol_info (abfd, symbol, ret)
- bfd *abfd; /* Ignored. */
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-/* Return whether this is a local label. */
-
-/*ARGSUSED*/
-boolean
-_bfd_ecoff_bfd_is_local_label (abfd, symbol)
- bfd *abfd;
- asymbol *symbol;
-{
- return symbol->name[0] == '$';
-}
-
-/* Print information about an ECOFF symbol. */
-
-void
-_bfd_ecoff_print_symbol (abfd, filep, symbol, how)
- bfd *abfd;
- PTR filep;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- const struct ecoff_debug_swap * const debug_swap
- = &ecoff_backend (abfd)->debug_swap;
- FILE *file = (FILE *)filep;
-
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
- case bfd_print_symbol_more:
- if (ecoffsymbol (symbol)->local)
- {
- SYMR ecoff_sym;
-
- (*debug_swap->swap_sym_in) (abfd, ecoffsymbol (symbol)->native,
- &ecoff_sym);
- fprintf (file, "ecoff local ");
- fprintf_vma (file, (bfd_vma) ecoff_sym.value);
- fprintf (file, " %x %x", (unsigned) ecoff_sym.st,
- (unsigned) ecoff_sym.sc);
- }
- else
- {
- EXTR ecoff_ext;
-
- (*debug_swap->swap_ext_in) (abfd, ecoffsymbol (symbol)->native,
- &ecoff_ext);
- fprintf (file, "ecoff extern ");
- fprintf_vma (file, (bfd_vma) ecoff_ext.asym.value);
- fprintf (file, " %x %x", (unsigned) ecoff_ext.asym.st,
- (unsigned) ecoff_ext.asym.sc);
- }
- break;
- case bfd_print_symbol_all:
- /* Print out the symbols in a reasonable way */
- {
- char type;
- int pos;
- EXTR ecoff_ext;
- char jmptbl;
- char cobol_main;
- char weakext;
-
- if (ecoffsymbol (symbol)->local)
- {
- (*debug_swap->swap_sym_in) (abfd, ecoffsymbol (symbol)->native,
- &ecoff_ext.asym);
- type = 'l';
- pos = ((((char *) ecoffsymbol (symbol)->native
- - (char *) ecoff_data (abfd)->debug_info.external_sym)
- / debug_swap->external_sym_size)
- + ecoff_data (abfd)->debug_info.symbolic_header.iextMax);
- jmptbl = ' ';
- cobol_main = ' ';
- weakext = ' ';
- }
- else
- {
- (*debug_swap->swap_ext_in) (abfd, ecoffsymbol (symbol)->native,
- &ecoff_ext);
- type = 'e';
- pos = (((char *) ecoffsymbol (symbol)->native
- - (char *) ecoff_data (abfd)->debug_info.external_ext)
- / debug_swap->external_ext_size);
- jmptbl = ecoff_ext.jmptbl ? 'j' : ' ';
- cobol_main = ecoff_ext.cobol_main ? 'c' : ' ';
- weakext = ecoff_ext.weakext ? 'w' : ' ';
- }
-
- fprintf (file, "[%3d] %c ",
- pos, type);
- fprintf_vma (file, (bfd_vma) ecoff_ext.asym.value);
- fprintf (file, " st %x sc %x indx %x %c%c%c %s",
- (unsigned) ecoff_ext.asym.st,
- (unsigned) ecoff_ext.asym.sc,
- (unsigned) ecoff_ext.asym.index,
- jmptbl, cobol_main, weakext,
- symbol->name);
-
- if (ecoffsymbol (symbol)->fdr != NULL
- && ecoff_ext.asym.index != indexNil)
- {
- FDR *fdr;
- unsigned int indx;
- int bigendian;
- bfd_size_type sym_base;
- union aux_ext *aux_base;
-
- fdr = ecoffsymbol (symbol)->fdr;
- indx = ecoff_ext.asym.index;
-
- /* sym_base is used to map the fdr relative indices which
- appear in the file to the position number which we are
- using. */
- sym_base = fdr->isymBase;
- if (ecoffsymbol (symbol)->local)
- sym_base +=
- ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
-
- /* aux_base is the start of the aux entries for this file;
- asym.index is an offset from this. */
- aux_base = (ecoff_data (abfd)->debug_info.external_aux
- + fdr->iauxBase);
-
- /* The aux entries are stored in host byte order; the
- order is indicated by a bit in the fdr. */
- bigendian = fdr->fBigendian;
-
- /* This switch is basically from gcc/mips-tdump.c */
- switch (ecoff_ext.asym.st)
- {
- case stNil:
- case stLabel:
- break;
-
- case stFile:
- case stBlock:
- fprintf (file, "\n End+1 symbol: %ld",
- (long) (indx + sym_base));
- break;
-
- case stEnd:
- if (ecoff_ext.asym.sc == scText
- || ecoff_ext.asym.sc == scInfo)
- fprintf (file, "\n First symbol: %ld",
- (long) (indx + sym_base));
- else
- fprintf (file, "\n First symbol: %ld",
- ((long)
- (AUX_GET_ISYM (bigendian,
- &aux_base[ecoff_ext.asym.index])
- + sym_base)));
- break;
-
- case stProc:
- case stStaticProc:
- if (ECOFF_IS_STAB (&ecoff_ext.asym))
- ;
- else if (ecoffsymbol (symbol)->local)
- fprintf (file, "\n End+1 symbol: %-7ld Type: %s",
- ((long)
- (AUX_GET_ISYM (bigendian,
- &aux_base[ecoff_ext.asym.index])
- + sym_base)),
- ecoff_type_to_string (abfd, fdr, indx + 1));
- else
- fprintf (file, "\n Local symbol: %ld",
- ((long) indx
- + (long) sym_base
- + (ecoff_data (abfd)
- ->debug_info.symbolic_header.iextMax)));
- break;
-
- case stStruct:
- fprintf (file, "\n struct; End+1 symbol: %ld",
- (long) (indx + sym_base));
- break;
-
- case stUnion:
- fprintf (file, "\n union; End+1 symbol: %ld",
- (long) (indx + sym_base));
- break;
-
- case stEnum:
- fprintf (file, "\n enum; End+1 symbol: %ld",
- (long) (indx + sym_base));
- break;
-
- default:
- if (! ECOFF_IS_STAB (&ecoff_ext.asym))
- fprintf (file, "\n Type: %s",
- ecoff_type_to_string (abfd, fdr, indx));
- break;
- }
- }
- }
- break;
- }
-}
-
-/* Read in the relocs for a section. */
-
-static boolean
-ecoff_slurp_reloc_table (abfd, section, symbols)
- bfd *abfd;
- asection *section;
- asymbol **symbols;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- arelent *internal_relocs;
- bfd_size_type external_reloc_size;
- bfd_size_type external_relocs_size;
- char *external_relocs;
- arelent *rptr;
- unsigned int i;
-
- if (section->relocation != (arelent *) NULL
- || section->reloc_count == 0
- || (section->flags & SEC_CONSTRUCTOR) != 0)
- return true;
-
- if (_bfd_ecoff_slurp_symbol_table (abfd) == false)
- return false;
-
- internal_relocs = (arelent *) bfd_alloc (abfd,
- (sizeof (arelent)
- * section->reloc_count));
- external_reloc_size = backend->external_reloc_size;
- external_relocs_size = external_reloc_size * section->reloc_count;
- external_relocs = (char *) bfd_alloc (abfd, external_relocs_size);
- if (internal_relocs == (arelent *) NULL
- || external_relocs == (char *) NULL)
- return false;
- if (bfd_seek (abfd, section->rel_filepos, SEEK_SET) != 0)
- return false;
- if (bfd_read (external_relocs, 1, external_relocs_size, abfd)
- != external_relocs_size)
- return false;
-
- for (i = 0, rptr = internal_relocs; i < section->reloc_count; i++, rptr++)
- {
- struct internal_reloc intern;
-
- (*backend->swap_reloc_in) (abfd,
- external_relocs + i * external_reloc_size,
- &intern);
-
- if (intern.r_extern)
- {
- /* r_symndx is an index into the external symbols. */
- BFD_ASSERT (intern.r_symndx >= 0
- && (intern.r_symndx
- < (ecoff_data (abfd)
- ->debug_info.symbolic_header.iextMax)));
- rptr->sym_ptr_ptr = symbols + intern.r_symndx;
- rptr->addend = 0;
- }
- else if (intern.r_symndx == RELOC_SECTION_NONE
- || intern.r_symndx == RELOC_SECTION_ABS)
- {
- rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- rptr->addend = 0;
- }
- else
- {
- CONST char *sec_name;
- asection *sec;
-
- /* r_symndx is a section key. */
- switch (intern.r_symndx)
- {
- case RELOC_SECTION_TEXT: sec_name = ".text"; break;
- case RELOC_SECTION_RDATA: sec_name = ".rdata"; break;
- case RELOC_SECTION_DATA: sec_name = ".data"; break;
- case RELOC_SECTION_SDATA: sec_name = ".sdata"; break;
- case RELOC_SECTION_SBSS: sec_name = ".sbss"; break;
- case RELOC_SECTION_BSS: sec_name = ".bss"; break;
- case RELOC_SECTION_INIT: sec_name = ".init"; break;
- case RELOC_SECTION_LIT8: sec_name = ".lit8"; break;
- case RELOC_SECTION_LIT4: sec_name = ".lit4"; break;
- case RELOC_SECTION_XDATA: sec_name = ".xdata"; break;
- case RELOC_SECTION_PDATA: sec_name = ".pdata"; break;
- case RELOC_SECTION_FINI: sec_name = ".fini"; break;
- case RELOC_SECTION_LITA: sec_name = ".lita"; break;
- case RELOC_SECTION_RCONST: sec_name = ".rconst"; break;
- default: abort ();
- }
-
- sec = bfd_get_section_by_name (abfd, sec_name);
- if (sec == (asection *) NULL)
- abort ();
- rptr->sym_ptr_ptr = sec->symbol_ptr_ptr;
-
- rptr->addend = - bfd_get_section_vma (abfd, sec);
- }
-
- rptr->address = intern.r_vaddr - bfd_get_section_vma (abfd, section);
-
- /* Let the backend select the howto field and do any other
- required processing. */
- (*backend->adjust_reloc_in) (abfd, &intern, rptr);
- }
-
- bfd_release (abfd, external_relocs);
-
- section->relocation = internal_relocs;
-
- return true;
-}
-
-/* Get a canonical list of relocs. */
-
-long
-_bfd_ecoff_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd *abfd;
- asection *section;
- arelent **relptr;
- asymbol **symbols;
-{
- unsigned int count;
-
- if (section->flags & SEC_CONSTRUCTOR)
- {
- arelent_chain *chain;
-
- /* This section has relocs made up by us, not the file, so take
- them out of their chain and place them into the data area
- provided. */
- for (count = 0, chain = section->constructor_chain;
- count < section->reloc_count;
- count++, chain = chain->next)
- *relptr++ = &chain->relent;
- }
- else
- {
- arelent *tblptr;
-
- if (ecoff_slurp_reloc_table (abfd, section, symbols) == false)
- return -1;
-
- tblptr = section->relocation;
-
- for (count = 0; count < section->reloc_count; count++)
- *relptr++ = tblptr++;
- }
-
- *relptr = (arelent *) NULL;
-
- return section->reloc_count;
-}
-
-/* Provided a BFD, a section and an offset into the section, calculate
- and return the name of the source file and the line nearest to the
- wanted location. */
-
-/*ARGSUSED*/
-boolean
-_bfd_ecoff_find_nearest_line (abfd, section, ignore_symbols, offset,
- filename_ptr, functionname_ptr, retline_ptr)
- bfd *abfd;
- asection *section;
- asymbol **ignore_symbols;
- bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
- unsigned int *retline_ptr;
-{
- const struct ecoff_debug_swap * const debug_swap
- = &ecoff_backend (abfd)->debug_swap;
- struct ecoff_debug_info * const debug_info = &ecoff_data (abfd)->debug_info;
- struct ecoff_find_line *line_info;
-
- /* Make sure we have the FDR's. */
- if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL, debug_info)
- || bfd_get_symcount (abfd) == 0)
- return false;
-
- if (ecoff_data (abfd)->find_line_info == NULL)
- {
- ecoff_data (abfd)->find_line_info =
- ((struct ecoff_find_line *)
- bfd_alloc (abfd, sizeof (struct ecoff_find_line)));
- if (ecoff_data (abfd)->find_line_info == NULL)
- return false;
- ecoff_data (abfd)->find_line_info->find_buffer = NULL;
- ecoff_data (abfd)->find_line_info->fdrtab_len = 0;
- ecoff_data (abfd)->find_line_info->fdrtab = NULL;
- }
- line_info = ecoff_data (abfd)->find_line_info;
-
- return _bfd_ecoff_locate_line (abfd, section, offset, debug_info,
- debug_swap, line_info, filename_ptr,
- functionname_ptr, retline_ptr);
-}
-
-/* Copy private BFD data. This is called by objcopy and strip. We
- use it to copy the ECOFF debugging information from one BFD to the
- other. It would be theoretically possible to represent the ECOFF
- debugging information in the symbol table. However, it would be a
- lot of work, and there would be little gain (gas, gdb, and ld
- already access the ECOFF debugging information via the
- ecoff_debug_info structure, and that structure would have to be
- retained in order to support ECOFF debugging in MIPS ELF).
-
- The debugging information for the ECOFF external symbols comes from
- the symbol table, so this function only handles the other debugging
- information. */
-
-boolean
-_bfd_ecoff_bfd_copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- struct ecoff_debug_info *iinfo = &ecoff_data (ibfd)->debug_info;
- struct ecoff_debug_info *oinfo = &ecoff_data (obfd)->debug_info;
- register int i;
- asymbol **sym_ptr_ptr;
- size_t c;
- boolean local;
-
- /* This function is selected based on the input vector. We only
- want to copy information over if the output BFD also uses ECOFF
- format. */
- if (bfd_get_flavour (obfd) != bfd_target_ecoff_flavour)
- return true;
-
- /* Copy the GP value and the register masks. */
- ecoff_data (obfd)->gp = ecoff_data (ibfd)->gp;
- ecoff_data (obfd)->gprmask = ecoff_data (ibfd)->gprmask;
- ecoff_data (obfd)->fprmask = ecoff_data (ibfd)->fprmask;
- for (i = 0; i < 3; i++)
- ecoff_data (obfd)->cprmask[i] = ecoff_data (ibfd)->cprmask[i];
-
- /* Copy the version stamp. */
- oinfo->symbolic_header.vstamp = iinfo->symbolic_header.vstamp;
-
- /* If there are no symbols, don't copy any debugging information. */
- c = bfd_get_symcount (obfd);
- sym_ptr_ptr = bfd_get_outsymbols (obfd);
- if (c == 0 || sym_ptr_ptr == (asymbol **) NULL)
- return true;
-
- /* See if there are any local symbols. */
- local = false;
- for (; c > 0; c--, sym_ptr_ptr++)
- {
- if (ecoffsymbol (*sym_ptr_ptr)->local)
- {
- local = true;
- break;
- }
- }
-
- if (local)
- {
- /* There are some local symbols. We just bring over all the
- debugging information. FIXME: This is not quite the right
- thing to do. If the user has asked us to discard all
- debugging information, then we are probably going to wind up
- keeping it because there will probably be some local symbol
- which objcopy did not discard. We should actually break
- apart the debugging information and only keep that which
- applies to the symbols we want to keep. */
- oinfo->symbolic_header.ilineMax = iinfo->symbolic_header.ilineMax;
- oinfo->symbolic_header.cbLine = iinfo->symbolic_header.cbLine;
- oinfo->line = iinfo->line;
-
- oinfo->symbolic_header.idnMax = iinfo->symbolic_header.idnMax;
- oinfo->external_dnr = iinfo->external_dnr;
-
- oinfo->symbolic_header.ipdMax = iinfo->symbolic_header.ipdMax;
- oinfo->external_pdr = iinfo->external_pdr;
-
- oinfo->symbolic_header.isymMax = iinfo->symbolic_header.isymMax;
- oinfo->external_sym = iinfo->external_sym;
-
- oinfo->symbolic_header.ioptMax = iinfo->symbolic_header.ioptMax;
- oinfo->external_opt = iinfo->external_opt;
-
- oinfo->symbolic_header.iauxMax = iinfo->symbolic_header.iauxMax;
- oinfo->external_aux = iinfo->external_aux;
-
- oinfo->symbolic_header.issMax = iinfo->symbolic_header.issMax;
- oinfo->ss = iinfo->ss;
-
- oinfo->symbolic_header.ifdMax = iinfo->symbolic_header.ifdMax;
- oinfo->external_fdr = iinfo->external_fdr;
-
- oinfo->symbolic_header.crfd = iinfo->symbolic_header.crfd;
- oinfo->external_rfd = iinfo->external_rfd;
- }
- else
- {
- /* We are discarding all the local symbol information. Look
- through the external symbols and remove all references to FDR
- or aux information. */
- c = bfd_get_symcount (obfd);
- sym_ptr_ptr = bfd_get_outsymbols (obfd);
- for (; c > 0; c--, sym_ptr_ptr++)
- {
- EXTR esym;
-
- (*(ecoff_backend (obfd)->debug_swap.swap_ext_in))
- (obfd, ecoffsymbol (*sym_ptr_ptr)->native, &esym);
- esym.ifd = ifdNil;
- esym.asym.index = indexNil;
- (*(ecoff_backend (obfd)->debug_swap.swap_ext_out))
- (obfd, &esym, ecoffsymbol (*sym_ptr_ptr)->native);
- }
- }
-
- return true;
-}
-
-/* Set the architecture. The supported architecture is stored in the
- backend pointer. We always set the architecture anyhow, since many
- callers ignore the return value. */
-
-boolean
-_bfd_ecoff_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 == ecoff_backend (abfd)->arch;
-}
-
-/* Get the size of the section headers. */
-
-/*ARGSUSED*/
-int
-_bfd_ecoff_sizeof_headers (abfd, reloc)
- bfd *abfd;
- boolean reloc;
-{
- asection *current;
- int c;
- int ret;
-
- c = 0;
- for (current = abfd->sections;
- current != (asection *)NULL;
- current = current->next)
- ++c;
-
- ret = (bfd_coff_filhsz (abfd)
- + bfd_coff_aoutsz (abfd)
- + c * bfd_coff_scnhsz (abfd));
- return BFD_ALIGN (ret, 16);
-}
-
-/* Get the contents of a section. */
-
-boolean
-_bfd_ecoff_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- return _bfd_generic_get_section_contents (abfd, section, location,
- offset, count);
-}
-
-/* Sort sections by VMA, but put SEC_ALLOC sections first. This is
- called via qsort. */
-
-static int
-ecoff_sort_hdrs (arg1, arg2)
- const PTR arg1;
- const PTR arg2;
-{
- const asection *hdr1 = *(const asection **) arg1;
- const asection *hdr2 = *(const asection **) arg2;
-
- if ((hdr1->flags & SEC_ALLOC) != 0)
- {
- if ((hdr2->flags & SEC_ALLOC) == 0)
- return -1;
- }
- else
- {
- if ((hdr2->flags & SEC_ALLOC) != 0)
- return 1;
- }
- if (hdr1->vma < hdr2->vma)
- return -1;
- else if (hdr1->vma > hdr2->vma)
- return 1;
- else
- return 0;
-}
-
-/* Calculate the file position for each section, and set
- reloc_filepos. */
-
-static boolean
-ecoff_compute_section_file_positions (abfd)
- bfd *abfd;
-{
- file_ptr sofar;
- asection **sorted_hdrs;
- asection *current;
- unsigned int i;
- file_ptr old_sofar;
- boolean first_data, first_nonalloc;
- const bfd_vma round = ecoff_backend (abfd)->round;
-
- sofar = _bfd_ecoff_sizeof_headers (abfd, false);
-
- /* Sort the sections by VMA. */
- sorted_hdrs = (asection **) bfd_malloc (abfd->section_count
- * sizeof (asection *));
- if (sorted_hdrs == NULL)
- return false;
- for (current = abfd->sections, i = 0;
- current != NULL;
- current = current->next, i++)
- sorted_hdrs[i] = current;
- BFD_ASSERT (i == abfd->section_count);
-
- qsort (sorted_hdrs, abfd->section_count, sizeof (asection *),
- ecoff_sort_hdrs);
-
- first_data = true;
- first_nonalloc = true;
- for (i = 0; i < abfd->section_count; i++)
- {
- unsigned int alignment_power;
-
- current = sorted_hdrs[i];
-
- /* For the Alpha ECOFF .pdata section the lnnoptr field is
- supposed to indicate the number of .pdata entries that are
- really in the section. Each entry is 8 bytes. We store this
- away in line_filepos before increasing the section size. */
- if (strcmp (current->name, _PDATA) != 0)
- alignment_power = current->alignment_power;
- else
- {
- current->line_filepos = current->_raw_size / 8;
- alignment_power = 4;
- }
-
- /* On Ultrix, the data sections in an executable file must be
- aligned to a page boundary within the file. This does not
- affect the section size, though. FIXME: Does this work for
- other platforms? It requires some modification for the
- Alpha, because .rdata on the Alpha goes with the text, not
- the data. */
- if ((abfd->flags & EXEC_P) != 0
- && (abfd->flags & D_PAGED) != 0
- && ! first_data
- && (current->flags & SEC_CODE) == 0
- && (! ecoff_backend (abfd)->rdata_in_text
- || strcmp (current->name, _RDATA) != 0)
- && strcmp (current->name, _PDATA) != 0
- && strcmp (current->name, _RCONST) != 0)
- {
- sofar = (sofar + round - 1) &~ (round - 1);
- first_data = false;
- }
- else if (strcmp (current->name, _LIB) == 0)
- {
- /* On Irix 4, the location of contents of the .lib section
- from a shared library section is also rounded up to a
- page boundary. */
-
- sofar = (sofar + round - 1) &~ (round - 1);
- }
- else if (first_nonalloc
- && (current->flags & SEC_ALLOC) == 0
- && (abfd->flags & D_PAGED) != 0)
- {
- /* Skip up to the next page for an unallocated section, such
- as the .comment section on the Alpha. This leaves room
- for the .bss section. */
- first_nonalloc = false;
- sofar = (sofar + round - 1) &~ (round - 1);
- }
-
- /* Align the sections in the file to the same boundary on
- which they are aligned in virtual memory. */
- old_sofar = sofar;
- sofar = BFD_ALIGN (sofar, 1 << alignment_power);
-
- if ((abfd->flags & D_PAGED) != 0
- && (current->flags & SEC_ALLOC) != 0)
- sofar += (current->vma - sofar) % round;
-
- if ((current->flags & (SEC_HAS_CONTENTS | SEC_LOAD)) != 0)
- current->filepos = sofar;
-
- sofar += current->_raw_size;
-
- /* make sure that this section is of the right size too */
- old_sofar = sofar;
- sofar = BFD_ALIGN (sofar, 1 << alignment_power);
- current->_raw_size += sofar - old_sofar;
- }
-
- free (sorted_hdrs);
- sorted_hdrs = NULL;
-
- ecoff_data (abfd)->reloc_filepos = sofar;
-
- return true;
-}
-
-/* Determine the location of the relocs for all the sections in the
- output file, as well as the location of the symbolic debugging
- information. */
-
-static bfd_size_type
-ecoff_compute_reloc_file_positions (abfd)
- bfd *abfd;
-{
- const bfd_size_type external_reloc_size =
- ecoff_backend (abfd)->external_reloc_size;
- file_ptr reloc_base;
- bfd_size_type reloc_size;
- asection *current;
- file_ptr sym_base;
-
- if (! abfd->output_has_begun)
- {
- if (! ecoff_compute_section_file_positions (abfd))
- abort ();
- abfd->output_has_begun = true;
- }
-
- reloc_base = ecoff_data (abfd)->reloc_filepos;
-
- reloc_size = 0;
- for (current = abfd->sections;
- current != (asection *)NULL;
- current = current->next)
- {
- if (current->reloc_count == 0)
- current->rel_filepos = 0;
- else
- {
- bfd_size_type relsize;
-
- current->rel_filepos = reloc_base;
- relsize = current->reloc_count * external_reloc_size;
- reloc_size += relsize;
- reloc_base += relsize;
- }
- }
-
- sym_base = ecoff_data (abfd)->reloc_filepos + reloc_size;
-
- /* At least on Ultrix, the symbol table of an executable file must
- be aligned to a page boundary. FIXME: Is this true on other
- platforms? */
- if ((abfd->flags & EXEC_P) != 0
- && (abfd->flags & D_PAGED) != 0)
- sym_base = ((sym_base + ecoff_backend (abfd)->round - 1)
- &~ (ecoff_backend (abfd)->round - 1));
-
- ecoff_data (abfd)->sym_filepos = sym_base;
-
- return reloc_size;
-}
-
-/* Set the contents of a section. */
-
-boolean
-_bfd_ecoff_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- /* This must be done first, because bfd_set_section_contents is
- going to set output_has_begun to true. */
- if (abfd->output_has_begun == false)
- {
- if (! ecoff_compute_section_file_positions (abfd))
- return false;
- }
-
- /* If this is a .lib section, bump the vma address so that it winds
- up being the number of .lib sections output. This is right for
- Irix 4. Ian Taylor <ian@cygnus.com>. */
- if (strcmp (section->name, _LIB) == 0)
- ++section->vma;
-
- if (count == 0)
- return true;
-
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
- return false;
-
- return true;
-}
-
-/* Get the GP value for an ECOFF file. This is a hook used by
- nlmconv. */
-
-bfd_vma
-bfd_ecoff_get_gp_value (abfd)
- bfd *abfd;
-{
- if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour
- || bfd_get_format (abfd) != bfd_object)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return 0;
- }
-
- return ecoff_data (abfd)->gp;
-}
-
-/* Set the GP value for an ECOFF file. This is a hook used by the
- assembler. */
-
-boolean
-bfd_ecoff_set_gp_value (abfd, gp_value)
- bfd *abfd;
- bfd_vma gp_value;
-{
- if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour
- || bfd_get_format (abfd) != bfd_object)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- ecoff_data (abfd)->gp = gp_value;
-
- return true;
-}
-
-/* Set the register masks for an ECOFF file. This is a hook used by
- the assembler. */
-
-boolean
-bfd_ecoff_set_regmasks (abfd, gprmask, fprmask, cprmask)
- bfd *abfd;
- unsigned long gprmask;
- unsigned long fprmask;
- unsigned long *cprmask;
-{
- ecoff_data_type *tdata;
-
- if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour
- || bfd_get_format (abfd) != bfd_object)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- tdata = ecoff_data (abfd);
- tdata->gprmask = gprmask;
- tdata->fprmask = fprmask;
- if (cprmask != (unsigned long *) NULL)
- {
- register int i;
-
- for (i = 0; i < 3; i++)
- tdata->cprmask[i] = cprmask[i];
- }
-
- return true;
-}
-
-/* Get ECOFF EXTR information for an external symbol. This function
- is passed to bfd_ecoff_debug_externals. */
-
-static boolean
-ecoff_get_extr (sym, esym)
- asymbol *sym;
- EXTR *esym;
-{
- ecoff_symbol_type *ecoff_sym_ptr;
- bfd *input_bfd;
-
- if (bfd_asymbol_flavour (sym) != bfd_target_ecoff_flavour
- || ecoffsymbol (sym)->native == NULL)
- {
- /* Don't include debugging, local, or section symbols. */
- if ((sym->flags & BSF_DEBUGGING) != 0
- || (sym->flags & BSF_LOCAL) != 0
- || (sym->flags & BSF_SECTION_SYM) != 0)
- return false;
-
- esym->jmptbl = 0;
- esym->cobol_main = 0;
- esym->weakext = (sym->flags & BSF_WEAK) != 0;
- esym->reserved = 0;
- esym->ifd = ifdNil;
- /* FIXME: we can do better than this for st and sc. */
- esym->asym.st = stGlobal;
- esym->asym.sc = scAbs;
- esym->asym.reserved = 0;
- esym->asym.index = indexNil;
- return true;
- }
-
- ecoff_sym_ptr = ecoffsymbol (sym);
-
- if (ecoff_sym_ptr->local)
- return false;
-
- input_bfd = bfd_asymbol_bfd (sym);
- (*(ecoff_backend (input_bfd)->debug_swap.swap_ext_in))
- (input_bfd, ecoff_sym_ptr->native, esym);
-
- /* If the symbol was defined by the linker, then esym will be
- undefined but sym will not be. Get a better class for such a
- symbol. */
- if ((esym->asym.sc == scUndefined
- || esym->asym.sc == scSUndefined)
- && ! bfd_is_und_section (bfd_get_section (sym)))
- esym->asym.sc = scAbs;
-
- /* Adjust the FDR index for the symbol by that used for the input
- BFD. */
- if (esym->ifd != -1)
- {
- struct ecoff_debug_info *input_debug;
-
- input_debug = &ecoff_data (input_bfd)->debug_info;
- BFD_ASSERT (esym->ifd < input_debug->symbolic_header.ifdMax);
- if (input_debug->ifdmap != (RFDT *) NULL)
- esym->ifd = input_debug->ifdmap[esym->ifd];
- }
-
- return true;
-}
-
-/* Set the external symbol index. This routine is passed to
- bfd_ecoff_debug_externals. */
-
-static void
-ecoff_set_index (sym, indx)
- asymbol *sym;
- bfd_size_type indx;
-{
- ecoff_set_sym_index (sym, indx);
-}
-
-/* Write out an ECOFF file. */
-
-boolean
-_bfd_ecoff_write_object_contents (abfd)
- bfd *abfd;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- const bfd_vma round = backend->round;
- const bfd_size_type filhsz = bfd_coff_filhsz (abfd);
- const bfd_size_type aoutsz = bfd_coff_aoutsz (abfd);
- const bfd_size_type scnhsz = bfd_coff_scnhsz (abfd);
- const bfd_size_type external_hdr_size
- = backend->debug_swap.external_hdr_size;
- const bfd_size_type external_reloc_size = backend->external_reloc_size;
- void (* const adjust_reloc_out) PARAMS ((bfd *,
- const arelent *,
- struct internal_reloc *))
- = backend->adjust_reloc_out;
- void (* const swap_reloc_out) PARAMS ((bfd *,
- const struct internal_reloc *,
- PTR))
- = backend->swap_reloc_out;
- struct ecoff_debug_info * const debug = &ecoff_data (abfd)->debug_info;
- HDRR * const symhdr = &debug->symbolic_header;
- asection *current;
- unsigned int count;
- bfd_size_type reloc_size;
- bfd_size_type text_size;
- bfd_vma text_start;
- boolean set_text_start;
- bfd_size_type data_size;
- bfd_vma data_start;
- boolean set_data_start;
- bfd_size_type bss_size;
- PTR buff = NULL;
- PTR reloc_buff = NULL;
- struct internal_filehdr internal_f;
- struct internal_aouthdr internal_a;
- int i;
-
- /* Determine where the sections and relocs will go in the output
- file. */
- reloc_size = ecoff_compute_reloc_file_positions (abfd);
-
- count = 1;
- for (current = abfd->sections;
- current != (asection *)NULL;
- current = current->next)
- {
- current->target_index = count;
- ++count;
- }
-
- if ((abfd->flags & D_PAGED) != 0)
- text_size = _bfd_ecoff_sizeof_headers (abfd, false);
- else
- text_size = 0;
- text_start = 0;
- set_text_start = false;
- data_size = 0;
- data_start = 0;
- set_data_start = false;
- bss_size = 0;
-
- /* Write section headers to the file. */
-
- /* Allocate buff big enough to hold a section header,
- file header, or a.out header. */
- {
- bfd_size_type siz;
- siz = scnhsz;
- if (siz < filhsz)
- siz = filhsz;
- if (siz < aoutsz)
- siz = aoutsz;
- buff = (PTR) bfd_malloc ((size_t) siz);
- if (buff == NULL)
- goto error_return;
- }
-
- internal_f.f_nscns = 0;
- if (bfd_seek (abfd, (file_ptr) (filhsz + aoutsz), SEEK_SET) != 0)
- goto error_return;
- for (current = abfd->sections;
- current != (asection *) NULL;
- current = current->next)
- {
- struct internal_scnhdr section;
- bfd_vma vma;
-
- ++internal_f.f_nscns;
-
- strncpy (section.s_name, current->name, sizeof section.s_name);
-
- /* This seems to be correct for Irix 4 shared libraries. */
- vma = bfd_get_section_vma (abfd, current);
- if (strcmp (current->name, _LIB) == 0)
- section.s_vaddr = 0;
- else
- section.s_vaddr = vma;
-
- section.s_paddr = current->lma;
- section.s_size = bfd_get_section_size_before_reloc (current);
-
- /* If this section is unloadable then the scnptr will be 0. */
- if ((current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
- section.s_scnptr = 0;
- else
- section.s_scnptr = current->filepos;
- section.s_relptr = current->rel_filepos;
-
- /* FIXME: the lnnoptr of the .sbss or .sdata section of an
- object file produced by the assembler is supposed to point to
- information about how much room is required by objects of
- various different sizes. I think this only matters if we
- want the linker to compute the best size to use, or
- something. I don't know what happens if the information is
- not present. */
- if (strcmp (current->name, _PDATA) != 0)
- section.s_lnnoptr = 0;
- else
- {
- /* The Alpha ECOFF .pdata section uses the lnnoptr field to
- hold the number of entries in the section (each entry is
- 8 bytes). We stored this in the line_filepos field in
- ecoff_compute_section_file_positions. */
- section.s_lnnoptr = current->line_filepos;
- }
-
- section.s_nreloc = current->reloc_count;
- section.s_nlnno = 0;
- section.s_flags = ecoff_sec_to_styp_flags (current->name,
- current->flags);
-
- if (bfd_coff_swap_scnhdr_out (abfd, (PTR) &section, buff) == 0
- || bfd_write (buff, 1, scnhsz, abfd) != scnhsz)
- goto error_return;
-
- if ((section.s_flags & STYP_TEXT) != 0
- || ((section.s_flags & STYP_RDATA) != 0
- && backend->rdata_in_text)
- || section.s_flags == STYP_PDATA
- || (section.s_flags & STYP_DYNAMIC) != 0
- || (section.s_flags & STYP_LIBLIST) != 0
- || (section.s_flags & STYP_RELDYN) != 0
- || section.s_flags == STYP_CONFLIC
- || (section.s_flags & STYP_DYNSTR) != 0
- || (section.s_flags & STYP_DYNSYM) != 0
- || (section.s_flags & STYP_HASH) != 0
- || (section.s_flags & STYP_ECOFF_INIT) != 0
- || (section.s_flags & STYP_ECOFF_FINI) != 0
- || section.s_flags == STYP_RCONST)
- {
- text_size += bfd_get_section_size_before_reloc (current);
- if (! set_text_start || text_start > vma)
- {
- text_start = vma;
- set_text_start = true;
- }
- }
- else if ((section.s_flags & STYP_RDATA) != 0
- || (section.s_flags & STYP_DATA) != 0
- || (section.s_flags & STYP_LITA) != 0
- || (section.s_flags & STYP_LIT8) != 0
- || (section.s_flags & STYP_LIT4) != 0
- || (section.s_flags & STYP_SDATA) != 0
- || section.s_flags == STYP_XDATA
- || (section.s_flags & STYP_GOT) != 0)
- {
- data_size += bfd_get_section_size_before_reloc (current);
- if (! set_data_start || data_start > vma)
- {
- data_start = vma;
- set_data_start = true;
- }
- }
- else if ((section.s_flags & STYP_BSS) != 0
- || (section.s_flags & STYP_SBSS) != 0)
- bss_size += bfd_get_section_size_before_reloc (current);
- else if (section.s_flags == 0
- || (section.s_flags & STYP_ECOFF_LIB) != 0
- || section.s_flags == STYP_COMMENT)
- /* Do nothing */ ;
- else
- abort ();
- }
-
- /* Set up the file header. */
-
- internal_f.f_magic = ecoff_get_magic (abfd);
-
- /* We will NOT put a fucking timestamp in the header here. Every
- time you put it back, I will come in and take it out again. I'm
- sorry. This field does not belong here. We fill it with a 0 so
- it compares the same but is not a reasonable time. --
- gnu@cygnus.com. */
- internal_f.f_timdat = 0;
-
- if (bfd_get_symcount (abfd) != 0)
- {
- /* The ECOFF f_nsyms field is not actually the number of
- symbols, it's the size of symbolic information header. */
- internal_f.f_nsyms = external_hdr_size;
- internal_f.f_symptr = ecoff_data (abfd)->sym_filepos;
- }
- else
- {
- internal_f.f_nsyms = 0;
- internal_f.f_symptr = 0;
- }
-
- internal_f.f_opthdr = aoutsz;
-
- internal_f.f_flags = F_LNNO;
- if (reloc_size == 0)
- internal_f.f_flags |= F_RELFLG;
- if (bfd_get_symcount (abfd) == 0)
- internal_f.f_flags |= F_LSYMS;
- if (abfd->flags & EXEC_P)
- internal_f.f_flags |= F_EXEC;
-
- if (bfd_little_endian (abfd))
- internal_f.f_flags |= F_AR32WR;
- else
- internal_f.f_flags |= F_AR32W;
-
- /* Set up the ``optional'' header. */
- if ((abfd->flags & D_PAGED) != 0)
- internal_a.magic = ECOFF_AOUT_ZMAGIC;
- else
- internal_a.magic = ECOFF_AOUT_OMAGIC;
-
- /* FIXME: Is this really correct? */
- internal_a.vstamp = symhdr->vstamp;
-
- /* At least on Ultrix, these have to be rounded to page boundaries.
- FIXME: Is this true on other platforms? */
- if ((abfd->flags & D_PAGED) != 0)
- {
- internal_a.tsize = (text_size + round - 1) &~ (round - 1);
- internal_a.text_start = text_start &~ (round - 1);
- internal_a.dsize = (data_size + round - 1) &~ (round - 1);
- internal_a.data_start = data_start &~ (round - 1);
- }
- else
- {
- internal_a.tsize = text_size;
- internal_a.text_start = text_start;
- internal_a.dsize = data_size;
- internal_a.data_start = data_start;
- }
-
- /* On Ultrix, the initial portions of the .sbss and .bss segments
- are at the end of the data section. The bsize field in the
- optional header records how many bss bytes are required beyond
- those in the data section. The value is not rounded to a page
- boundary. */
- if (bss_size < internal_a.dsize - data_size)
- bss_size = 0;
- else
- bss_size -= internal_a.dsize - data_size;
- internal_a.bsize = bss_size;
- internal_a.bss_start = internal_a.data_start + internal_a.dsize;
-
- internal_a.entry = bfd_get_start_address (abfd);
-
- internal_a.gp_value = ecoff_data (abfd)->gp;
-
- internal_a.gprmask = ecoff_data (abfd)->gprmask;
- internal_a.fprmask = ecoff_data (abfd)->fprmask;
- for (i = 0; i < 4; i++)
- internal_a.cprmask[i] = ecoff_data (abfd)->cprmask[i];
-
- /* Let the backend adjust the headers if necessary. */
- if (backend->adjust_headers)
- {
- if (! (*backend->adjust_headers) (abfd, &internal_f, &internal_a))
- goto error_return;
- }
-
- /* Write out the file header and the optional header. */
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto error_return;
-
- bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, buff);
- if (bfd_write (buff, 1, filhsz, abfd) != filhsz)
- goto error_return;
-
- bfd_coff_swap_aouthdr_out (abfd, (PTR) &internal_a, buff);
- if (bfd_write (buff, 1, aoutsz, abfd) != aoutsz)
- goto error_return;
-
- /* Build the external symbol information. This must be done before
- writing out the relocs so that we know the symbol indices. We
- don't do this if this BFD was created by the backend linker,
- since it will have already handled the symbols and relocs. */
- if (! ecoff_data (abfd)->linker)
- {
- symhdr->iextMax = 0;
- symhdr->issExtMax = 0;
- debug->external_ext = debug->external_ext_end = NULL;
- debug->ssext = debug->ssext_end = NULL;
- if (bfd_ecoff_debug_externals (abfd, debug, &backend->debug_swap,
- (((abfd->flags & EXEC_P) == 0)
- ? true : false),
- ecoff_get_extr, ecoff_set_index)
- == false)
- goto error_return;
-
- /* Write out the relocs. */
- for (current = abfd->sections;
- current != (asection *) NULL;
- current = current->next)
- {
- arelent **reloc_ptr_ptr;
- arelent **reloc_end;
- char *out_ptr;
-
- if (current->reloc_count == 0)
- continue;
-
- reloc_buff =
- bfd_alloc (abfd, current->reloc_count * external_reloc_size);
- if (reloc_buff == NULL)
- goto error_return;
-
- reloc_ptr_ptr = current->orelocation;
- reloc_end = reloc_ptr_ptr + current->reloc_count;
- out_ptr = (char *) reloc_buff;
- for (;
- reloc_ptr_ptr < reloc_end;
- reloc_ptr_ptr++, out_ptr += external_reloc_size)
- {
- arelent *reloc;
- asymbol *sym;
- struct internal_reloc in;
-
- memset ((PTR) &in, 0, sizeof in);
-
- reloc = *reloc_ptr_ptr;
- sym = *reloc->sym_ptr_ptr;
-
- in.r_vaddr = (reloc->address
- + bfd_get_section_vma (abfd, current));
- in.r_type = reloc->howto->type;
-
- if ((sym->flags & BSF_SECTION_SYM) == 0)
- {
- in.r_symndx = ecoff_get_sym_index (*reloc->sym_ptr_ptr);
- in.r_extern = 1;
- }
- else
- {
- CONST char *name;
-
- name = bfd_get_section_name (abfd, bfd_get_section (sym));
- if (strcmp (name, ".text") == 0)
- in.r_symndx = RELOC_SECTION_TEXT;
- else if (strcmp (name, ".rdata") == 0)
- in.r_symndx = RELOC_SECTION_RDATA;
- else if (strcmp (name, ".data") == 0)
- in.r_symndx = RELOC_SECTION_DATA;
- else if (strcmp (name, ".sdata") == 0)
- in.r_symndx = RELOC_SECTION_SDATA;
- else if (strcmp (name, ".sbss") == 0)
- in.r_symndx = RELOC_SECTION_SBSS;
- else if (strcmp (name, ".bss") == 0)
- in.r_symndx = RELOC_SECTION_BSS;
- else if (strcmp (name, ".init") == 0)
- in.r_symndx = RELOC_SECTION_INIT;
- else if (strcmp (name, ".lit8") == 0)
- in.r_symndx = RELOC_SECTION_LIT8;
- else if (strcmp (name, ".lit4") == 0)
- in.r_symndx = RELOC_SECTION_LIT4;
- else if (strcmp (name, ".xdata") == 0)
- in.r_symndx = RELOC_SECTION_XDATA;
- else if (strcmp (name, ".pdata") == 0)
- in.r_symndx = RELOC_SECTION_PDATA;
- else if (strcmp (name, ".fini") == 0)
- in.r_symndx = RELOC_SECTION_FINI;
- else if (strcmp (name, ".lita") == 0)
- in.r_symndx = RELOC_SECTION_LITA;
- else if (strcmp (name, "*ABS*") == 0)
- in.r_symndx = RELOC_SECTION_ABS;
- else if (strcmp (name, ".rconst") == 0)
- in.r_symndx = RELOC_SECTION_RCONST;
- else
- abort ();
- in.r_extern = 0;
- }
-
- (*adjust_reloc_out) (abfd, reloc, &in);
-
- (*swap_reloc_out) (abfd, &in, (PTR) out_ptr);
- }
-
- if (bfd_seek (abfd, current->rel_filepos, SEEK_SET) != 0)
- goto error_return;
- if (bfd_write (reloc_buff,
- external_reloc_size, current->reloc_count, abfd)
- != external_reloc_size * current->reloc_count)
- goto error_return;
- bfd_release (abfd, reloc_buff);
- reloc_buff = NULL;
- }
-
- /* Write out the symbolic debugging information. */
- if (bfd_get_symcount (abfd) > 0)
- {
- /* Write out the debugging information. */
- if (bfd_ecoff_write_debug (abfd, debug, &backend->debug_swap,
- ecoff_data (abfd)->sym_filepos)
- == false)
- goto error_return;
- }
- }
-
- /* The .bss section of a demand paged executable must receive an
- entire page. If there are symbols, the symbols will start on the
- next page. If there are no symbols, we must fill out the page by
- hand. */
- if (bfd_get_symcount (abfd) == 0
- && (abfd->flags & EXEC_P) != 0
- && (abfd->flags & D_PAGED) != 0)
- {
- char c;
-
- if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
- SEEK_SET) != 0)
- goto error_return;
- if (bfd_read (&c, 1, 1, abfd) == 0)
- c = 0;
- if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
- SEEK_SET) != 0)
- goto error_return;
- if (bfd_write (&c, 1, 1, abfd) != 1)
- goto error_return;
- }
-
- if (reloc_buff != NULL)
- bfd_release (abfd, reloc_buff);
- if (buff != NULL)
- free (buff);
- return true;
- error_return:
- if (reloc_buff != NULL)
- bfd_release (abfd, reloc_buff);
- if (buff != NULL)
- free (buff);
- return false;
-}
-
-/* Archive handling. ECOFF uses what appears to be a unique type of
- archive header (armap). The byte ordering of the armap and the
- contents are encoded in the name of the armap itself. At least for
- now, we only support archives with the same byte ordering in the
- armap and the contents.
-
- The first four bytes in the armap are the number of symbol
- definitions. This is always a power of two.
-
- This is followed by the symbol definitions. Each symbol definition
- occupies 8 bytes. The first four bytes are the offset from the
- start of the armap strings to the null-terminated string naming
- this symbol. The second four bytes are the file offset to the
- archive member which defines this symbol. If the second four bytes
- are 0, then this is not actually a symbol definition, and it should
- be ignored.
-
- The symbols are hashed into the armap with a closed hashing scheme.
- See the functions below for the details of the algorithm.
-
- After the symbol definitions comes four bytes holding the size of
- the string table, followed by the string table itself. */
-
-/* The name of an archive headers looks like this:
- __________E[BL]E[BL]_ (with a trailing space).
- The trailing space is changed to an X if the archive is changed to
- indicate that the armap is out of date.
-
- The Alpha seems to use ________64E[BL]E[BL]_. */
-
-#define ARMAP_BIG_ENDIAN 'B'
-#define ARMAP_LITTLE_ENDIAN 'L'
-#define ARMAP_MARKER 'E'
-#define ARMAP_START_LENGTH 10
-#define ARMAP_HEADER_MARKER_INDEX 10
-#define ARMAP_HEADER_ENDIAN_INDEX 11
-#define ARMAP_OBJECT_MARKER_INDEX 12
-#define ARMAP_OBJECT_ENDIAN_INDEX 13
-#define ARMAP_END_INDEX 14
-#define ARMAP_END "_ "
-
-/* This is a magic number used in the hashing algorithm. */
-#define ARMAP_HASH_MAGIC 0x9dd68ab5
-
-/* This returns the hash value to use for a string. It also sets
- *REHASH to the rehash adjustment if the first slot is taken. SIZE
- is the number of entries in the hash table, and HLOG is the log
- base 2 of SIZE. */
-
-static unsigned int
-ecoff_armap_hash (s, rehash, size, hlog)
- CONST char *s;
- unsigned int *rehash;
- unsigned int size;
- unsigned int hlog;
-{
- unsigned int hash;
-
- hash = *s++;
- while (*s != '\0')
- hash = ((hash >> 27) | (hash << 5)) + *s++;
- hash *= ARMAP_HASH_MAGIC;
- *rehash = (hash & (size - 1)) | 1;
- return hash >> (32 - hlog);
-}
-
-/* Read in the armap. */
-
-boolean
-_bfd_ecoff_slurp_armap (abfd)
- bfd *abfd;
-{
- char nextname[17];
- unsigned int i;
- struct areltdata *mapdata;
- bfd_size_type parsed_size;
- char *raw_armap;
- struct artdata *ardata;
- unsigned int count;
- char *raw_ptr;
- struct symdef *symdef_ptr;
- char *stringbase;
-
- /* Get the name of the first element. */
- i = bfd_read ((PTR) nextname, 1, 16, abfd);
- if (i == 0)
- return true;
- if (i != 16)
- return false;
-
- if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
- return false;
-
- /* Irix 4.0.5F apparently can use either an ECOFF armap or a
- standard COFF armap. We could move the ECOFF armap stuff into
- bfd_slurp_armap, but that seems inappropriate since no other
- target uses this format. Instead, we check directly for a COFF
- armap. */
- if (strncmp (nextname, "/ ", 16) == 0)
- return bfd_slurp_armap (abfd);
-
- /* See if the first element is an armap. */
- if (strncmp (nextname, ecoff_backend (abfd)->armap_start,
- ARMAP_START_LENGTH) != 0
- || nextname[ARMAP_HEADER_MARKER_INDEX] != ARMAP_MARKER
- || (nextname[ARMAP_HEADER_ENDIAN_INDEX] != ARMAP_BIG_ENDIAN
- && nextname[ARMAP_HEADER_ENDIAN_INDEX] != ARMAP_LITTLE_ENDIAN)
- || nextname[ARMAP_OBJECT_MARKER_INDEX] != ARMAP_MARKER
- || (nextname[ARMAP_OBJECT_ENDIAN_INDEX] != ARMAP_BIG_ENDIAN
- && nextname[ARMAP_OBJECT_ENDIAN_INDEX] != ARMAP_LITTLE_ENDIAN)
- || strncmp (nextname + ARMAP_END_INDEX,
- ARMAP_END, sizeof ARMAP_END - 1) != 0)
- {
- bfd_has_map (abfd) = false;
- return true;
- }
-
- /* Make sure we have the right byte ordering. */
- if (((nextname[ARMAP_HEADER_ENDIAN_INDEX] == ARMAP_BIG_ENDIAN)
- ^ (bfd_header_big_endian (abfd)))
- || ((nextname[ARMAP_OBJECT_ENDIAN_INDEX] == ARMAP_BIG_ENDIAN)
- ^ (bfd_big_endian (abfd))))
- {
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- /* Read in the armap. */
- ardata = bfd_ardata (abfd);
- mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (mapdata == (struct areltdata *) NULL)
- return false;
- parsed_size = mapdata->parsed_size;
- bfd_release (abfd, (PTR) mapdata);
-
- raw_armap = (char *) bfd_alloc (abfd, parsed_size);
- if (raw_armap == (char *) NULL)
- return false;
-
- if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- bfd_release (abfd, (PTR) raw_armap);
- return false;
- }
-
- ardata->tdata = (PTR) raw_armap;
-
- count = bfd_h_get_32 (abfd, (PTR) raw_armap);
-
- ardata->symdef_count = 0;
- ardata->cache = (struct ar_cache *) NULL;
-
- /* This code used to overlay the symdefs over the raw archive data,
- but that doesn't work on a 64 bit host. */
-
- stringbase = raw_armap + count * 8 + 8;
-
-#ifdef CHECK_ARMAP_HASH
- {
- unsigned int hlog;
-
- /* Double check that I have the hashing algorithm right by making
- sure that every symbol can be looked up successfully. */
- hlog = 0;
- for (i = 1; i < count; i <<= 1)
- hlog++;
- BFD_ASSERT (i == count);
-
- raw_ptr = raw_armap + 4;
- for (i = 0; i < count; i++, raw_ptr += 8)
- {
- unsigned int name_offset, file_offset;
- unsigned int hash, rehash, srch;
-
- name_offset = bfd_h_get_32 (abfd, (PTR) raw_ptr);
- file_offset = bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4));
- if (file_offset == 0)
- continue;
- hash = ecoff_armap_hash (stringbase + name_offset, &rehash, count,
- hlog);
- if (hash == i)
- continue;
-
- /* See if we can rehash to this location. */
- for (srch = (hash + rehash) & (count - 1);
- srch != hash && srch != i;
- srch = (srch + rehash) & (count - 1))
- BFD_ASSERT (bfd_h_get_32 (abfd, (PTR) (raw_armap + 8 + srch * 8))
- != 0);
- BFD_ASSERT (srch == i);
- }
- }
-
-#endif /* CHECK_ARMAP_HASH */
-
- raw_ptr = raw_armap + 4;
- for (i = 0; i < count; i++, raw_ptr += 8)
- if (bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4)) != 0)
- ++ardata->symdef_count;
-
- symdef_ptr = ((struct symdef *)
- bfd_alloc (abfd,
- ardata->symdef_count * sizeof (struct symdef)));
- if (!symdef_ptr)
- return false;
-
- ardata->symdefs = (carsym *) symdef_ptr;
-
- raw_ptr = raw_armap + 4;
- for (i = 0; i < count; i++, raw_ptr += 8)
- {
- unsigned int name_offset, file_offset;
-
- file_offset = bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4));
- if (file_offset == 0)
- continue;
- name_offset = bfd_h_get_32 (abfd, (PTR) raw_ptr);
- symdef_ptr->s.name = stringbase + name_offset;
- symdef_ptr->file_offset = file_offset;
- ++symdef_ptr;
- }
-
- ardata->first_file_filepos = bfd_tell (abfd);
- /* Pad to an even boundary. */
- ardata->first_file_filepos += ardata->first_file_filepos % 2;
-
- bfd_has_map (abfd) = true;
-
- return true;
-}
-
-/* Write out an armap. */
-
-boolean
-_bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx)
- bfd *abfd;
- unsigned int elength;
- struct orl *map;
- unsigned int orl_count;
- int stridx;
-{
- unsigned int hashsize, hashlog;
- unsigned int symdefsize;
- int padit;
- unsigned int stringsize;
- unsigned int mapsize;
- file_ptr firstreal;
- struct ar_hdr hdr;
- struct stat statbuf;
- unsigned int i;
- bfd_byte temp[4];
- bfd_byte *hashtable;
- bfd *current;
- bfd *last_elt;
-
- /* Ultrix appears to use as a hash table size the least power of two
- greater than twice the number of entries. */
- for (hashlog = 0; (1 << hashlog) <= 2 * orl_count; hashlog++)
- ;
- hashsize = 1 << hashlog;
-
- symdefsize = hashsize * 8;
- padit = stridx % 2;
- stringsize = stridx + padit;
-
- /* Include 8 bytes to store symdefsize and stringsize in output. */
- mapsize = symdefsize + stringsize + 8;
-
- firstreal = SARMAG + sizeof (struct ar_hdr) + mapsize + elength;
-
- memset ((PTR) &hdr, 0, sizeof hdr);
-
- /* Work out the ECOFF armap name. */
- strcpy (hdr.ar_name, ecoff_backend (abfd)->armap_start);
- hdr.ar_name[ARMAP_HEADER_MARKER_INDEX] = ARMAP_MARKER;
- hdr.ar_name[ARMAP_HEADER_ENDIAN_INDEX] =
- (bfd_header_big_endian (abfd)
- ? ARMAP_BIG_ENDIAN
- : ARMAP_LITTLE_ENDIAN);
- hdr.ar_name[ARMAP_OBJECT_MARKER_INDEX] = ARMAP_MARKER;
- hdr.ar_name[ARMAP_OBJECT_ENDIAN_INDEX] =
- bfd_big_endian (abfd) ? ARMAP_BIG_ENDIAN : ARMAP_LITTLE_ENDIAN;
- memcpy (hdr.ar_name + ARMAP_END_INDEX, ARMAP_END, sizeof ARMAP_END - 1);
-
- /* Write the timestamp of the archive header to be just a little bit
- later than the timestamp of the file, otherwise the linker will
- complain that the index is out of date. Actually, the Ultrix
- linker just checks the archive name; the GNU linker may check the
- date. */
- stat (abfd->filename, &statbuf);
- sprintf (hdr.ar_date, "%ld", (long) (statbuf.st_mtime + 60));
-
- /* The DECstation uses zeroes for the uid, gid and mode of the
- armap. */
- hdr.ar_uid[0] = '0';
- hdr.ar_gid[0] = '0';
- hdr.ar_mode[0] = '0';
-
- sprintf (hdr.ar_size, "%-10d", (int) mapsize);
-
- hdr.ar_fmag[0] = '`';
- hdr.ar_fmag[1] = '\012';
-
- /* Turn all null bytes in the header into spaces. */
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *)(&hdr))[i] == '\0')
- (((char *)(&hdr))[i]) = ' ';
-
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
- return false;
-
- bfd_h_put_32 (abfd, (bfd_vma) hashsize, temp);
- if (bfd_write ((PTR) temp, 1, 4, abfd) != 4)
- return false;
-
- hashtable = (bfd_byte *) bfd_zalloc (abfd, symdefsize);
- if (!hashtable)
- return false;
-
- current = abfd->archive_head;
- last_elt = current;
- for (i = 0; i < orl_count; i++)
- {
- unsigned int hash, rehash;
-
- /* Advance firstreal to the file position of this archive
- element. */
- if (((bfd *) map[i].pos) != last_elt)
- {
- do
- {
- firstreal += arelt_size (current) + sizeof (struct ar_hdr);
- firstreal += firstreal % 2;
- current = current->next;
- }
- while (current != (bfd *) map[i].pos);
- }
-
- last_elt = current;
-
- hash = ecoff_armap_hash (*map[i].name, &rehash, hashsize, hashlog);
- if (bfd_h_get_32 (abfd, (PTR) (hashtable + (hash * 8) + 4)) != 0)
- {
- unsigned int srch;
-
- /* The desired slot is already taken. */
- for (srch = (hash + rehash) & (hashsize - 1);
- srch != hash;
- srch = (srch + rehash) & (hashsize - 1))
- if (bfd_h_get_32 (abfd, (PTR) (hashtable + (srch * 8) + 4)) == 0)
- break;
-
- BFD_ASSERT (srch != hash);
-
- hash = srch;
- }
-
- bfd_h_put_32 (abfd, (bfd_vma) map[i].namidx,
- (PTR) (hashtable + hash * 8));
- bfd_h_put_32 (abfd, (bfd_vma) firstreal,
- (PTR) (hashtable + hash * 8 + 4));
- }
-
- if (bfd_write ((PTR) hashtable, 1, symdefsize, abfd) != symdefsize)
- return false;
-
- bfd_release (abfd, hashtable);
-
- /* Now write the strings. */
- bfd_h_put_32 (abfd, (bfd_vma) stringsize, temp);
- if (bfd_write ((PTR) temp, 1, 4, abfd) != 4)
- return false;
- for (i = 0; i < orl_count; i++)
- {
- bfd_size_type len;
-
- len = strlen (*map[i].name) + 1;
- if (bfd_write ((PTR) (*map[i].name), 1, len, abfd) != len)
- return false;
- }
-
- /* The spec sez this should be a newline. But in order to be
- bug-compatible for DECstation ar we use a null. */
- if (padit)
- {
- if (bfd_write ("", 1, 1, abfd) != 1)
- return false;
- }
-
- return true;
-}
-
-/* See whether this BFD is an archive. If it is, read in the armap
- and the extended name table. */
-
-const bfd_target *
-_bfd_ecoff_archive_p (abfd)
- bfd *abfd;
-{
- char armag[SARMAG + 1];
-
- if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG
- || strncmp (armag, ARMAG, SARMAG) != 0)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return (const bfd_target *) 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 (const bfd_target *) NULL;
-
- bfd_ardata (abfd)->first_file_filepos = SARMAG;
- 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 = NULL;
-
- if (_bfd_ecoff_slurp_armap (abfd) == false
- || _bfd_ecoff_slurp_extended_name_table (abfd) == false)
- {
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = (struct artdata *) NULL;
- return (const bfd_target *) NULL;
- }
-
- return abfd->xvec;
-}
-
-/* ECOFF linker code. */
-
-static struct bfd_hash_entry *ecoff_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string));
-static boolean ecoff_link_add_archive_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean ecoff_link_check_archive_element
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
-static boolean ecoff_link_add_object_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean ecoff_link_add_externals
- PARAMS ((bfd *, struct bfd_link_info *, PTR, char *));
-
-/* Routine to create an entry in an ECOFF link hash table. */
-
-static struct bfd_hash_entry *
-ecoff_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct ecoff_link_hash_entry *ret = (struct ecoff_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct ecoff_link_hash_entry *) NULL)
- ret = ((struct ecoff_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct ecoff_link_hash_entry)));
- if (ret == (struct ecoff_link_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct ecoff_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
-
- if (ret)
- {
- /* Set local fields. */
- ret->indx = -1;
- ret->abfd = NULL;
- ret->written = 0;
- ret->small = 0;
- }
- memset ((PTR) &ret->esym, 0, sizeof ret->esym);
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create an ECOFF link hash table. */
-
-struct bfd_link_hash_table *
-_bfd_ecoff_bfd_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct ecoff_link_hash_table *ret;
-
- ret = ((struct ecoff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct ecoff_link_hash_table)));
- if (ret == NULL)
- return NULL;
- if (! _bfd_link_hash_table_init (&ret->root, abfd,
- ecoff_link_hash_newfunc))
- {
- free (ret);
- return (struct bfd_link_hash_table *) NULL;
- }
- return &ret->root;
-}
-
-/* Look up an entry in an ECOFF link hash table. */
-
-#define ecoff_link_hash_lookup(table, string, create, copy, follow) \
- ((struct ecoff_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
-
-/* Traverse an ECOFF link hash table. */
-
-#define ecoff_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the ECOFF link hash table from the info structure. This is
- just a cast. */
-
-#define ecoff_hash_table(p) ((struct ecoff_link_hash_table *) ((p)->hash))
-
-/* Given an ECOFF BFD, add symbols to the global hash table as
- appropriate. */
-
-boolean
-_bfd_ecoff_bfd_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- switch (bfd_get_format (abfd))
- {
- case bfd_object:
- return ecoff_link_add_object_symbols (abfd, info);
- case bfd_archive:
- return ecoff_link_add_archive_symbols (abfd, info);
- default:
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-}
-
-/* Add the symbols from an archive file to the global hash table.
- This looks through the undefined symbols, looks each one up in the
- archive hash table, and adds any associated object file. We do not
- use _bfd_generic_link_add_archive_symbols because ECOFF archives
- already have a hash table, so there is no reason to construct
- another one. */
-
-static boolean
-ecoff_link_add_archive_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- const bfd_byte *raw_armap;
- struct bfd_link_hash_entry **pundef;
- unsigned int armap_count;
- unsigned int armap_log;
- unsigned int i;
- const bfd_byte *hashtable;
- const char *stringbase;
-
- 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;
- }
-
- /* If we don't have any raw data for this archive, as can happen on
- Irix 4.0.5F, we call the generic routine.
- FIXME: We should be more clever about this, since someday tdata
- may get to something for a generic archive. */
- raw_armap = (const bfd_byte *) bfd_ardata (abfd)->tdata;
- if (raw_armap == (bfd_byte *) NULL)
- return (_bfd_generic_link_add_archive_symbols
- (abfd, info, ecoff_link_check_archive_element));
-
- armap_count = bfd_h_get_32 (abfd, raw_armap);
-
- armap_log = 0;
- for (i = 1; i < armap_count; i <<= 1)
- armap_log++;
- BFD_ASSERT (i == armap_count);
-
- hashtable = raw_armap + 4;
- stringbase = (const char *) raw_armap + armap_count * 8 + 8;
-
- /* Look through the list of undefined symbols. */
- pundef = &info->hash->undefs;
- while (*pundef != (struct bfd_link_hash_entry *) NULL)
- {
- struct bfd_link_hash_entry *h;
- unsigned int hash, rehash;
- unsigned int file_offset;
- const char *name;
- bfd *element;
-
- h = *pundef;
-
- /* When a symbol is defined, it is not necessarily removed from
- the list. */
- if (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common)
- {
- /* Remove this entry from the list, for general cleanliness
- and because we are going to look through the list again
- if we search any more libraries. We can't remove the
- entry if it is the tail, because that would lose any
- entries we add to the list later on. */
- if (*pundef != info->hash->undefs_tail)
- *pundef = (*pundef)->next;
- else
- pundef = &(*pundef)->next;
- continue;
- }
-
- /* Native ECOFF linkers do not pull in archive elements merely
- to satisfy common definitions, so neither do we. We leave
- them on the list, though, in case we are linking against some
- other object format. */
- if (h->type != bfd_link_hash_undefined)
- {
- pundef = &(*pundef)->next;
- continue;
- }
-
- /* Look for this symbol in the archive hash table. */
- hash = ecoff_armap_hash (h->root.string, &rehash, armap_count,
- armap_log);
-
- file_offset = bfd_h_get_32 (abfd, hashtable + (hash * 8) + 4);
- if (file_offset == 0)
- {
- /* Nothing in this slot. */
- pundef = &(*pundef)->next;
- continue;
- }
-
- name = stringbase + bfd_h_get_32 (abfd, hashtable + (hash * 8));
- if (name[0] != h->root.string[0]
- || strcmp (name, h->root.string) != 0)
- {
- unsigned int srch;
- boolean found;
-
- /* That was the wrong symbol. Try rehashing. */
- found = false;
- for (srch = (hash + rehash) & (armap_count - 1);
- srch != hash;
- srch = (srch + rehash) & (armap_count - 1))
- {
- file_offset = bfd_h_get_32 (abfd, hashtable + (srch * 8) + 4);
- if (file_offset == 0)
- break;
- name = stringbase + bfd_h_get_32 (abfd, hashtable + (srch * 8));
- if (name[0] == h->root.string[0]
- && strcmp (name, h->root.string) == 0)
- {
- found = true;
- break;
- }
- }
-
- if (! found)
- {
- pundef = &(*pundef)->next;
- continue;
- }
-
- hash = srch;
- }
-
- element = (*backend->get_elt_at_filepos) (abfd, file_offset);
- if (element == (bfd *) NULL)
- return false;
-
- if (! bfd_check_format (element, bfd_object))
- return false;
-
- /* Unlike the generic linker, we know that this element provides
- a definition for an undefined symbol and we know that we want
- to include it. We don't need to check anything. */
- if (! (*info->callbacks->add_archive_element) (info, element, name))
- return false;
- if (! ecoff_link_add_object_symbols (element, info))
- return false;
-
- pundef = &(*pundef)->next;
- }
-
- return true;
-}
-
-/* This is called if we used _bfd_generic_link_add_archive_symbols
- because we were not dealing with an ECOFF archive. */
-
-static boolean
-ecoff_link_check_archive_element (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
- = backend->debug_swap.swap_ext_in;
- HDRR *symhdr;
- bfd_size_type external_ext_size;
- PTR external_ext = NULL;
- size_t esize;
- char *ssext = NULL;
- char *ext_ptr;
- char *ext_end;
-
- *pneeded = false;
-
- if (! ecoff_slurp_symbolic_header (abfd))
- goto error_return;
-
- /* If there are no symbols, we don't want it. */
- if (bfd_get_symcount (abfd) == 0)
- goto successful_return;
-
- symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
-
- /* Read in the external symbols and external strings. */
- external_ext_size = backend->debug_swap.external_ext_size;
- esize = symhdr->iextMax * external_ext_size;
- external_ext = (PTR) bfd_malloc (esize);
- if (external_ext == NULL && esize != 0)
- goto error_return;
-
- if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
- || bfd_read (external_ext, 1, esize, abfd) != esize)
- goto error_return;
-
- ssext = (char *) bfd_malloc (symhdr->issExtMax);
- if (ssext == NULL && symhdr->issExtMax != 0)
- goto error_return;
-
- if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
- || (bfd_read (ssext, 1, symhdr->issExtMax, abfd) !=
- (bfd_size_type) symhdr->issExtMax))
- goto error_return;
-
- /* Look through the external symbols to see if they define some
- symbol that is currently undefined. */
- ext_ptr = (char *) external_ext;
- ext_end = ext_ptr + esize;
- for (; ext_ptr < ext_end; ext_ptr += external_ext_size)
- {
- EXTR esym;
- boolean def;
- const char *name;
- struct bfd_link_hash_entry *h;
-
- (*swap_ext_in) (abfd, (PTR) ext_ptr, &esym);
-
- /* See if this symbol defines something. */
- if (esym.asym.st != stGlobal
- && esym.asym.st != stLabel
- && esym.asym.st != stProc)
- continue;
-
- switch (esym.asym.sc)
- {
- case scText:
- case scData:
- case scBss:
- case scAbs:
- case scSData:
- case scSBss:
- case scRData:
- case scCommon:
- case scSCommon:
- case scInit:
- case scFini:
- case scRConst:
- def = true;
- break;
- default:
- def = false;
- break;
- }
-
- if (! def)
- continue;
-
- name = ssext + esym.asym.iss;
- h = bfd_link_hash_lookup (info->hash, name, false, false, true);
-
- /* Unlike the generic linker, we do not pull in elements because
- of common symbols. */
- if (h == (struct bfd_link_hash_entry *) NULL
- || h->type != bfd_link_hash_undefined)
- continue;
-
- /* Include this element. */
- if (! (*info->callbacks->add_archive_element) (info, abfd, name))
- goto error_return;
- if (! ecoff_link_add_externals (abfd, info, external_ext, ssext))
- goto error_return;
-
- *pneeded = true;
- goto successful_return;
- }
-
- successful_return:
- if (external_ext != NULL)
- free (external_ext);
- if (ssext != NULL)
- free (ssext);
- return true;
- error_return:
- if (external_ext != NULL)
- free (external_ext);
- if (ssext != NULL)
- free (ssext);
- return false;
-}
-
-/* Add symbols from an ECOFF object file to the global linker hash
- table. */
-
-static boolean
-ecoff_link_add_object_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- HDRR *symhdr;
- bfd_size_type external_ext_size;
- PTR external_ext = NULL;
- size_t esize;
- char *ssext = NULL;
- boolean result;
-
- if (! ecoff_slurp_symbolic_header (abfd))
- return false;
-
- /* If there are no symbols, we don't want it. */
- if (bfd_get_symcount (abfd) == 0)
- return true;
-
- symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
-
- /* Read in the external symbols and external strings. */
- external_ext_size = ecoff_backend (abfd)->debug_swap.external_ext_size;
- esize = symhdr->iextMax * external_ext_size;
- external_ext = (PTR) bfd_malloc (esize);
- if (external_ext == NULL && esize != 0)
- goto error_return;
-
- if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
- || bfd_read (external_ext, 1, esize, abfd) != esize)
- goto error_return;
-
- ssext = (char *) bfd_malloc (symhdr->issExtMax);
- if (ssext == NULL && symhdr->issExtMax != 0)
- goto error_return;
-
- if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
- || (bfd_read (ssext, 1, symhdr->issExtMax, abfd)
- != (bfd_size_type) symhdr->issExtMax))
- goto error_return;
-
- result = ecoff_link_add_externals (abfd, info, external_ext, ssext);
-
- if (ssext != NULL)
- free (ssext);
- if (external_ext != NULL)
- free (external_ext);
- return result;
-
- error_return:
- if (ssext != NULL)
- free (ssext);
- if (external_ext != NULL)
- free (external_ext);
- return false;
-}
-
-/* Add the external symbols of an object file to the global linker
- hash table. The external symbols and strings we are passed are
- just allocated on the stack, and will be discarded. We must
- explicitly save any information we may need later on in the link.
- We do not want to read the external symbol information again. */
-
-static boolean
-ecoff_link_add_externals (abfd, info, external_ext, ssext)
- bfd *abfd;
- struct bfd_link_info *info;
- PTR external_ext;
- char *ssext;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
- = backend->debug_swap.swap_ext_in;
- bfd_size_type external_ext_size = backend->debug_swap.external_ext_size;
- unsigned long ext_count;
- struct ecoff_link_hash_entry **sym_hash;
- char *ext_ptr;
- char *ext_end;
-
- ext_count = ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
-
- sym_hash = ((struct ecoff_link_hash_entry **)
- bfd_alloc (abfd,
- ext_count * sizeof (struct bfd_link_hash_entry *)));
- if (!sym_hash)
- return false;
- ecoff_data (abfd)->sym_hashes = sym_hash;
-
- ext_ptr = (char *) external_ext;
- ext_end = ext_ptr + ext_count * external_ext_size;
- for (; ext_ptr < ext_end; ext_ptr += external_ext_size, sym_hash++)
- {
- EXTR esym;
- boolean skip;
- bfd_vma value;
- asection *section;
- const char *name;
- struct ecoff_link_hash_entry *h;
-
- *sym_hash = NULL;
-
- (*swap_ext_in) (abfd, (PTR) ext_ptr, &esym);
-
- /* Skip debugging symbols. */
- skip = false;
- switch (esym.asym.st)
- {
- case stGlobal:
- case stStatic:
- case stLabel:
- case stProc:
- case stStaticProc:
- break;
- default:
- skip = true;
- break;
- }
-
- if (skip)
- continue;
-
- /* Get the information for this symbol. */
- value = esym.asym.value;
- switch (esym.asym.sc)
- {
- default:
- case scNil:
- case scRegister:
- case scCdbLocal:
- case scBits:
- case scCdbSystem:
- case scRegImage:
- case scInfo:
- case scUserStruct:
- case scVar:
- case scVarRegister:
- case scVariant:
- case scBasedVar:
- case scXData:
- case scPData:
- section = NULL;
- break;
- case scText:
- section = bfd_make_section_old_way (abfd, ".text");
- value -= section->vma;
- break;
- case scData:
- section = bfd_make_section_old_way (abfd, ".data");
- value -= section->vma;
- break;
- case scBss:
- section = bfd_make_section_old_way (abfd, ".bss");
- value -= section->vma;
- break;
- case scAbs:
- section = bfd_abs_section_ptr;
- break;
- case scUndefined:
- section = bfd_und_section_ptr;
- break;
- case scSData:
- section = bfd_make_section_old_way (abfd, ".sdata");
- value -= section->vma;
- break;
- case scSBss:
- section = bfd_make_section_old_way (abfd, ".sbss");
- value -= section->vma;
- break;
- case scRData:
- section = bfd_make_section_old_way (abfd, ".rdata");
- value -= section->vma;
- break;
- case scCommon:
- if (value > ecoff_data (abfd)->gp_size)
- {
- section = bfd_com_section_ptr;
- break;
- }
- /* Fall through. */
- case scSCommon:
- if (ecoff_scom_section.name == NULL)
- {
- /* Initialize the small common section. */
- ecoff_scom_section.name = SCOMMON;
- ecoff_scom_section.flags = SEC_IS_COMMON;
- ecoff_scom_section.output_section = &ecoff_scom_section;
- ecoff_scom_section.symbol = &ecoff_scom_symbol;
- ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
- ecoff_scom_symbol.name = SCOMMON;
- ecoff_scom_symbol.flags = BSF_SECTION_SYM;
- ecoff_scom_symbol.section = &ecoff_scom_section;
- ecoff_scom_symbol_ptr = &ecoff_scom_symbol;
- }
- section = &ecoff_scom_section;
- break;
- case scSUndefined:
- section = bfd_und_section_ptr;
- break;
- case scInit:
- section = bfd_make_section_old_way (abfd, ".init");
- value -= section->vma;
- break;
- case scFini:
- section = bfd_make_section_old_way (abfd, ".fini");
- value -= section->vma;
- break;
- case scRConst:
- section = bfd_make_section_old_way (abfd, ".rconst");
- value -= section->vma;
- break;
- }
-
- if (section == (asection *) NULL)
- continue;
-
- name = ssext + esym.asym.iss;
-
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, name,
- esym.weakext ? BSF_WEAK : BSF_GLOBAL,
- section, value, (const char *) NULL, true, true,
- (struct bfd_link_hash_entry **) &h)))
- return false;
-
- *sym_hash = h;
-
- /* If we are building an ECOFF hash table, save the external
- symbol information. */
- if (info->hash->creator->flavour == bfd_get_flavour (abfd))
- {
- if (h->abfd == (bfd *) NULL
- || (! bfd_is_und_section (section)
- && (! bfd_is_com_section (section)
- || (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak))))
- {
- h->abfd = abfd;
- h->esym = esym;
- }
-
- /* Remember whether this symbol was small undefined. */
- if (esym.asym.sc == scSUndefined)
- h->small = 1;
-
- /* If this symbol was ever small undefined, it needs to wind
- up in a GP relative section. We can't control the
- section of a defined symbol, but we can control the
- section of a common symbol. This case is actually needed
- on Ultrix 4.2 to handle the symbol cred in -lckrb. */
- if (h->small
- && h->root.type == bfd_link_hash_common
- && strcmp (h->root.u.c.p->section->name, SCOMMON) != 0)
- {
- h->root.u.c.p->section = bfd_make_section_old_way (abfd,
- SCOMMON);
- h->root.u.c.p->section->flags = SEC_ALLOC;
- if (h->esym.asym.sc == scCommon)
- h->esym.asym.sc = scSCommon;
- }
- }
- }
-
- return true;
-}
-
-/* ECOFF final link routines. */
-
-static boolean ecoff_final_link_debug_accumulate
- PARAMS ((bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *,
- PTR handle));
-static boolean ecoff_link_write_external
- PARAMS ((struct ecoff_link_hash_entry *, PTR));
-static boolean ecoff_indirect_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-static boolean ecoff_reloc_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-
-/* Structure used to pass information to ecoff_link_write_external. */
-
-struct extsym_info
-{
- bfd *abfd;
- struct bfd_link_info *info;
-};
-
-/* ECOFF final link routine. This looks through all the input BFDs
- and gathers together all the debugging information, and then
- processes all the link order information. This may cause it to
- close and reopen some input BFDs; I'll see how bad this is. */
-
-boolean
-_bfd_ecoff_bfd_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- struct ecoff_debug_info * const debug = &ecoff_data (abfd)->debug_info;
- HDRR *symhdr;
- PTR handle;
- register bfd *input_bfd;
- asection *o;
- struct bfd_link_order *p;
- struct extsym_info einfo;
-
- /* We accumulate the debugging information counts in the symbolic
- header. */
- symhdr = &debug->symbolic_header;
- 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;
-
- handle = bfd_ecoff_debug_init (abfd, debug, &backend->debug_swap, info);
- if (handle == (PTR) NULL)
- return false;
-
- /* Accumulate the debugging symbols from each input BFD. */
- for (input_bfd = info->input_bfds;
- input_bfd != (bfd *) NULL;
- input_bfd = input_bfd->link_next)
- {
- boolean ret;
-
- if (bfd_get_flavour (input_bfd) == bfd_target_ecoff_flavour)
- {
- /* Abitrarily set the symbolic header vstamp to the vstamp
- of the first object file in the link. */
- if (symhdr->vstamp == 0)
- symhdr->vstamp
- = ecoff_data (input_bfd)->debug_info.symbolic_header.vstamp;
- ret = ecoff_final_link_debug_accumulate (abfd, input_bfd, info,
- handle);
- }
- else
- ret = bfd_ecoff_debug_accumulate_other (handle, abfd,
- debug, &backend->debug_swap,
- input_bfd, info);
- if (! ret)
- return false;
-
- /* Combine the register masks. */
- ecoff_data (abfd)->gprmask |= ecoff_data (input_bfd)->gprmask;
- ecoff_data (abfd)->fprmask |= ecoff_data (input_bfd)->fprmask;
- ecoff_data (abfd)->cprmask[0] |= ecoff_data (input_bfd)->cprmask[0];
- ecoff_data (abfd)->cprmask[1] |= ecoff_data (input_bfd)->cprmask[1];
- ecoff_data (abfd)->cprmask[2] |= ecoff_data (input_bfd)->cprmask[2];
- ecoff_data (abfd)->cprmask[3] |= ecoff_data (input_bfd)->cprmask[3];
- }
-
- /* Write out the external symbols. */
- einfo.abfd = abfd;
- einfo.info = info;
- ecoff_link_hash_traverse (ecoff_hash_table (info),
- ecoff_link_write_external,
- (PTR) &einfo);
-
- if (info->relocateable)
- {
- /* We need to make a pass over the link_orders to count up the
- number of relocations we will need to output, so that we know
- how much space they will take up. */
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- o->reloc_count = 0;
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- if (p->type == bfd_indirect_link_order)
- o->reloc_count += p->u.indirect.section->reloc_count;
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- ++o->reloc_count;
- }
- }
-
- /* Compute the reloc and symbol file positions. */
- ecoff_compute_reloc_file_positions (abfd);
-
- /* Write out the debugging information. */
- if (! bfd_ecoff_write_accumulated_debug (handle, abfd, debug,
- &backend->debug_swap, info,
- ecoff_data (abfd)->sym_filepos))
- return false;
-
- bfd_ecoff_debug_free (handle, abfd, debug, &backend->debug_swap, info);
-
- if (info->relocateable)
- {
- /* Now reset the reloc_count field of the sections in the output
- BFD to 0, so that we can use them to keep track of how many
- relocs we have output thus far. */
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- o->reloc_count = 0;
- }
-
- /* Get a value for the GP register. */
- if (ecoff_data (abfd)->gp == 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)
- ecoff_data (abfd)->gp = (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
- || strcmp (o->name, _LITA) == 0))
- lo = o->vma;
- }
- ecoff_data (abfd)->gp = lo + 0x8000;
- }
- 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. */
- }
- }
-
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- if (p->type == bfd_indirect_link_order
- && (bfd_get_flavour (p->u.indirect.section->owner)
- == bfd_target_ecoff_flavour))
- {
- if (! ecoff_indirect_link_order (abfd, info, o, p))
- return false;
- }
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- if (! ecoff_reloc_link_order (abfd, info, o, p))
- return false;
- }
- else
- {
- if (! _bfd_default_link_order (abfd, info, o, p))
- return false;
- }
- }
- }
-
- bfd_get_symcount (abfd) = symhdr->iextMax + symhdr->isymMax;
-
- ecoff_data (abfd)->linker = true;
-
- return true;
-}
-
-/* Accumulate the debugging information for an input BFD into the
- output BFD. This must read in the symbolic information of the
- input BFD. */
-
-static boolean
-ecoff_final_link_debug_accumulate (output_bfd, input_bfd, info, handle)
- bfd *output_bfd;
- bfd *input_bfd;
- struct bfd_link_info *info;
- PTR handle;
-{
- struct ecoff_debug_info * const debug = &ecoff_data (input_bfd)->debug_info;
- const struct ecoff_debug_swap * const swap =
- &ecoff_backend (input_bfd)->debug_swap;
- HDRR *symhdr = &debug->symbolic_header;
- boolean ret;
-
-#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) \
- { \
- ret = false; \
- goto return_something; \
- } \
- if ((bfd_seek (input_bfd, (file_ptr) symhdr->offset, SEEK_SET) \
- != 0) \
- || (bfd_read (debug->ptr, size, symhdr->count, \
- input_bfd) != size * symhdr->count)) \
- { \
- ret = false; \
- goto return_something; \
- } \
- }
-
- /* If raw_syments is not NULL, then the data was already by read by
- _bfd_ecoff_slurp_symbolic_info. */
- if (ecoff_data (input_bfd)->raw_syments == NULL)
- {
- 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 (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
- READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
- }
-#undef READ
-
- /* We do not read the external strings or the external symbols. */
-
- ret = (bfd_ecoff_debug_accumulate
- (handle, output_bfd, &ecoff_data (output_bfd)->debug_info,
- &ecoff_backend (output_bfd)->debug_swap,
- input_bfd, debug, swap, info));
-
- return_something:
- if (ecoff_data (input_bfd)->raw_syments == NULL)
- {
- 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->external_fdr != NULL)
- free (debug->external_fdr);
- if (debug->external_rfd != NULL)
- free (debug->external_rfd);
-
- /* Make sure we don't accidentally follow one of these pointers
- into freed memory. */
- 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->external_fdr = NULL;
- debug->external_rfd = NULL;
- }
-
- return ret;
-}
-
-/* Put out information for an external symbol. These come only from
- the hash table. */
-
-static boolean
-ecoff_link_write_external (h, data)
- struct ecoff_link_hash_entry *h;
- PTR data;
-{
- struct extsym_info *einfo = (struct extsym_info *) data;
- bfd *output_bfd = einfo->abfd;
- boolean strip;
-
- /* We need to check if this symbol is being stripped. */
- if (h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak)
- strip = false;
- else if (einfo->info->strip == strip_all
- || (einfo->info->strip == strip_some
- && bfd_hash_lookup (einfo->info->keep_hash,
- h->root.root.string,
- false, false) == NULL))
- strip = true;
- else
- strip = false;
-
- if (strip || h->written)
- return true;
-
- if (h->abfd == (bfd *) NULL)
- {
- h->esym.jmptbl = 0;
- h->esym.cobol_main = 0;
- h->esym.weakext = 0;
- h->esym.reserved = 0;
- h->esym.ifd = ifdNil;
- h->esym.asym.value = 0;
- h->esym.asym.st = stGlobal;
-
- if (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak)
- h->esym.asym.sc = scAbs;
- else
- {
- asection *output_section;
- const char *name;
-
- output_section = h->root.u.def.section->output_section;
- 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, _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 if (strcmp (name, _PDATA) == 0)
- h->esym.asym.sc = scPData;
- else if (strcmp (name, _XDATA) == 0)
- h->esym.asym.sc = scXData;
- else if (strcmp (name, _RCONST) == 0)
- h->esym.asym.sc = scRConst;
- else
- h->esym.asym.sc = scAbs;
- }
-
- h->esym.asym.reserved = 0;
- h->esym.asym.index = indexNil;
- }
- else if (h->esym.ifd != -1)
- {
- struct ecoff_debug_info *debug;
-
- /* Adjust the FDR index for the symbol by that used for the
- input BFD. */
- debug = &ecoff_data (h->abfd)->debug_info;
- BFD_ASSERT (h->esym.ifd >= 0
- && h->esym.ifd < debug->symbolic_header.ifdMax);
- h->esym.ifd = debug->ifdmap[h->esym.ifd];
- }
-
- switch (h->root.type)
- {
- default:
- case bfd_link_hash_new:
- abort ();
- case bfd_link_hash_undefined:
- case bfd_link_hash_undefweak:
- if (h->esym.asym.sc != scUndefined
- && h->esym.asym.sc != scSUndefined)
- h->esym.asym.sc = scUndefined;
- break;
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- if (h->esym.asym.sc == scUndefined
- || h->esym.asym.sc == scSUndefined)
- h->esym.asym.sc = scAbs;
- else if (h->esym.asym.sc == scCommon)
- h->esym.asym.sc = scBss;
- else if (h->esym.asym.sc == scSCommon)
- h->esym.asym.sc = scSBss;
- h->esym.asym.value = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- break;
- case bfd_link_hash_common:
- if (h->esym.asym.sc != scCommon
- && h->esym.asym.sc != scSCommon)
- h->esym.asym.sc = scCommon;
- h->esym.asym.value = h->root.u.c.size;
- break;
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- /* FIXME: Ignore these for now. The circumstances under which
- they should be written out are not clear to me. */
- return true;
- }
-
- /* bfd_ecoff_debug_one_external uses iextMax to keep track of the
- symbol number. */
- h->indx = ecoff_data (output_bfd)->debug_info.symbolic_header.iextMax;
- h->written = 1;
-
- return (bfd_ecoff_debug_one_external
- (output_bfd, &ecoff_data (output_bfd)->debug_info,
- &ecoff_backend (output_bfd)->debug_swap, h->root.root.string,
- &h->esym));
-}
-
-/* Relocate and write an ECOFF section into an ECOFF output file. */
-
-static boolean
-ecoff_indirect_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;
-{
- asection *input_section;
- bfd *input_bfd;
- struct ecoff_section_tdata *section_tdata;
- bfd_size_type raw_size;
- bfd_size_type cooked_size;
- bfd_byte *contents = NULL;
- bfd_size_type external_reloc_size;
- bfd_size_type external_relocs_size;
- PTR external_relocs = NULL;
-
- BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0);
-
- if (link_order->size == 0)
- return true;
-
- input_section = link_order->u.indirect.section;
- input_bfd = input_section->owner;
- section_tdata = ecoff_section_data (input_bfd, input_section);
-
- raw_size = input_section->_raw_size;
- cooked_size = input_section->_cooked_size;
- if (cooked_size == 0)
- cooked_size = raw_size;
-
- BFD_ASSERT (input_section->output_section == output_section);
- BFD_ASSERT (input_section->output_offset == link_order->offset);
- BFD_ASSERT (cooked_size == link_order->size);
-
- /* Get the section contents. We allocate memory for the larger of
- the size before relocating and the size after relocating. */
- contents = (bfd_byte *) bfd_malloc (raw_size >= cooked_size
- ? (size_t) raw_size
- : (size_t) cooked_size);
- if (contents == NULL && raw_size != 0)
- goto error_return;
-
- /* If we are relaxing, the contents may have already been read into
- memory, in which case we copy them into our new buffer. We don't
- simply reuse the old buffer in case cooked_size > raw_size. */
- if (section_tdata != (struct ecoff_section_tdata *) NULL
- && section_tdata->contents != (bfd_byte *) NULL)
- memcpy (contents, section_tdata->contents, (size_t) raw_size);
- else
- {
- if (! bfd_get_section_contents (input_bfd, input_section,
- (PTR) contents,
- (file_ptr) 0, raw_size))
- goto error_return;
- }
-
- /* Get the relocs. If we are relaxing MIPS code, they will already
- have been read in. Otherwise, we read them in now. */
- external_reloc_size = ecoff_backend (input_bfd)->external_reloc_size;
- external_relocs_size = external_reloc_size * input_section->reloc_count;
-
- if (section_tdata != (struct ecoff_section_tdata *) NULL
- && section_tdata->external_relocs != NULL)
- external_relocs = section_tdata->external_relocs;
- else
- {
- external_relocs = (PTR) bfd_malloc ((size_t) external_relocs_size);
- if (external_relocs == NULL && external_relocs_size != 0)
- goto error_return;
-
- if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
- || (bfd_read (external_relocs, 1, external_relocs_size, input_bfd)
- != external_relocs_size))
- goto error_return;
- }
-
- /* Relocate the section contents. */
- if (! ((*ecoff_backend (input_bfd)->relocate_section)
- (output_bfd, info, input_bfd, input_section, contents,
- external_relocs)))
- goto error_return;
-
- /* Write out the relocated section. */
- if (! bfd_set_section_contents (output_bfd,
- output_section,
- (PTR) contents,
- input_section->output_offset,
- cooked_size))
- goto error_return;
-
- /* If we are producing relocateable output, the relocs were
- modified, and we write them out now. We use the reloc_count
- field of output_section to keep track of the number of relocs we
- have output so far. */
- if (info->relocateable)
- {
- if (bfd_seek (output_bfd,
- (output_section->rel_filepos +
- output_section->reloc_count * external_reloc_size),
- SEEK_SET) != 0
- || (bfd_write (external_relocs, 1, external_relocs_size, output_bfd)
- != external_relocs_size))
- goto error_return;
- output_section->reloc_count += input_section->reloc_count;
- }
-
- if (contents != NULL)
- free (contents);
- if (external_relocs != NULL && section_tdata == NULL)
- free (external_relocs);
- return true;
-
- error_return:
- if (contents != NULL)
- free (contents);
- if (external_relocs != NULL && section_tdata == NULL)
- free (external_relocs);
- return false;
-}
-
-/* Generate a reloc when linking an ECOFF 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
-ecoff_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;
-{
- enum bfd_link_order_type type;
- asection *section;
- bfd_vma addend;
- arelent rel;
- struct internal_reloc in;
- bfd_size_type external_reloc_size;
- bfd_byte *rbuf;
- boolean ok;
-
- type = link_order->type;
- section = NULL;
- addend = link_order->u.reloc.p->addend;
-
- /* We set up an arelent to pass to the backend adjust_reloc_out
- routine. */
- rel.address = link_order->offset;
-
- rel.howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
- if (rel.howto == 0)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- if (type == bfd_section_reloc_link_order)
- {
- section = link_order->u.reloc.p->u.section;
- rel.sym_ptr_ptr = section->symbol_ptr_ptr;
- }
- else
- {
- struct bfd_link_hash_entry *h;
-
- /* Treat a reloc against a defined symbol as though it were
- actually against the section. */
- h = bfd_wrapped_link_hash_lookup (output_bfd, info,
- link_order->u.reloc.p->u.name,
- false, false, false);
- if (h != NULL
- && (h->type == bfd_link_hash_defined
- || h->type == bfd_link_hash_defweak))
- {
- type = bfd_section_reloc_link_order;
- section = h->u.def.section->output_section;
- /* 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->vma + h->u.def.section->output_offset;
- }
- else
- {
- /* We can't set up a reloc against a symbol correctly,
- because we have no asymbol structure. Currently no
- adjust_reloc_out routine cares. */
- rel.sym_ptr_ptr = (asymbol **) NULL;
- }
- }
-
- /* All ECOFF relocs are in-place. Put the addend into the object
- file. */
-
- BFD_ASSERT (rel.howto->partial_inplace);
- if (addend != 0)
- {
- bfd_size_type size;
- bfd_reloc_status_type rstat;
- bfd_byte *buf;
- boolean ok;
-
- size = bfd_get_reloc_size (rel.howto);
- buf = (bfd_byte *) bfd_zmalloc (size);
- if (buf == (bfd_byte *) NULL)
- return false;
- rstat = _bfd_relocate_contents (rel.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, section)
- : link_order->u.reloc.p->u.name),
- rel.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;
- }
-
- rel.addend = 0;
-
- /* Move the information into a internal_reloc structure. */
- in.r_vaddr = (rel.address
- + bfd_get_section_vma (output_bfd, output_section));
- in.r_type = rel.howto->type;
-
- if (type == bfd_symbol_reloc_link_order)
- {
- struct ecoff_link_hash_entry *h;
-
- h = ((struct ecoff_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (output_bfd, info,
- link_order->u.reloc.p->u.name,
- false, false, true));
- if (h != (struct ecoff_link_hash_entry *) NULL
- && h->indx != -1)
- in.r_symndx = h->indx;
- else
- {
- if (! ((*info->callbacks->unattached_reloc)
- (info, link_order->u.reloc.p->u.name, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- return false;
- in.r_symndx = 0;
- }
- in.r_extern = 1;
- }
- else
- {
- CONST char *name;
-
- name = bfd_get_section_name (output_bfd, section);
- if (strcmp (name, ".text") == 0)
- in.r_symndx = RELOC_SECTION_TEXT;
- else if (strcmp (name, ".rdata") == 0)
- in.r_symndx = RELOC_SECTION_RDATA;
- else if (strcmp (name, ".data") == 0)
- in.r_symndx = RELOC_SECTION_DATA;
- else if (strcmp (name, ".sdata") == 0)
- in.r_symndx = RELOC_SECTION_SDATA;
- else if (strcmp (name, ".sbss") == 0)
- in.r_symndx = RELOC_SECTION_SBSS;
- else if (strcmp (name, ".bss") == 0)
- in.r_symndx = RELOC_SECTION_BSS;
- else if (strcmp (name, ".init") == 0)
- in.r_symndx = RELOC_SECTION_INIT;
- else if (strcmp (name, ".lit8") == 0)
- in.r_symndx = RELOC_SECTION_LIT8;
- else if (strcmp (name, ".lit4") == 0)
- in.r_symndx = RELOC_SECTION_LIT4;
- else if (strcmp (name, ".xdata") == 0)
- in.r_symndx = RELOC_SECTION_XDATA;
- else if (strcmp (name, ".pdata") == 0)
- in.r_symndx = RELOC_SECTION_PDATA;
- else if (strcmp (name, ".fini") == 0)
- in.r_symndx = RELOC_SECTION_FINI;
- else if (strcmp (name, ".lita") == 0)
- in.r_symndx = RELOC_SECTION_LITA;
- else if (strcmp (name, "*ABS*") == 0)
- in.r_symndx = RELOC_SECTION_ABS;
- else if (strcmp (name, ".rconst") == 0)
- in.r_symndx = RELOC_SECTION_RCONST;
- else
- abort ();
- in.r_extern = 0;
- }
-
- /* Let the BFD backend adjust the reloc. */
- (*ecoff_backend (output_bfd)->adjust_reloc_out) (output_bfd, &rel, &in);
-
- /* Get some memory and swap out the reloc. */
- external_reloc_size = ecoff_backend (output_bfd)->external_reloc_size;
- rbuf = (bfd_byte *) bfd_malloc ((size_t) external_reloc_size);
- if (rbuf == (bfd_byte *) NULL)
- return false;
-
- (*ecoff_backend (output_bfd)->swap_reloc_out) (output_bfd, &in, (PTR) rbuf);
-
- ok = (bfd_seek (output_bfd,
- (output_section->rel_filepos +
- output_section->reloc_count * external_reloc_size),
- SEEK_SET) == 0
- && (bfd_write ((PTR) rbuf, 1, external_reloc_size, output_bfd)
- == external_reloc_size));
-
- if (ok)
- ++output_section->reloc_count;
-
- free (rbuf);
-
- return ok;
-}
diff --git a/contrib/gdb/bfd/ecofflink.c b/contrib/gdb/bfd/ecofflink.c
deleted file mode 100644
index 03d6e00ad188..000000000000
--- a/contrib/gdb/bfd/ecofflink.c
+++ /dev/null
@@ -1,2452 +0,0 @@
-/* Routines to link ECOFF debugging information.
- Copyright 1993 Free Software Foundation, Inc.
- Written 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. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "aout/stab_gnu.h"
-#include "coff/internal.h"
-#include "coff/sym.h"
-#include "coff/symconst.h"
-#include "coff/ecoff.h"
-
-static boolean ecoff_add_bytes PARAMS ((char **buf, char **bufend,
- size_t need));
-static struct bfd_hash_entry *string_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
- const char *));
-static void ecoff_align_debug PARAMS ((bfd *abfd,
- struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap));
-static boolean ecoff_write_symhdr PARAMS ((bfd *, struct ecoff_debug_info *,
- const struct ecoff_debug_swap *,
- file_ptr where));
-static int cmp_fdrtab_entry PARAMS ((const PTR, const PTR));
-static boolean mk_fdrtab PARAMS ((bfd *,
- struct ecoff_debug_info * const,
- const struct ecoff_debug_swap * const,
- struct ecoff_find_line *));
-static long fdrtab_lookup PARAMS ((struct ecoff_find_line *, bfd_vma));
-
-/* Obstack allocation and deallocation routines. */
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-
-/* Routines to swap auxiliary information in and out. I am assuming
- that the auxiliary information format is always going to be target
- independent. */
-
-/* Swap in a type information record.
- BIGEND says whether AUX symbols are big-endian or little-endian; this
- info comes from the file header record (fh-fBigendian). */
-
-void
-_bfd_ecoff_swap_tir_in (bigend, ext_copy, intern)
- int bigend;
- const struct tir_ext *ext_copy;
- TIR *intern;
-{
- struct tir_ext ext[1];
-
- *ext = *ext_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_BIG);
- intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_BIG);
- intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_BIG)
- >> TIR_BITS1_BT_SH_BIG;
- intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_BIG)
- >> TIR_BITS_TQ4_SH_BIG;
- intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_BIG)
- >> TIR_BITS_TQ5_SH_BIG;
- intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_BIG)
- >> TIR_BITS_TQ0_SH_BIG;
- intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_BIG)
- >> TIR_BITS_TQ1_SH_BIG;
- intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_BIG)
- >> TIR_BITS_TQ2_SH_BIG;
- intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_BIG)
- >> TIR_BITS_TQ3_SH_BIG;
- } else {
- intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_LITTLE);
- intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_LITTLE);
- intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_LITTLE)
- >> TIR_BITS1_BT_SH_LITTLE;
- intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_LITTLE)
- >> TIR_BITS_TQ4_SH_LITTLE;
- intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_LITTLE)
- >> TIR_BITS_TQ5_SH_LITTLE;
- intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_LITTLE)
- >> TIR_BITS_TQ0_SH_LITTLE;
- intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_LITTLE)
- >> TIR_BITS_TQ1_SH_LITTLE;
- intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_LITTLE)
- >> TIR_BITS_TQ2_SH_LITTLE;
- intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_LITTLE)
- >> TIR_BITS_TQ3_SH_LITTLE;
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out a type information record.
- BIGEND says whether AUX symbols are big-endian or little-endian; this
- info comes from the file header record (fh-fBigendian). */
-
-void
-_bfd_ecoff_swap_tir_out (bigend, intern_copy, ext)
- int bigend;
- const TIR *intern_copy;
- struct tir_ext *ext;
-{
- TIR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_BIG : 0)
- | (intern->continued ? TIR_BITS1_CONTINUED_BIG : 0)
- | ((intern->bt << TIR_BITS1_BT_SH_BIG)
- & TIR_BITS1_BT_BIG));
- ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_BIG)
- & TIR_BITS_TQ4_BIG)
- | ((intern->tq5 << TIR_BITS_TQ5_SH_BIG)
- & TIR_BITS_TQ5_BIG));
- ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_BIG)
- & TIR_BITS_TQ0_BIG)
- | ((intern->tq1 << TIR_BITS_TQ1_SH_BIG)
- & TIR_BITS_TQ1_BIG));
- ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_BIG)
- & TIR_BITS_TQ2_BIG)
- | ((intern->tq3 << TIR_BITS_TQ3_SH_BIG)
- & TIR_BITS_TQ3_BIG));
- } else {
- ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_LITTLE : 0)
- | (intern->continued ? TIR_BITS1_CONTINUED_LITTLE : 0)
- | ((intern->bt << TIR_BITS1_BT_SH_LITTLE)
- & TIR_BITS1_BT_LITTLE));
- ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_LITTLE)
- & TIR_BITS_TQ4_LITTLE)
- | ((intern->tq5 << TIR_BITS_TQ5_SH_LITTLE)
- & TIR_BITS_TQ5_LITTLE));
- ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_LITTLE)
- & TIR_BITS_TQ0_LITTLE)
- | ((intern->tq1 << TIR_BITS_TQ1_SH_LITTLE)
- & TIR_BITS_TQ1_LITTLE));
- ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_LITTLE)
- & TIR_BITS_TQ2_LITTLE)
- | ((intern->tq3 << TIR_BITS_TQ3_SH_LITTLE)
- & TIR_BITS_TQ3_LITTLE));
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap in a relative symbol record. BIGEND says whether it is in
- big-endian or little-endian format.*/
-
-void
-_bfd_ecoff_swap_rndx_in (bigend, ext_copy, intern)
- int bigend;
- const struct rndx_ext *ext_copy;
- RNDXR *intern;
-{
- struct rndx_ext ext[1];
-
- *ext = *ext_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_BIG)
- | ((ext->r_bits[1] & RNDX_BITS1_RFD_BIG)
- >> RNDX_BITS1_RFD_SH_BIG);
- intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_BIG)
- << RNDX_BITS1_INDEX_SH_LEFT_BIG)
- | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG)
- | (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG);
- } else {
- intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE)
- | ((ext->r_bits[1] & RNDX_BITS1_RFD_LITTLE)
- << RNDX_BITS1_RFD_SH_LEFT_LITTLE);
- intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
- >> RNDX_BITS1_INDEX_SH_LITTLE)
- | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE)
- | ((unsigned int) ext->r_bits[3]
- << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out a relative symbol record. BIGEND says whether it is in
- big-endian or little-endian format.*/
-
-void
-_bfd_ecoff_swap_rndx_out (bigend, intern_copy, ext)
- int bigend;
- const RNDXR *intern_copy;
- struct rndx_ext *ext;
-{
- RNDXR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_BIG;
- ext->r_bits[1] = (((intern->rfd << RNDX_BITS1_RFD_SH_BIG)
- & RNDX_BITS1_RFD_BIG)
- | ((intern->index >> RNDX_BITS1_INDEX_SH_LEFT_BIG)
- & RNDX_BITS1_INDEX_BIG));
- ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_BIG;
- ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_BIG;
- } else {
- ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_LITTLE;
- ext->r_bits[1] = (((intern->rfd >> RNDX_BITS1_RFD_SH_LEFT_LITTLE)
- & RNDX_BITS1_RFD_LITTLE)
- | ((intern->index << RNDX_BITS1_INDEX_SH_LITTLE)
- & RNDX_BITS1_INDEX_LITTLE));
- ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_LITTLE;
- ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_LITTLE;
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* The minimum amount of data to allocate. */
-#define ALLOC_SIZE (4064)
-
-/* Add bytes to a buffer. Return success. */
-
-static boolean
-ecoff_add_bytes (buf, bufend, need)
- char **buf;
- char **bufend;
- size_t need;
-{
- size_t have;
- size_t want;
- char *newbuf;
-
- have = *bufend - *buf;
- if (have > need)
- want = ALLOC_SIZE;
- else
- {
- want = need - have;
- if (want < ALLOC_SIZE)
- want = ALLOC_SIZE;
- }
- newbuf = (char *) bfd_realloc (*buf, have + want);
- if (newbuf == NULL)
- return false;
- *buf = newbuf;
- *bufend = *buf + have + want;
- return true;
-}
-
-/* We keep a hash table which maps strings to numbers. We use it to
- map FDR names to indices in the output file, and to map local
- strings when combining stabs debugging information. */
-
-struct string_hash_entry
-{
- struct bfd_hash_entry root;
- /* FDR index or string table offset. */
- long val;
- /* Next entry in string table. */
- struct string_hash_entry *next;
-};
-
-struct string_hash_table
-{
- struct bfd_hash_table table;
-};
-
-/* Routine to create an entry in a string hash table. */
-
-static struct bfd_hash_entry *
-string_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct string_hash_entry *ret = (struct string_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct string_hash_entry *) NULL)
- ret = ((struct string_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct string_hash_entry)));
- if (ret == (struct string_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct string_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- ret->val = -1;
- ret->next = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Look up an entry in an string hash table. */
-
-#define string_hash_lookup(t, string, create, copy) \
- ((struct string_hash_entry *) \
- bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
-
-/* We can't afford to read in all the debugging information when we do
- a link. Instead, we build a list of these structures to show how
- different parts of the input file map to the output file. */
-
-struct shuffle
-{
- /* The next entry in this linked list. */
- struct shuffle *next;
- /* The length of the information. */
- unsigned long size;
- /* Whether this information comes from a file or not. */
- boolean filep;
- union
- {
- struct
- {
- /* The BFD the data comes from. */
- bfd *input_bfd;
- /* The offset within input_bfd. */
- file_ptr offset;
- } file;
- /* The data to be written out. */
- PTR memory;
- } u;
-};
-
-/* This structure holds information across calls to
- bfd_ecoff_debug_accumulate. */
-
-struct accumulate
-{
- /* The FDR hash table. */
- struct string_hash_table fdr_hash;
- /* The strings hash table. */
- struct string_hash_table str_hash;
- /* Linked lists describing how to shuffle the input debug
- information into the output file. We keep a pointer to both the
- head and the tail. */
- struct shuffle *line;
- struct shuffle *line_end;
- struct shuffle *pdr;
- struct shuffle *pdr_end;
- struct shuffle *sym;
- struct shuffle *sym_end;
- struct shuffle *opt;
- struct shuffle *opt_end;
- struct shuffle *aux;
- struct shuffle *aux_end;
- struct shuffle *ss;
- struct shuffle *ss_end;
- struct string_hash_entry *ss_hash;
- struct string_hash_entry *ss_hash_end;
- struct shuffle *fdr;
- struct shuffle *fdr_end;
- struct shuffle *rfd;
- struct shuffle *rfd_end;
- /* The size of the largest file shuffle. */
- unsigned long largest_file_shuffle;
- /* An obstack for debugging information. */
- struct obstack memory;
-};
-
-/* Add a file entry to a shuffle list. */
-
-static boolean add_file_shuffle PARAMS ((struct accumulate *,
- struct shuffle **,
- struct shuffle **, bfd *, file_ptr,
- unsigned long));
-
-static boolean
-add_file_shuffle (ainfo, head, tail, input_bfd, offset, size)
- struct accumulate *ainfo;
- struct shuffle **head;
- struct shuffle **tail;
- bfd *input_bfd;
- file_ptr offset;
- unsigned long size;
-{
- struct shuffle *n;
-
- if (*tail != (struct shuffle *) NULL
- && (*tail)->filep
- && (*tail)->u.file.input_bfd == input_bfd
- && (*tail)->u.file.offset + (*tail)->size == (unsigned long) offset)
- {
- /* Just merge this entry onto the existing one. */
- (*tail)->size += size;
- if ((*tail)->size > ainfo->largest_file_shuffle)
- ainfo->largest_file_shuffle = (*tail)->size;
- return true;
- }
-
- n = (struct shuffle *) obstack_alloc (&ainfo->memory,
- sizeof (struct shuffle));
- if (!n)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- n->next = NULL;
- n->size = size;
- n->filep = true;
- n->u.file.input_bfd = input_bfd;
- n->u.file.offset = offset;
- if (*head == (struct shuffle *) NULL)
- *head = n;
- if (*tail != (struct shuffle *) NULL)
- (*tail)->next = n;
- *tail = n;
- if (size > ainfo->largest_file_shuffle)
- ainfo->largest_file_shuffle = size;
- return true;
-}
-
-/* Add a memory entry to a shuffle list. */
-
-static boolean add_memory_shuffle PARAMS ((struct accumulate *,
- struct shuffle **head,
- struct shuffle **tail,
- bfd_byte *data, unsigned long size));
-
-static boolean
-add_memory_shuffle (ainfo, head, tail, data, size)
- struct accumulate *ainfo;
- struct shuffle **head;
- struct shuffle **tail;
- bfd_byte *data;
- unsigned long size;
-{
- struct shuffle *n;
-
- n = (struct shuffle *) obstack_alloc (&ainfo->memory,
- sizeof (struct shuffle));
- if (!n)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- n->next = NULL;
- n->size = size;
- n->filep = false;
- n->u.memory = (PTR) data;
- if (*head == (struct shuffle *) NULL)
- *head = n;
- if (*tail != (struct shuffle *) NULL)
- (*tail)->next = n;
- *tail = n;
- return true;
-}
-
-/* Initialize the FDR hash table. This returns a handle which is then
- passed in to bfd_ecoff_debug_accumulate, et. al. */
-
-/*ARGSUSED*/
-PTR
-bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
- bfd *output_bfd;
- struct ecoff_debug_info *output_debug;
- const struct ecoff_debug_swap *output_swap;
- struct bfd_link_info *info;
-{
- struct accumulate *ainfo;
-
- ainfo = (struct accumulate *) bfd_malloc (sizeof (struct accumulate));
- if (!ainfo)
- return NULL;
- if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
- 1021))
- return NULL;
-
- ainfo->line = NULL;
- ainfo->line_end = NULL;
- ainfo->pdr = NULL;
- ainfo->pdr_end = NULL;
- ainfo->sym = NULL;
- ainfo->sym_end = NULL;
- ainfo->opt = NULL;
- ainfo->opt_end = NULL;
- ainfo->aux = NULL;
- ainfo->aux_end = NULL;
- ainfo->ss = NULL;
- ainfo->ss_end = NULL;
- ainfo->ss_hash = NULL;
- ainfo->ss_hash_end = NULL;
- ainfo->fdr = NULL;
- ainfo->fdr_end = NULL;
- ainfo->rfd = NULL;
- ainfo->rfd_end = NULL;
-
- ainfo->largest_file_shuffle = 0;
-
- if (! info->relocateable)
- {
- if (! bfd_hash_table_init (&ainfo->str_hash.table, string_hash_newfunc))
- return NULL;
-
- /* The first entry in the string table is the empty string. */
- output_debug->symbolic_header.issMax = 1;
- }
-
- if (!obstack_begin (&ainfo->memory, 4050))
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
-
- return (PTR) ainfo;
-}
-
-/* Free the accumulated debugging information. */
-
-/*ARGSUSED*/
-void
-bfd_ecoff_debug_free (handle, output_bfd, output_debug, output_swap, info)
- PTR handle;
- bfd *output_bfd;
- struct ecoff_debug_info *output_debug;
- const struct ecoff_debug_swap *output_swap;
- struct bfd_link_info *info;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
-
- bfd_hash_table_free (&ainfo->fdr_hash.table);
-
- if (! info->relocateable)
- bfd_hash_table_free (&ainfo->str_hash.table);
-
- obstack_free (&ainfo->memory, (PTR) NULL);
-
- free (ainfo);
-}
-
-/* Accumulate the debugging information from INPUT_BFD into
- OUTPUT_BFD. The INPUT_DEBUG argument points to some ECOFF
- debugging information which we want to link into the information
- pointed to by the OUTPUT_DEBUG argument. OUTPUT_SWAP and
- INPUT_SWAP point to the swapping information needed. INFO is the
- linker information structure. HANDLE is returned by
- bfd_ecoff_debug_init. */
-
-/*ARGSUSED*/
-boolean
-bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
- input_bfd, input_debug, input_swap,
- info)
- 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 *info;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
- void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *))
- = input_swap->swap_sym_in;
- void (* const swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *))
- = input_swap->swap_rfd_in;
- void (* const swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR))
- = output_swap->swap_sym_out;
- void (* const swap_fdr_out) PARAMS ((bfd *, const FDR *, PTR))
- = output_swap->swap_fdr_out;
- void (* const swap_rfd_out) PARAMS ((bfd *, const RFDT *, PTR))
- = output_swap->swap_rfd_out;
- bfd_size_type external_pdr_size = output_swap->external_pdr_size;
- bfd_size_type external_sym_size = output_swap->external_sym_size;
- bfd_size_type external_opt_size = output_swap->external_opt_size;
- bfd_size_type external_fdr_size = output_swap->external_fdr_size;
- bfd_size_type external_rfd_size = output_swap->external_rfd_size;
- HDRR * const output_symhdr = &output_debug->symbolic_header;
- HDRR * const input_symhdr = &input_debug->symbolic_header;
- bfd_vma section_adjust[scMax];
- asection *sec;
- bfd_byte *fdr_start;
- bfd_byte *fdr_ptr;
- bfd_byte *fdr_end;
- bfd_size_type fdr_add;
- unsigned int copied;
- RFDT i;
- unsigned long sz;
- bfd_byte *rfd_out;
- bfd_byte *rfd_in;
- bfd_byte *rfd_end;
- long newrfdbase = 0;
- long oldrfdbase = 0;
- bfd_byte *fdr_out;
-
- /* Use section_adjust to hold the value to add to a symbol in a
- particular section. */
- memset ((PTR) section_adjust, 0, sizeof section_adjust);
-
-#define SET(name, indx) \
- sec = bfd_get_section_by_name (input_bfd, name); \
- if (sec != NULL) \
- section_adjust[indx] = (sec->output_section->vma \
- + sec->output_offset \
- - sec->vma);
-
- SET (".text", scText);
- SET (".data", scData);
- SET (".bss", scBss);
- SET (".sdata", scSData);
- SET (".sbss", scSBss);
- /* scRdata section may be either .rdata or .rodata. */
- SET (".rdata", scRData);
- SET (".rodata", scRData);
- SET (".init", scInit);
- SET (".fini", scFini);
- SET (".rconst", scRConst);
-
-#undef SET
-
- /* Find all the debugging information based on the FDR's. We need
- to handle them whether they are swapped or not. */
- if (input_debug->fdr != (FDR *) NULL)
- {
- fdr_start = (bfd_byte *) input_debug->fdr;
- fdr_add = sizeof (FDR);
- }
- else
- {
- fdr_start = (bfd_byte *) input_debug->external_fdr;
- fdr_add = input_swap->external_fdr_size;
- }
- fdr_end = fdr_start + input_symhdr->ifdMax * fdr_add;
-
- input_debug->ifdmap = (RFDT *) bfd_alloc (input_bfd,
- (input_symhdr->ifdMax
- * sizeof (RFDT)));
-
- sz = (input_symhdr->crfd + input_symhdr->ifdMax) * external_rfd_size;
- rfd_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!input_debug->ifdmap || !rfd_out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->rfd, &ainfo->rfd_end, rfd_out, sz))
- return false;
-
- copied = 0;
-
- /* Look through the FDR's to see which ones we are going to include
- in the final output. We do not want duplicate FDR information
- for header files, because ECOFF debugging is often very large.
- When we find an FDR with no line information which can be merged,
- we look it up in a hash table to ensure that we only include it
- once. We keep a table mapping FDR numbers to the final number
- they get with the BFD, so that we can refer to it when we write
- out the external symbols. */
- for (fdr_ptr = fdr_start, i = 0;
- fdr_ptr < fdr_end;
- fdr_ptr += fdr_add, i++, rfd_out += external_rfd_size)
- {
- FDR fdr;
-
- if (input_debug->fdr != (FDR *) NULL)
- fdr = *(FDR *) fdr_ptr;
- else
- (*input_swap->swap_fdr_in) (input_bfd, (PTR) fdr_ptr, &fdr);
-
- /* See if this FDR can be merged with an existing one. */
- if (fdr.cbLine == 0 && fdr.rss != -1 && fdr.fMerge)
- {
- const char *name;
- char *lookup;
- struct string_hash_entry *fh;
-
- /* We look up a string formed from the file name and the
- number of symbols. Sometimes an include file will
- conditionally define a typedef or something based on the
- order of include files. Using the number of symbols as a
- hash reduces the chance that we will merge symbol
- information that should not be merged. */
- name = input_debug->ss + fdr.issBase + fdr.rss;
-
- lookup = (char *) bfd_malloc (strlen (name) + 20);
- if (lookup == NULL)
- return false;
- sprintf (lookup, "%s %lx", name, fdr.csym);
-
- fh = string_hash_lookup (&ainfo->fdr_hash, lookup, true, true);
- free (lookup);
- if (fh == (struct string_hash_entry *) NULL)
- return false;
-
- if (fh->val != -1)
- {
- input_debug->ifdmap[i] = fh->val;
- (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i,
- (PTR) rfd_out);
-
- /* Don't copy this FDR. */
- continue;
- }
-
- fh->val = output_symhdr->ifdMax + copied;
- }
-
- input_debug->ifdmap[i] = output_symhdr->ifdMax + copied;
- (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i, (PTR) rfd_out);
- ++copied;
- }
-
- newrfdbase = output_symhdr->crfd;
- output_symhdr->crfd += input_symhdr->ifdMax;
-
- /* Copy over any existing RFD's. RFD's are only created by the
- linker, so this will only happen for input files which are the
- result of a partial link. */
- rfd_in = (bfd_byte *) input_debug->external_rfd;
- rfd_end = rfd_in + input_symhdr->crfd * input_swap->external_rfd_size;
- for (;
- rfd_in < rfd_end;
- rfd_in += input_swap->external_rfd_size)
- {
- RFDT rfd;
-
- (*swap_rfd_in) (input_bfd, (PTR) rfd_in, &rfd);
- BFD_ASSERT (rfd >= 0 && rfd < input_symhdr->ifdMax);
- rfd = input_debug->ifdmap[rfd];
- (*swap_rfd_out) (output_bfd, &rfd, (PTR) rfd_out);
- rfd_out += external_rfd_size;
- }
-
- oldrfdbase = output_symhdr->crfd;
- output_symhdr->crfd += input_symhdr->crfd;
-
- /* Look through the FDR's and copy over all associated debugging
- information. */
- sz = copied * external_fdr_size;
- fdr_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!fdr_out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->fdr, &ainfo->fdr_end, fdr_out, sz))
- return false;
- for (fdr_ptr = fdr_start, i = 0;
- fdr_ptr < fdr_end;
- fdr_ptr += fdr_add, i++)
- {
- FDR fdr;
- bfd_vma fdr_adr;
- bfd_byte *sym_out;
- bfd_byte *lraw_src;
- bfd_byte *lraw_end;
- boolean fgotfilename;
-
- if (input_debug->ifdmap[i] < output_symhdr->ifdMax)
- {
- /* We are not copying this FDR. */
- continue;
- }
-
- if (input_debug->fdr != (FDR *) NULL)
- fdr = *(FDR *) fdr_ptr;
- else
- (*input_swap->swap_fdr_in) (input_bfd, (PTR) fdr_ptr, &fdr);
-
- fdr_adr = fdr.adr;
-
- /* Adjust the FDR address for any changes that may have been
- made by relaxing. */
- if (input_debug->adjust != (struct ecoff_value_adjust *) NULL)
- {
- struct ecoff_value_adjust *adjust;
-
- for (adjust = input_debug->adjust;
- adjust != (struct ecoff_value_adjust *) NULL;
- adjust = adjust->next)
- if (fdr_adr >= adjust->start
- && fdr_adr < adjust->end)
- fdr.adr += adjust->adjust;
- }
-
- /* FIXME: It is conceivable that this FDR points to the .init or
- .fini section, in which case this will not do the right
- thing. */
- fdr.adr += section_adjust[scText];
-
- /* Swap in the local symbols, adjust their values, and swap them
- out again. */
- fgotfilename = false;
- sz = fdr.csym * external_sym_size;
- sym_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!sym_out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->sym, &ainfo->sym_end, sym_out,
- sz))
- return false;
- lraw_src = ((bfd_byte *) input_debug->external_sym
- + fdr.isymBase * input_swap->external_sym_size);
- lraw_end = lraw_src + fdr.csym * input_swap->external_sym_size;
- for (; lraw_src < lraw_end; lraw_src += input_swap->external_sym_size)
- {
- SYMR internal_sym;
-
- (*swap_sym_in) (input_bfd, (PTR) lraw_src, &internal_sym);
-
- BFD_ASSERT (internal_sym.sc != scCommon
- && internal_sym.sc != scSCommon);
-
- /* Adjust the symbol value if appropriate. */
- switch (internal_sym.st)
- {
- case stNil:
- if (ECOFF_IS_STAB (&internal_sym))
- break;
- /* Fall through. */
- case stGlobal:
- case stStatic:
- case stLabel:
- case stProc:
- case stStaticProc:
- if (input_debug->adjust != (struct ecoff_value_adjust *) NULL)
- {
- bfd_vma value;
- struct ecoff_value_adjust *adjust;
-
- value = internal_sym.value;
- for (adjust = input_debug->adjust;
- adjust != (struct ecoff_value_adjust *) NULL;
- adjust = adjust->next)
- if (value >= adjust->start
- && value < adjust->end)
- internal_sym.value += adjust->adjust;
- }
- internal_sym.value += section_adjust[internal_sym.sc];
- break;
-
- default:
- break;
- }
-
- /* If we are doing a final link, we hash all the strings in
- the local symbol table together. This reduces the amount
- of space required by debugging information. We don't do
- this when performing a relocateable link because it would
- prevent us from easily merging different FDR's. */
- if (! info->relocateable)
- {
- boolean ffilename;
- const char *name;
-
- if (! fgotfilename && internal_sym.iss == fdr.rss)
- ffilename = true;
- else
- ffilename = false;
-
- /* Hash the name into the string table. */
- name = input_debug->ss + fdr.issBase + internal_sym.iss;
- if (*name == '\0')
- internal_sym.iss = 0;
- else
- {
- struct string_hash_entry *sh;
-
- sh = string_hash_lookup (&ainfo->str_hash, name, true, true);
- if (sh == (struct string_hash_entry *) NULL)
- return false;
- if (sh->val == -1)
- {
- sh->val = output_symhdr->issMax;
- output_symhdr->issMax += strlen (name) + 1;
- if (ainfo->ss_hash == (struct string_hash_entry *) NULL)
- ainfo->ss_hash = sh;
- if (ainfo->ss_hash_end
- != (struct string_hash_entry *) NULL)
- ainfo->ss_hash_end->next = sh;
- ainfo->ss_hash_end = sh;
- }
- internal_sym.iss = sh->val;
- }
-
- if (ffilename)
- {
- fdr.rss = internal_sym.iss;
- fgotfilename = true;
- }
- }
-
- (*swap_sym_out) (output_bfd, &internal_sym, sym_out);
- sym_out += external_sym_size;
- }
-
- fdr.isymBase = output_symhdr->isymMax;
- output_symhdr->isymMax += fdr.csym;
-
- /* Copy the information that does not need swapping. */
-
- /* FIXME: If we are relaxing, we need to adjust the line
- numbers. Frankly, forget it. Anybody using stabs debugging
- information will not use this line number information, and
- stabs are adjusted correctly. */
- if (fdr.cbLine > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->line, &ainfo->line_end,
- input_bfd,
- input_symhdr->cbLineOffset + fdr.cbLineOffset,
- fdr.cbLine))
- return false;
- fdr.ilineBase = output_symhdr->ilineMax;
- fdr.cbLineOffset = output_symhdr->cbLine;
- output_symhdr->ilineMax += fdr.cline;
- output_symhdr->cbLine += fdr.cbLine;
- }
- if (fdr.caux > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->aux, &ainfo->aux_end,
- input_bfd,
- (input_symhdr->cbAuxOffset
- + fdr.iauxBase * sizeof (union aux_ext)),
- fdr.caux * sizeof (union aux_ext)))
- return false;
- fdr.iauxBase = output_symhdr->iauxMax;
- output_symhdr->iauxMax += fdr.caux;
- }
- if (! info->relocateable)
- {
-
- /* When are are hashing strings, we lie about the number of
- strings attached to each FDR. We need to set cbSs
- because some versions of dbx apparently use it to decide
- how much of the string table to read in. */
- fdr.issBase = 0;
- fdr.cbSs = output_symhdr->issMax;
- }
- else if (fdr.cbSs > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end,
- input_bfd,
- input_symhdr->cbSsOffset + fdr.issBase,
- fdr.cbSs))
- return false;
- fdr.issBase = output_symhdr->issMax;
- output_symhdr->issMax += fdr.cbSs;
- }
-
- if ((output_bfd->xvec->header_byteorder
- == input_bfd->xvec->header_byteorder)
- && input_debug->adjust == (struct ecoff_value_adjust *) NULL)
- {
- /* The two BFD's have the same endianness, and we don't have
- to adjust the PDR addresses, so simply copying the
- information will suffice. */
- BFD_ASSERT (external_pdr_size == input_swap->external_pdr_size);
- if (fdr.cpd > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end,
- input_bfd,
- (input_symhdr->cbPdOffset
- + fdr.ipdFirst * external_pdr_size),
- fdr.cpd * external_pdr_size))
- return false;
- }
- BFD_ASSERT (external_opt_size == input_swap->external_opt_size);
- if (fdr.copt > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end,
- input_bfd,
- (input_symhdr->cbOptOffset
- + fdr.ioptBase * external_opt_size),
- fdr.copt * external_opt_size))
- return false;
- }
- }
- else
- {
- bfd_size_type outsz, insz;
- bfd_byte *in;
- bfd_byte *end;
- bfd_byte *out;
-
- /* The two BFD's have different endianness, so we must swap
- everything in and out. This code would always work, but
- it would be unnecessarily slow in the normal case. */
- outsz = external_pdr_size;
- insz = input_swap->external_pdr_size;
- in = ((bfd_byte *) input_debug->external_pdr
- + fdr.ipdFirst * insz);
- end = in + fdr.cpd * insz;
- sz = fdr.cpd * outsz;
- out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end, out,
- sz))
- return false;
- for (; in < end; in += insz, out += outsz)
- {
- PDR pdr;
-
- (*input_swap->swap_pdr_in) (input_bfd, (PTR) in, &pdr);
-
- /* If we have been relaxing, we may have to adjust the
- address. */
- if (input_debug->adjust != (struct ecoff_value_adjust *) NULL)
- {
- bfd_vma adr;
- struct ecoff_value_adjust *adjust;
-
- adr = fdr_adr + pdr.adr;
- for (adjust = input_debug->adjust;
- adjust != (struct ecoff_value_adjust *) NULL;
- adjust = adjust->next)
- if (adr >= adjust->start
- && adr < adjust->end)
- pdr.adr += adjust->adjust;
- }
-
- (*output_swap->swap_pdr_out) (output_bfd, &pdr, (PTR) out);
- }
-
- /* Swap over the optimization information. */
- outsz = external_opt_size;
- insz = input_swap->external_opt_size;
- in = ((bfd_byte *) input_debug->external_opt
- + fdr.ioptBase * insz);
- end = in + fdr.copt * insz;
- sz = fdr.copt * outsz;
- out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end, out,
- sz))
- return false;
- for (; in < end; in += insz, out += outsz)
- {
- OPTR opt;
-
- (*input_swap->swap_opt_in) (input_bfd, (PTR) in, &opt);
- (*output_swap->swap_opt_out) (output_bfd, &opt, (PTR) out);
- }
- }
-
- fdr.ipdFirst = output_symhdr->ipdMax;
- output_symhdr->ipdMax += fdr.cpd;
- fdr.ioptBase = output_symhdr->ioptMax;
- output_symhdr->ioptMax += fdr.copt;
-
- if (fdr.crfd <= 0)
- {
- /* Point this FDR at the table of RFD's we created. */
- fdr.rfdBase = newrfdbase;
- fdr.crfd = input_symhdr->ifdMax;
- }
- else
- {
- /* Point this FDR at the remapped RFD's. */
- fdr.rfdBase += oldrfdbase;
- }
-
- (*swap_fdr_out) (output_bfd, &fdr, fdr_out);
- fdr_out += external_fdr_size;
- ++output_symhdr->ifdMax;
- }
-
- return true;
-}
-
-/* Add a string to the debugging information we are accumulating.
- Return the offset from the fdr string base. */
-
-static long ecoff_add_string PARAMS ((struct accumulate *,
- struct bfd_link_info *,
- struct ecoff_debug_info *,
- FDR *fdr, const char *string));
-
-static long
-ecoff_add_string (ainfo, info, debug, fdr, string)
- struct accumulate *ainfo;
- struct bfd_link_info *info;
- struct ecoff_debug_info *debug;
- FDR *fdr;
- const char *string;
-{
- HDRR *symhdr;
- size_t len;
- bfd_size_type ret;
-
- symhdr = &debug->symbolic_header;
- len = strlen (string);
- if (info->relocateable)
- {
- if (!add_memory_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end, (PTR) string,
- len + 1))
- return -1;
- ret = symhdr->issMax;
- symhdr->issMax += len + 1;
- fdr->cbSs += len + 1;
- }
- else
- {
- struct string_hash_entry *sh;
-
- sh = string_hash_lookup (&ainfo->str_hash, string, true, true);
- if (sh == (struct string_hash_entry *) NULL)
- return -1;
- if (sh->val == -1)
- {
- sh->val = symhdr->issMax;
- symhdr->issMax += len + 1;
- if (ainfo->ss_hash == (struct string_hash_entry *) NULL)
- ainfo->ss_hash = sh;
- if (ainfo->ss_hash_end
- != (struct string_hash_entry *) NULL)
- ainfo->ss_hash_end->next = sh;
- ainfo->ss_hash_end = sh;
- }
- ret = sh->val;
- }
-
- return ret;
-}
-
-/* Add debugging information from a non-ECOFF file. */
-
-boolean
-bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug,
- output_swap, input_bfd, info)
- 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 *info;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
- void (* const swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR))
- = output_swap->swap_sym_out;
- HDRR *output_symhdr = &output_debug->symbolic_header;
- FDR fdr;
- asection *sec;
- asymbol **symbols;
- asymbol **sym_ptr;
- asymbol **sym_end;
- long symsize;
- long symcount;
- PTR external_fdr;
-
- memset ((PTR) &fdr, 0, sizeof fdr);
-
- sec = bfd_get_section_by_name (input_bfd, ".text");
- if (sec != NULL)
- fdr.adr = sec->output_section->vma + sec->output_offset;
- else
- {
- /* FIXME: What about .init or .fini? */
- fdr.adr = 0;
- }
-
- fdr.issBase = output_symhdr->issMax;
- fdr.cbSs = 0;
- fdr.rss = ecoff_add_string (ainfo, info, output_debug, &fdr,
- bfd_get_filename (input_bfd));
- if (fdr.rss == -1)
- return false;
- fdr.isymBase = output_symhdr->isymMax;
-
- /* Get the local symbols from the input BFD. */
- symsize = bfd_get_symtab_upper_bound (input_bfd);
- if (symsize < 0)
- return false;
- symbols = (asymbol **) bfd_alloc (output_bfd, symsize);
- if (symbols == (asymbol **) NULL)
- return false;
- symcount = bfd_canonicalize_symtab (input_bfd, symbols);
- if (symcount < 0)
- return false;
- sym_end = symbols + symcount;
-
- /* Handle the local symbols. Any external symbols are handled
- separately. */
- fdr.csym = 0;
- for (sym_ptr = symbols; sym_ptr != sym_end; sym_ptr++)
- {
- SYMR internal_sym;
- PTR external_sym;
-
- if (((*sym_ptr)->flags & BSF_EXPORT) != 0)
- continue;
- memset ((PTR) &internal_sym, 0, sizeof internal_sym);
- internal_sym.iss = ecoff_add_string (ainfo, info, output_debug, &fdr,
- (*sym_ptr)->name);
-
- if (internal_sym.iss == -1)
- return false;
- if (bfd_is_com_section ((*sym_ptr)->section)
- || bfd_is_und_section ((*sym_ptr)->section))
- internal_sym.value = (*sym_ptr)->value;
- else
- internal_sym.value = ((*sym_ptr)->value
- + (*sym_ptr)->section->output_offset
- + (*sym_ptr)->section->output_section->vma);
- internal_sym.st = stNil;
- internal_sym.sc = scUndefined;
- internal_sym.index = indexNil;
-
- external_sym = (PTR) obstack_alloc (&ainfo->memory,
- output_swap->external_sym_size);
- if (!external_sym)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- (*swap_sym_out) (output_bfd, &internal_sym, external_sym);
- add_memory_shuffle (ainfo, &ainfo->sym, &ainfo->sym_end,
- external_sym, output_swap->external_sym_size);
- ++fdr.csym;
- ++output_symhdr->isymMax;
- }
-
- bfd_release (output_bfd, (PTR) symbols);
-
- /* Leave everything else in the FDR zeroed out. This will cause
- the lang field to be langC. The fBigendian field will
- indicate little endian format, but it doesn't matter because
- it only applies to aux fields and there are none. */
- external_fdr = (PTR) obstack_alloc (&ainfo->memory,
- output_swap->external_fdr_size);
- if (!external_fdr)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- (*output_swap->swap_fdr_out) (output_bfd, &fdr, external_fdr);
- add_memory_shuffle (ainfo, &ainfo->fdr, &ainfo->fdr_end,
- external_fdr, output_swap->external_fdr_size);
-
- ++output_symhdr->ifdMax;
-
- return true;
-}
-
-/* Set up ECOFF debugging information for the external symbols.
- FIXME: This is done using a memory buffer, but it should be
- probably be changed to use a shuffle structure. The assembler uses
- this interface, so that must be changed to do something else. */
-
-boolean
-bfd_ecoff_debug_externals (abfd, debug, swap, relocateable, get_extr,
- set_index)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- boolean relocateable;
- boolean (*get_extr) PARAMS ((asymbol *, EXTR *));
- void (*set_index) PARAMS ((asymbol *, bfd_size_type));
-{
- HDRR * const symhdr = &debug->symbolic_header;
- asymbol **sym_ptr_ptr;
- size_t c;
-
- sym_ptr_ptr = bfd_get_outsymbols (abfd);
- if (sym_ptr_ptr == NULL)
- return true;
-
- for (c = bfd_get_symcount (abfd); c > 0; c--, sym_ptr_ptr++)
- {
- asymbol *sym_ptr;
- EXTR esym;
-
- sym_ptr = *sym_ptr_ptr;
-
- /* Get the external symbol information. */
- if ((*get_extr) (sym_ptr, &esym) == false)
- continue;
-
- /* If we're producing an executable, move common symbols into
- bss. */
- if (relocateable == false)
- {
- if (esym.asym.sc == scCommon)
- esym.asym.sc = scBss;
- else if (esym.asym.sc == scSCommon)
- esym.asym.sc = scSBss;
- }
-
- if (bfd_is_com_section (sym_ptr->section)
- || bfd_is_und_section (sym_ptr->section)
- || sym_ptr->section->output_section == (asection *) NULL)
- {
- /* FIXME: gas does not keep the value of a small undefined
- symbol in the symbol itself, because of relocation
- problems. */
- if (esym.asym.sc != scSUndefined
- || esym.asym.value == 0
- || sym_ptr->value != 0)
- esym.asym.value = sym_ptr->value;
- }
- else
- esym.asym.value = (sym_ptr->value
- + sym_ptr->section->output_offset
- + sym_ptr->section->output_section->vma);
-
- if (set_index)
- (*set_index) (sym_ptr, (bfd_size_type) symhdr->iextMax);
-
- if (! bfd_ecoff_debug_one_external (abfd, debug, swap,
- sym_ptr->name, &esym))
- return false;
- }
-
- return true;
-}
-
-/* Add a single external symbol to the debugging information. */
-
-boolean
-bfd_ecoff_debug_one_external (abfd, debug, swap, name, esym)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- const char *name;
- EXTR *esym;
-{
- const bfd_size_type external_ext_size = swap->external_ext_size;
- void (* const swap_ext_out) PARAMS ((bfd *, const EXTR *, PTR))
- = swap->swap_ext_out;
- HDRR * const symhdr = &debug->symbolic_header;
- size_t namelen;
-
- namelen = strlen (name);
-
- if ((size_t) (debug->ssext_end - debug->ssext)
- < symhdr->issExtMax + namelen + 1)
- {
- if (ecoff_add_bytes ((char **) &debug->ssext,
- (char **) &debug->ssext_end,
- symhdr->issExtMax + namelen + 1)
- == false)
- return false;
- }
- if ((size_t) ((char *) debug->external_ext_end
- - (char *) debug->external_ext)
- < (symhdr->iextMax + 1) * external_ext_size)
- {
- if (ecoff_add_bytes ((char **) &debug->external_ext,
- (char **) &debug->external_ext_end,
- (symhdr->iextMax + 1) * external_ext_size)
- == false)
- return false;
- }
-
- esym->asym.iss = symhdr->issExtMax;
-
- (*swap_ext_out) (abfd, esym,
- ((char *) debug->external_ext
- + symhdr->iextMax * swap->external_ext_size));
-
- ++symhdr->iextMax;
-
- strcpy (debug->ssext + symhdr->issExtMax, name);
- symhdr->issExtMax += namelen + 1;
-
- return true;
-}
-
-/* Align the ECOFF debugging information. */
-
-/*ARGSUSED*/
-static void
-ecoff_align_debug (abfd, debug, swap)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
-{
- HDRR * const symhdr = &debug->symbolic_header;
- bfd_size_type debug_align, aux_align, rfd_align;
- size_t add;
-
- /* Adjust the counts so that structures are aligned. */
- debug_align = swap->debug_align;
- aux_align = debug_align / sizeof (union aux_ext);
- rfd_align = debug_align / swap->external_rfd_size;
-
- add = debug_align - (symhdr->cbLine & (debug_align - 1));
- if (add != debug_align)
- {
- if (debug->line != (unsigned char *) NULL)
- memset ((PTR) (debug->line + symhdr->cbLine), 0, add);
- symhdr->cbLine += add;
- }
-
- add = debug_align - (symhdr->issMax & (debug_align - 1));
- if (add != debug_align)
- {
- if (debug->ss != (char *) NULL)
- memset ((PTR) (debug->ss + symhdr->issMax), 0, add);
- symhdr->issMax += add;
- }
-
- add = debug_align - (symhdr->issExtMax & (debug_align - 1));
- if (add != debug_align)
- {
- if (debug->ssext != (char *) NULL)
- memset ((PTR) (debug->ssext + symhdr->issExtMax), 0, add);
- symhdr->issExtMax += add;
- }
-
- add = aux_align - (symhdr->iauxMax & (aux_align - 1));
- if (add != aux_align)
- {
- if (debug->external_aux != (union aux_ext *) NULL)
- memset ((PTR) (debug->external_aux + symhdr->iauxMax), 0,
- add * sizeof (union aux_ext));
- symhdr->iauxMax += add;
- }
-
- add = rfd_align - (symhdr->crfd & (rfd_align - 1));
- if (add != rfd_align)
- {
- if (debug->external_rfd != (PTR) NULL)
- memset ((PTR) ((char *) debug->external_rfd
- + symhdr->crfd * swap->external_rfd_size),
- 0, (size_t) (add * swap->external_rfd_size));
- symhdr->crfd += add;
- }
-}
-
-/* Return the size required by the ECOFF debugging information. */
-
-bfd_size_type
-bfd_ecoff_debug_size (abfd, debug, swap)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
-{
- bfd_size_type tot;
-
- ecoff_align_debug (abfd, debug, swap);
- tot = swap->external_hdr_size;
-
-#define ADD(count, size) \
- tot += debug->symbolic_header.count * size
-
- ADD (cbLine, sizeof (unsigned char));
- ADD (idnMax, swap->external_dnr_size);
- ADD (ipdMax, swap->external_pdr_size);
- ADD (isymMax, swap->external_sym_size);
- ADD (ioptMax, swap->external_opt_size);
- ADD (iauxMax, sizeof (union aux_ext));
- ADD (issMax, sizeof (char));
- ADD (issExtMax, sizeof (char));
- ADD (ifdMax, swap->external_fdr_size);
- ADD (crfd, swap->external_rfd_size);
- ADD (iextMax, swap->external_ext_size);
-
-#undef ADD
-
- return tot;
-}
-
-/* Write out the ECOFF symbolic header, given the file position it is
- going to be placed at. This assumes that the counts are set
- correctly. */
-
-static boolean
-ecoff_write_symhdr (abfd, debug, swap, where)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- file_ptr where;
-{
- HDRR * const symhdr = &debug->symbolic_header;
- char *buff = NULL;
-
- ecoff_align_debug (abfd, debug, swap);
-
- /* Go to the right location in the file. */
- if (bfd_seek (abfd, where, SEEK_SET) != 0)
- return false;
-
- where += swap->external_hdr_size;
-
- symhdr->magic = swap->sym_magic;
-
- /* Fill in the file offsets. */
-#define SET(offset, count, size) \
- if (symhdr->count == 0) \
- symhdr->offset = 0; \
- else \
- { \
- symhdr->offset = where; \
- where += symhdr->count * size; \
- }
-
- SET (cbLineOffset, cbLine, sizeof (unsigned char));
- SET (cbDnOffset, idnMax, swap->external_dnr_size);
- SET (cbPdOffset, ipdMax, swap->external_pdr_size);
- SET (cbSymOffset, isymMax, swap->external_sym_size);
- SET (cbOptOffset, ioptMax, swap->external_opt_size);
- SET (cbAuxOffset, iauxMax, sizeof (union aux_ext));
- SET (cbSsOffset, issMax, sizeof (char));
- SET (cbSsExtOffset, issExtMax, sizeof (char));
- SET (cbFdOffset, ifdMax, swap->external_fdr_size);
- SET (cbRfdOffset, crfd, swap->external_rfd_size);
- SET (cbExtOffset, iextMax, swap->external_ext_size);
-#undef SET
-
- buff = (PTR) bfd_malloc ((size_t) swap->external_hdr_size);
- if (buff == NULL && swap->external_hdr_size != 0)
- goto error_return;
-
- (*swap->swap_hdr_out) (abfd, symhdr, buff);
- if (bfd_write (buff, 1, swap->external_hdr_size, abfd)
- != swap->external_hdr_size)
- goto error_return;
-
- if (buff != NULL)
- free (buff);
- return true;
- error_return:
- if (buff != NULL)
- free (buff);
- return false;
-}
-
-/* Write out the ECOFF debugging information. This function assumes
- that the information (the pointers and counts) in *DEBUG have been
- set correctly. WHERE is the position in the file to write the
- information to. This function fills in the file offsets in the
- symbolic header. */
-
-boolean
-bfd_ecoff_write_debug (abfd, debug, swap, where)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- file_ptr where;
-{
- HDRR * const symhdr = &debug->symbolic_header;
-
- if (! ecoff_write_symhdr (abfd, debug, swap, where))
- return false;
-
-#define WRITE(ptr, count, size, offset) \
- BFD_ASSERT (symhdr->offset == 0 \
- || (bfd_vma) bfd_tell (abfd) == symhdr->offset); \
- if (bfd_write ((PTR) debug->ptr, size, symhdr->count, abfd) \
- != size * symhdr->count) \
- return false;
-
- WRITE (line, cbLine, sizeof (unsigned char), cbLineOffset);
- WRITE (external_dnr, idnMax, swap->external_dnr_size, cbDnOffset);
- WRITE (external_pdr, ipdMax, swap->external_pdr_size, cbPdOffset);
- WRITE (external_sym, isymMax, swap->external_sym_size, cbSymOffset);
- WRITE (external_opt, ioptMax, swap->external_opt_size, cbOptOffset);
- WRITE (external_aux, iauxMax, sizeof (union aux_ext), cbAuxOffset);
- WRITE (ss, issMax, sizeof (char), cbSsOffset);
- WRITE (ssext, issExtMax, sizeof (char), cbSsExtOffset);
- WRITE (external_fdr, ifdMax, swap->external_fdr_size, cbFdOffset);
- WRITE (external_rfd, crfd, swap->external_rfd_size, cbRfdOffset);
- WRITE (external_ext, iextMax, swap->external_ext_size, cbExtOffset);
-#undef WRITE
-
- return true;
-}
-
-/* Write out a shuffle list. */
-
-static boolean ecoff_write_shuffle PARAMS ((bfd *,
- const struct ecoff_debug_swap *,
- struct shuffle *, PTR space));
-
-static boolean
-ecoff_write_shuffle (abfd, swap, shuffle, space)
- bfd *abfd;
- const struct ecoff_debug_swap *swap;
- struct shuffle *shuffle;
- PTR space;
-{
- register struct shuffle *l;
- unsigned long total;
-
- total = 0;
- for (l = shuffle; l != (struct shuffle *) NULL; l = l->next)
- {
- if (! l->filep)
- {
- if (bfd_write (l->u.memory, 1, l->size, abfd) != l->size)
- return false;
- }
- else
- {
- if (bfd_seek (l->u.file.input_bfd, l->u.file.offset, SEEK_SET) != 0
- || bfd_read (space, 1, l->size, l->u.file.input_bfd) != l->size
- || bfd_write (space, 1, l->size, abfd) != l->size)
- return false;
- }
- total += l->size;
- }
-
- if ((total & (swap->debug_align - 1)) != 0)
- {
- unsigned int i;
- bfd_byte *s;
-
- i = swap->debug_align - (total & (swap->debug_align - 1));
- s = (bfd_byte *) bfd_malloc (i);
- if (s == NULL && i != 0)
- return false;
-
- memset ((PTR) s, 0, i);
- if (bfd_write ((PTR) s, 1, i, abfd) != i)
- {
- free (s);
- return false;
- }
- free (s);
- }
-
- return true;
-}
-
-/* Write out debugging information using accumulated linker
- information. */
-
-boolean
-bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where)
- PTR handle;
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- struct bfd_link_info *info;
- file_ptr where;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
- PTR space = NULL;
-
- if (! ecoff_write_symhdr (abfd, debug, swap, where))
- goto error_return;
-
- space = (PTR) bfd_malloc (ainfo->largest_file_shuffle);
- if (space == NULL && ainfo->largest_file_shuffle != 0)
- goto error_return;
-
- if (! ecoff_write_shuffle (abfd, swap, ainfo->line, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->pdr, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->sym, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->opt, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->aux, space))
- goto error_return;
-
- /* The string table is written out from the hash table if this is a
- final link. */
- if (info->relocateable)
- {
- BFD_ASSERT (ainfo->ss_hash == (struct string_hash_entry *) NULL);
- if (! ecoff_write_shuffle (abfd, swap, ainfo->ss, space))
- goto error_return;
- }
- else
- {
- unsigned long total;
- bfd_byte null;
- struct string_hash_entry *sh;
-
- BFD_ASSERT (ainfo->ss == (struct shuffle *) NULL);
- null = 0;
- if (bfd_write ((PTR) &null, 1, 1, abfd) != 1)
- goto error_return;
- total = 1;
- BFD_ASSERT (ainfo->ss_hash == NULL || ainfo->ss_hash->val == 1);
- for (sh = ainfo->ss_hash;
- sh != (struct string_hash_entry *) NULL;
- sh = sh->next)
- {
- size_t len;
-
- len = strlen (sh->root.string);
- if (bfd_write ((PTR) sh->root.string, 1, len + 1, abfd) != len + 1)
- goto error_return;
- total += len + 1;
- }
-
- if ((total & (swap->debug_align - 1)) != 0)
- {
- unsigned int i;
- bfd_byte *s;
-
- i = swap->debug_align - (total & (swap->debug_align - 1));
- s = (bfd_byte *) bfd_malloc (i);
- if (s == NULL && i != 0)
- goto error_return;
- memset ((PTR) s, 0, i);
- if (bfd_write ((PTR) s, 1, i, abfd) != i)
- {
- free (s);
- goto error_return;
- }
- free (s);
- }
- }
-
- /* The external strings and symbol are not converted over to using
- shuffles. FIXME: They probably should be. */
- if (bfd_write (debug->ssext, 1, debug->symbolic_header.issExtMax, abfd)
- != (bfd_size_type) debug->symbolic_header.issExtMax)
- goto error_return;
- if ((debug->symbolic_header.issExtMax & (swap->debug_align - 1)) != 0)
- {
- unsigned int i;
- bfd_byte *s;
-
- i = (swap->debug_align
- - (debug->symbolic_header.issExtMax & (swap->debug_align - 1)));
- s = (bfd_byte *) bfd_malloc (i);
- if (s == NULL && i != 0)
- goto error_return;
- memset ((PTR) s, 0, i);
- if (bfd_write ((PTR) s, 1, i, abfd) != i)
- {
- free (s);
- goto error_return;
- }
- free (s);
- }
-
- if (! ecoff_write_shuffle (abfd, swap, ainfo->fdr, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->rfd, space))
- goto error_return;
-
- BFD_ASSERT (debug->symbolic_header.cbExtOffset == 0
- || (debug->symbolic_header.cbExtOffset
- == (bfd_vma) bfd_tell (abfd)));
-
- if (bfd_write (debug->external_ext, swap->external_ext_size,
- debug->symbolic_header.iextMax, abfd)
- != debug->symbolic_header.iextMax * swap->external_ext_size)
- goto error_return;
-
- if (space != NULL)
- free (space);
- return true;
-
- error_return:
- if (space != NULL)
- free (space);
- return false;
-}
-
-/* Handle the find_nearest_line function for both ECOFF and MIPS ELF
- files. */
-
-/* Compare FDR entries. This is called via qsort. */
-
-static int
-cmp_fdrtab_entry (leftp, rightp)
- const PTR leftp;
- const PTR rightp;
-{
- const struct ecoff_fdrtab_entry *lp =
- (const struct ecoff_fdrtab_entry *) leftp;
- const struct ecoff_fdrtab_entry *rp =
- (const struct ecoff_fdrtab_entry *) rightp;
-
- if (lp->base_addr < rp->base_addr)
- return -1;
- if (lp->base_addr > rp->base_addr)
- return 1;
- return 0;
-}
-
-/* Each file descriptor (FDR) has a memory address, to simplify
- looking up an FDR by address, we build a table covering all FDRs
- that have a least one procedure descriptor in them. The final
- table will be sorted by address so we can look it up via binary
- search. */
-
-static boolean
-mk_fdrtab (abfd, debug_info, debug_swap, line_info)
- bfd *abfd;
- struct ecoff_debug_info * const debug_info;
- const struct ecoff_debug_swap * const debug_swap;
- struct ecoff_find_line *line_info;
-{
- struct ecoff_fdrtab_entry *tab;
- FDR *fdr_ptr;
- FDR *fdr_start;
- FDR *fdr_end;
- boolean stabs;
- long len;
-
- fdr_start = debug_info->fdr;
- fdr_end = fdr_start + debug_info->symbolic_header.ifdMax;
-
- /* First, let's see how long the table needs to be: */
- for (len = 0, fdr_ptr = fdr_start; fdr_ptr < fdr_end; fdr_ptr++)
- {
- if (fdr_ptr->cpd == 0) /* skip FDRs that have no PDRs */
- continue;
- ++len;
- }
-
- /* Now, create and fill in the table: */
-
- line_info->fdrtab = ((struct ecoff_fdrtab_entry*)
- bfd_zalloc (abfd,
- len * sizeof (struct ecoff_fdrtab_entry)));
- if (line_info->fdrtab == NULL)
- return false;
- line_info->fdrtab_len = len;
-
- tab = line_info->fdrtab;
- for (fdr_ptr = fdr_start; fdr_ptr < fdr_end; fdr_ptr++)
- {
- if (fdr_ptr->cpd == 0)
- continue;
-
- /* Check whether this file has stabs debugging information. In
- a file with stabs debugging information, the second local
- symbol is named @stabs. */
- stabs = false;
- if (fdr_ptr->csym >= 2)
- {
- char *sym_ptr;
- SYMR sym;
-
- sym_ptr = ((char *) debug_info->external_sym
- + (fdr_ptr->isymBase + 1)*debug_swap->external_sym_size);
- (*debug_swap->swap_sym_in) (abfd, sym_ptr, &sym);
- if (strcmp (debug_info->ss + fdr_ptr->issBase + sym.iss,
- STABS_SYMBOL) == 0)
- stabs = true;
- }
-
- if (!stabs)
- {
- bfd_size_type external_pdr_size;
- char *pdr_ptr;
- PDR pdr;
-
- external_pdr_size = debug_swap->external_pdr_size;
-
- pdr_ptr = ((char *) debug_info->external_pdr
- + fdr_ptr->ipdFirst * external_pdr_size);
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
- /* The address of the first PDR is the offset of that
- procedure relative to the beginning of file FDR. */
- tab->base_addr = fdr_ptr->adr - pdr.adr;
- }
- else
- {
- /* XXX I don't know about stabs, so this is a guess
- (davidm@cs.arizona.edu): */
- tab->base_addr = fdr_ptr->adr;
- }
- tab->fdr = fdr_ptr;
- ++tab;
- }
-
- /* Finally, the table is sorted in increasing memory-address order.
- The table is mostly sorted already, but there are cases (e.g.,
- static functions in include files), where this does not hold.
- Use "odump -PFv" to verify... */
- qsort ((PTR) line_info->fdrtab, len,
- sizeof (struct ecoff_fdrtab_entry), cmp_fdrtab_entry);
-
- return true;
-}
-
-/* Return index of first FDR that covers to OFFSET. */
-
-static long
-fdrtab_lookup (line_info, offset)
- struct ecoff_find_line *line_info;
- bfd_vma offset;
-{
- long low, high, len;
- long mid = -1;
- struct ecoff_fdrtab_entry *tab;
-
- len = line_info->fdrtab_len;
- if (len == 0)
- return -1;
-
- tab = line_info->fdrtab;
- for (low = 0, high = len - 1 ; low != high ;)
- {
- mid = (high + low) / 2;
- if (offset >= tab[mid].base_addr && offset < tab[mid + 1].base_addr)
- goto find_min;
-
- if (tab[mid].base_addr > offset)
- high = mid;
- else
- low = mid + 1;
- }
- ++mid;
-
- /* last entry is catch-all for all higher addresses: */
- if (offset < tab[mid].base_addr)
- return -1;
-
- find_min:
-
- while (mid > 0 && tab[mid - 1].base_addr == tab[mid].base_addr)
- --mid;
-
- return mid;
-}
-
-/* Do the work of find_nearest_line. */
-
-boolean
-_bfd_ecoff_locate_line (abfd, section, offset, debug_info, debug_swap,
- line_info, filename_ptr, functionname_ptr, retline_ptr)
- bfd *abfd;
- asection *section;
- bfd_vma offset;
- struct ecoff_debug_info * const debug_info;
- const struct ecoff_debug_swap * const debug_swap;
- struct ecoff_find_line *line_info;
- const char **filename_ptr;
- const char **functionname_ptr;
- unsigned int *retline_ptr;
-{
- struct ecoff_fdrtab_entry *tab;
- boolean stabs;
- FDR *fdr_ptr;
- int i;
-
- offset += section->vma;
-
- /* Build FDR table (sorted by object file's base-address) if we
- don't have it already. */
- if (line_info->fdrtab == NULL
- && !mk_fdrtab (abfd, debug_info, debug_swap, line_info))
- return false;
-
- tab = line_info->fdrtab;
-
- /* find first FDR for address OFFSET */
- i = fdrtab_lookup (line_info, offset);
- if (i < 0)
- return false; /* no FDR, no fun... */
- fdr_ptr = tab[i].fdr;
-
- /* Check whether this file has stabs debugging information. In a
- file with stabs debugging information, the second local symbol is
- named @stabs. */
- stabs = false;
- if (fdr_ptr->csym >= 2)
- {
- char *sym_ptr;
- SYMR sym;
-
- sym_ptr = ((char *) debug_info->external_sym
- + (fdr_ptr->isymBase + 1) * debug_swap->external_sym_size);
- (*debug_swap->swap_sym_in) (abfd, sym_ptr, &sym);
- if (strcmp (debug_info->ss + fdr_ptr->issBase + sym.iss,
- STABS_SYMBOL) == 0)
- stabs = true;
- }
-
- if (!stabs)
- {
- bfd_size_type external_pdr_size;
- char *pdr_ptr;
- char *best_pdr = NULL;
- FDR *best_fdr;
- bfd_vma best_dist = ~0;
- PDR pdr;
- unsigned char *line_ptr;
- unsigned char *line_end;
- int lineno;
- /* This file uses ECOFF debugging information. Each FDR has a
- list of procedure descriptors (PDR). The address in the FDR
- is the absolute address of the first procedure. The address
- in the first PDR gives the offset of that procedure relative
- to the object file's base-address. The addresses in
- subsequent PDRs specify each procedure's address relative to
- the object file's base-address. To make things more juicy,
- whenever the PROF bit in the PDR is set, the real entry point
- of the procedure may be 16 bytes below what would normally be
- the procedure's entry point. Instead, DEC came up with a
- wicked scheme to create profiled libraries "on the fly":
- instead of shipping a regular and a profiled version of each
- library, they insert 16 bytes of unused space in front of
- each procedure and set the "prof" bit in the PDR to indicate
- that there is a gap there (this is done automagically by "as"
- when option "-pg" is specified). Thus, normally, you link
- against such a library and, except for lots of 16 byte gaps
- between functions, things will behave as usual. However,
- when invoking "ld" with option "-pg", it will fill those gaps
- with code that calls mcount(). It then moves the function's
- entry point down by 16 bytes, and out pops a binary that has
- all functions profiled.
-
- NOTE: Neither FDRs nor PDRs are strictly sorted in memory
- order. For example, when including header-files that
- define functions, the FDRs follow behind the including
- file, even though their code may have been generated at
- a lower address. File coff-alpha.c from libbfd
- illustrates this (use "odump -PFv" to look at a file's
- FDR/PDR). Similarly, PDRs are sometimes out of order
- as well. An example of this is OSF/1 v3.0 libc's
- malloc.c. I'm not sure why this happens, but it could
- be due to optimizations that reorder a function's
- position within an object-file.
-
- Strategy:
-
- On the first call to this function, we build a table of FDRs
- that is sorted by the base-address of the object-file the FDR
- is referring to. Notice that each object-file may contain
- code from multiple source files (e.g., due to code defined in
- include files). Thus, for any given base-address, there may
- be multiple FDRs (but this case is, fortunately, uncommon).
- lookup(addr) guarantees to return the first FDR that applies
- to address ADDR. Thus, after invoking lookup(), we have a
- list of FDRs that may contain the PDR for ADDR. Next, we
- walk through the PDRs of these FDRs and locate the one that
- is closest to ADDR (i.e., for which the difference between
- ADDR and the PDR's entry point is positive and minimal).
- Once, the right FDR and PDR are located, we simply walk
- through the line-number table to lookup the line-number that
- best matches ADDR. Obviously, things could be sped up by
- keeping a sorted list of PDRs instead of a sorted list of
- FDRs. However, this would increase space requirements
- considerably, which is undesirable. */
- external_pdr_size = debug_swap->external_pdr_size;
-
- /* Make offset relative to object file's start-address: */
- offset -= tab[i].base_addr;
- /* Search FDR list starting at tab[i] for the PDR that best matches
- OFFSET. Normally, the FDR list is only one entry long. */
- best_fdr = NULL;
- do
- {
- bfd_vma dist, min_dist = 0;
- char *pdr_hold;
- char *pdr_end;
-
- fdr_ptr = tab[i].fdr;
-
- pdr_ptr = ((char *) debug_info->external_pdr
- + fdr_ptr->ipdFirst * external_pdr_size);
- pdr_end = pdr_ptr + fdr_ptr->cpd * external_pdr_size;
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
- /* Find PDR that is closest to OFFSET. If pdr.prof is set,
- the procedure entry-point *may* be 0x10 below pdr.adr. We
- simply pretend that pdr.prof *implies* a lower entry-point.
- This is safe because it just means that may identify 4 NOPs
- in front of the function as belonging to the function. */
- for (pdr_hold = NULL;
- pdr_ptr < pdr_end;
- (pdr_ptr += external_pdr_size,
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr)))
- {
- if (offset >= (pdr.adr - 0x10 * pdr.prof))
- {
- dist = offset - (pdr.adr - 0x10 * pdr.prof);
- if (!pdr_hold || dist < min_dist)
- {
- min_dist = dist;
- pdr_hold = pdr_ptr;
- }
- }
- }
-
- if (!best_pdr || min_dist < best_dist)
- {
- best_dist = min_dist;
- best_fdr = fdr_ptr;
- best_pdr = pdr_hold;
- }
- /* continue looping until base_addr of next entry is different: */
- }
- while (++i < line_info->fdrtab_len
- && tab[i].base_addr == tab[i - 1].base_addr);
-
- if (!best_fdr || !best_pdr)
- return false; /* shouldn't happen... */
-
- /* phew, finally we got something that we can hold onto: */
- fdr_ptr = best_fdr;
- pdr_ptr = best_pdr;
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
- /* Now we can look for the actual line number. The line numbers
- are stored in a very funky format, which I won't try to
- describe. The search is bounded by the end of the FDRs line
- number entries. */
- line_end = debug_info->line + fdr_ptr->cbLineOffset + fdr_ptr->cbLine;
-
- /* Make offset relative to procedure entry: */
- offset -= pdr.adr - 0x10 * pdr.prof;
- lineno = pdr.lnLow;
- line_ptr = debug_info->line + fdr_ptr->cbLineOffset + pdr.cbLineOffset;
- while (line_ptr < line_end)
- {
- int delta;
- unsigned int count;
-
- delta = *line_ptr >> 4;
- if (delta >= 0x8)
- delta -= 0x10;
- count = (*line_ptr & 0xf) + 1;
- ++line_ptr;
- if (delta == -8)
- {
- delta = (((line_ptr[0]) & 0xff) << 8) + ((line_ptr[1]) & 0xff);
- if (delta >= 0x8000)
- delta -= 0x10000;
- line_ptr += 2;
- }
- lineno += delta;
- if (offset < count * 4)
- break;
- offset -= count * 4;
- }
-
- /* If fdr_ptr->rss is -1, then this file does not have full
- symbols, at least according to gdb/mipsread.c. */
- if (fdr_ptr->rss == -1)
- {
- *filename_ptr = NULL;
- if (pdr.isym == -1)
- *functionname_ptr = NULL;
- else
- {
- EXTR proc_ext;
-
- (*debug_swap->swap_ext_in)
- (abfd,
- ((char *) debug_info->external_ext
- + pdr.isym * debug_swap->external_ext_size),
- &proc_ext);
- *functionname_ptr = debug_info->ssext + proc_ext.asym.iss;
- }
- }
- else
- {
- SYMR proc_sym;
-
- *filename_ptr = debug_info->ss + fdr_ptr->issBase + fdr_ptr->rss;
- (*debug_swap->swap_sym_in)
- (abfd,
- ((char *) debug_info->external_sym
- + (fdr_ptr->isymBase + pdr.isym) * debug_swap->external_sym_size),
- &proc_sym);
- *functionname_ptr = debug_info->ss + fdr_ptr->issBase + proc_sym.iss;
- }
- if (lineno == ilineNil)
- lineno = 0;
- *retline_ptr = lineno;
- }
- else
- {
- bfd_size_type external_sym_size;
- const char *directory_name;
- const char *main_file_name;
- const char *current_file_name;
- const char *function_name;
- const char *line_file_name;
- bfd_vma low_func_vma;
- bfd_vma low_line_vma;
- boolean past_line;
- boolean past_fn;
- char *sym_ptr, *sym_ptr_end;
- size_t len, funclen;
- char *buffer = NULL;
-
- /* This file uses stabs debugging information. When gcc is not
- optimizing, it will put the line number information before
- the function name stabs entry. When gcc is optimizing, it
- will put the stabs entry for all the function first, followed
- by the line number information. (This appears to happen
- because of the two output files used by the -mgpopt switch,
- which is implied by -O). This means that we must keep
- looking through the symbols until we find both a line number
- and a function name which are beyond the address we want. */
-
- *filename_ptr = NULL;
- *functionname_ptr = NULL;
- *retline_ptr = 0;
-
- directory_name = NULL;
- main_file_name = NULL;
- current_file_name = NULL;
- function_name = NULL;
- line_file_name = NULL;
- low_func_vma = 0;
- low_line_vma = 0;
- past_line = false;
- past_fn = false;
-
- external_sym_size = debug_swap->external_sym_size;
-
- sym_ptr = ((char *) debug_info->external_sym
- + (fdr_ptr->isymBase + 2) * external_sym_size);
- sym_ptr_end = sym_ptr + (fdr_ptr->csym - 2) * external_sym_size;
- for (;
- sym_ptr < sym_ptr_end && (! past_line || ! past_fn);
- sym_ptr += external_sym_size)
- {
- SYMR sym;
-
- (*debug_swap->swap_sym_in) (abfd, sym_ptr, &sym);
-
- if (ECOFF_IS_STAB (&sym))
- {
- switch (ECOFF_UNMARK_STAB (sym.index))
- {
- case N_SO:
- main_file_name = current_file_name =
- debug_info->ss + fdr_ptr->issBase + sym.iss;
-
- /* Check the next symbol to see if it is also an
- N_SO symbol. */
- if (sym_ptr + external_sym_size < sym_ptr_end)
- {
- SYMR nextsym;
-
- (*debug_swap->swap_sym_in) (abfd,
- sym_ptr + external_sym_size,
- &nextsym);
- if (ECOFF_IS_STAB (&nextsym)
- && ECOFF_UNMARK_STAB (nextsym.index) == N_SO)
- {
- directory_name = current_file_name;
- main_file_name = current_file_name =
- debug_info->ss + fdr_ptr->issBase + nextsym.iss;
- sym_ptr += external_sym_size;
- }
- }
- break;
-
- case N_SOL:
- current_file_name =
- debug_info->ss + fdr_ptr->issBase + sym.iss;
- break;
-
- case N_FUN:
- if (sym.value > offset)
- past_fn = true;
- else if (sym.value >= low_func_vma)
- {
- low_func_vma = sym.value;
- function_name =
- debug_info->ss + fdr_ptr->issBase + sym.iss;
- }
- break;
- }
- }
- else if (sym.st == stLabel && sym.index != indexNil)
- {
- if (sym.value > offset)
- past_line = true;
- else if (sym.value >= low_line_vma)
- {
- low_line_vma = sym.value;
- line_file_name = current_file_name;
- *retline_ptr = sym.index;
- }
- }
- }
-
- if (*retline_ptr != 0)
- main_file_name = line_file_name;
-
- /* We need to remove the stuff after the colon in the function
- name. We also need to put the directory name and the file
- name together. */
- if (function_name == NULL)
- len = funclen = 0;
- else
- len = funclen = strlen (function_name) + 1;
-
- if (main_file_name != NULL
- && directory_name != NULL
- && main_file_name[0] != '/')
- len += strlen (directory_name) + strlen (main_file_name) + 1;
-
- if (len != 0)
- {
- if (line_info->find_buffer != NULL)
- free (line_info->find_buffer);
- buffer = (char *) bfd_malloc (len);
- if (buffer == NULL)
- return false;
- line_info->find_buffer = buffer;
- }
-
- if (function_name != NULL)
- {
- char *colon;
-
- strcpy (buffer, function_name);
- colon = strchr (buffer, ':');
- if (colon != NULL)
- *colon = '\0';
- *functionname_ptr = buffer;
- }
-
- if (main_file_name != NULL)
- {
- if (directory_name == NULL || main_file_name[0] == '/')
- *filename_ptr = main_file_name;
- else
- {
- sprintf (buffer + funclen, "%s%s", directory_name,
- main_file_name);
- *filename_ptr = buffer + funclen;
- }
- }
- }
-
- return true;
-}
-
-/* These routines copy symbolic information into a memory buffer.
-
- FIXME: The whole point of the shuffle code is to avoid storing
- everything in memory, since the linker is such a memory hog. This
- code makes that effort useless. It is only called by the MIPS ELF
- code when generating a shared library, so it is not that big a
- deal, but it should be fixed eventually. */
-
-/* Collect a shuffle into a memory buffer. */
-
-static boolean ecoff_collect_shuffle PARAMS ((struct shuffle *, bfd_byte *));
-
-static boolean
-ecoff_collect_shuffle (l, buff)
- struct shuffle *l;
- bfd_byte *buff;
-{
- unsigned long total;
-
- total = 0;
- for (; l != (struct shuffle *) NULL; l = l->next)
- {
- if (! l->filep)
- memcpy (buff, l->u.memory, l->size);
- else
- {
- if (bfd_seek (l->u.file.input_bfd, l->u.file.offset, SEEK_SET) != 0
- || bfd_read (buff, 1, l->size, l->u.file.input_bfd) != l->size)
- return false;
- }
- total += l->size;
- buff += l->size;
- }
-
- return true;
-}
-
-/* Copy PDR information into a memory buffer. */
-
-boolean
-_bfd_ecoff_get_accumulated_pdr (handle, buff)
- PTR handle;
- bfd_byte *buff;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
-
- return ecoff_collect_shuffle (ainfo->pdr, buff);
-}
-
-/* Copy symbol information into a memory buffer. */
-
-boolean
-_bfd_ecoff_get_accumulated_sym (handle, buff)
- PTR handle;
- bfd_byte *buff;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
-
- return ecoff_collect_shuffle (ainfo->sym, buff);
-}
-
-/* Copy the string table into a memory buffer. */
-
-boolean
-_bfd_ecoff_get_accumulated_ss (handle, buff)
- PTR handle;
- bfd_byte *buff;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
- struct string_hash_entry *sh;
- unsigned long total;
-
- /* The string table is written out from the hash table if this is a
- final link. */
- BFD_ASSERT (ainfo->ss == (struct shuffle *) NULL);
- *buff++ = '\0';
- total = 1;
- BFD_ASSERT (ainfo->ss_hash == NULL || ainfo->ss_hash->val == 1);
- for (sh = ainfo->ss_hash;
- sh != (struct string_hash_entry *) NULL;
- sh = sh->next)
- {
- size_t len;
-
- len = strlen (sh->root.string);
- memcpy (buff, (PTR) sh->root.string, len + 1);
- total += len + 1;
- buff += len + 1;
- }
-
- return true;
-}
diff --git a/contrib/gdb/bfd/ecoffswap.h b/contrib/gdb/bfd/ecoffswap.h
deleted file mode 100644
index 0d28d16883e1..000000000000
--- 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/elf-bfd.h b/contrib/gdb/bfd/elf-bfd.h
deleted file mode 100644
index ee38e5b12f4c..000000000000
--- a/contrib/gdb/bfd/elf-bfd.h
+++ /dev/null
@@ -1,858 +0,0 @@
-/* BFD back-end data structures for ELF files.
- Copyright (C) 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. */
-
-#ifndef _LIBELF_H_
-#define _LIBELF_H_ 1
-
-#include "elf/common.h"
-#include "elf/internal.h"
-#include "elf/external.h"
-#include "bfdlink.h"
-
-/* If size isn't specified as 64 or 32, NAME macro should fail. */
-#ifndef NAME
-#if ARCH_SIZE==64
-#define NAME(x,y) CAT4(x,64,_,y)
-#endif
-#if ARCH_SIZE==32
-#define NAME(x,y) CAT4(x,32,_,y)
-#endif
-#endif
-
-#ifndef NAME
-#define NAME(x,y) CAT4(x,NOSIZE,_,y)
-#endif
-
-#define ElfNAME(X) NAME(Elf,X)
-#define elfNAME(X) NAME(elf,X)
-
-/* Information held for an ELF symbol. The first field is the
- corresponding asymbol. Every symbol is an ELF file is actually a
- pointer to this structure, although it is often handled as a
- pointer to an asymbol. */
-
-typedef struct
-{
- /* The BFD symbol. */
- asymbol symbol;
- /* ELF symbol information. */
- Elf_Internal_Sym internal_elf_sym;
- /* Backend specific information. */
- union
- {
- unsigned int hppa_arg_reloc;
- PTR mips_extr;
- PTR any;
- }
- tc_data;
-} elf_symbol_type;
-
-/* ELF linker hash table entries. */
-
-struct elf_link_hash_entry
-{
- struct bfd_link_hash_entry root;
-
- /* Symbol index in output file. This is initialized to -1. It is
- set to -2 if the symbol is used by a reloc. */
- long indx;
-
- /* Symbol size. */
- bfd_size_type size;
-
- /* Symbol index as a dynamic symbol. Initialized to -1, and remains
- -1 if this is not a dynamic symbol. */
- long dynindx;
-
- /* String table index in .dynstr if this is a dynamic symbol. */
- unsigned long dynstr_index;
-
- /* If this is a weak defined symbol from a dynamic object, this
- field points to a defined symbol with the same value, if there is
- one. Otherwise it is NULL. */
- struct elf_link_hash_entry *weakdef;
-
- /* If this symbol requires an entry in the global offset table, the
- processor specific backend uses this field to hold the offset
- into the .got section. If this field is -1, then the symbol does
- not require a global offset table entry. */
- bfd_vma got_offset;
-
- /* If this symbol requires an entry in the procedure linkage table,
- the processor specific backend uses these two fields to hold the
- offset into the procedure linkage section and the offset into the
- .got section. If plt_offset is -1, then the symbol does not
- require an entry in the procedure linkage table. */
- bfd_vma plt_offset;
-
- /* If this symbol is used in the linker created sections, the processor
- specific backend uses this field to map the field into the offset
- from the beginning of the section. */
- struct elf_linker_section_pointers *linker_section_pointer;
-
- /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */
- char type;
-
- /* Some flags; legal values follow. */
- unsigned char elf_link_hash_flags;
- /* Symbol is referenced by a non-shared object. */
-#define ELF_LINK_HASH_REF_REGULAR 01
- /* Symbol is defined by a non-shared object. */
-#define ELF_LINK_HASH_DEF_REGULAR 02
- /* Symbol is referenced by a shared object. */
-#define ELF_LINK_HASH_REF_DYNAMIC 04
- /* Symbol is defined by a shared object. */
-#define ELF_LINK_HASH_DEF_DYNAMIC 010
- /* Dynamic symbol has been adjustd. */
-#define ELF_LINK_HASH_DYNAMIC_ADJUSTED 020
- /* Symbol needs a copy reloc. */
-#define ELF_LINK_HASH_NEEDS_COPY 040
- /* Symbol needs a procedure linkage table entry. */
-#define ELF_LINK_HASH_NEEDS_PLT 0100
- /* Symbol appears in a non-ELF input file. */
-#define ELF_LINK_NON_ELF 0200
- /* Note: If you add more flags, you must change the type of
- elf_link_hash_flags. */
-};
-
-/* ELF linker hash table. */
-
-struct elf_link_hash_table
-{
- struct bfd_link_hash_table root;
- /* Whether we have created the special dynamic sections required
- when linking against or generating a shared object. */
- boolean dynamic_sections_created;
- /* The BFD used to hold special sections created by the linker.
- This will be the first BFD found which requires these sections to
- be created. */
- bfd *dynobj;
- /* The number of symbols found in the link which must be put into
- the .dynsym section. */
- bfd_size_type dynsymcount;
- /* The string table of dynamic symbols, which becomes the .dynstr
- section. */
- struct bfd_strtab_hash *dynstr;
- /* The number of buckets in the hash table in the .hash section.
- This is based on the number of dynamic symbols. */
- bfd_size_type bucketcount;
- /* A linked list of DT_NEEDED names found in dynamic objects
- included in the link. */
- struct bfd_link_needed_list *needed;
-};
-
-/* Look up an entry in an ELF linker hash table. */
-
-#define elf_link_hash_lookup(table, string, create, copy, follow) \
- ((struct elf_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), \
- (copy), (follow)))
-
-/* Traverse an ELF linker hash table. */
-
-#define elf_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the ELF linker hash table from a link_info structure. */
-
-#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
-
-/* Constant information held for an ELF backend. */
-
-struct elf_size_info {
- unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
- unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
-
- unsigned char arch_size, file_align;
- unsigned char elfclass, ev_current;
- int (*write_out_phdrs) PARAMS ((bfd *, Elf_Internal_Phdr *, int));
- boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
- void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
- void (*swap_symbol_out) PARAMS ((bfd *, Elf_Internal_Sym *, PTR));
- boolean (*slurp_reloc_table) PARAMS ((bfd *, asection *, asymbol **));
- long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
- void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
-};
-
-#define elf_symbol_from(ABFD,S) \
- (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
- && (S)->the_bfd->tdata.elf_obj_data != 0) \
- ? (elf_symbol_type *) (S) \
- : 0)
-
-struct elf_backend_data
-{
- /* Whether the backend uses REL or RELA relocations. FIXME: some
- ELF backends use both. When we need to support one, this whole
- approach will need to be changed. */
- int use_rela_p;
-
- /* The architecture for this backend. */
- enum bfd_architecture arch;
-
- /* The ELF machine code (EM_xxxx) for this backend. */
- int elf_machine_code;
-
- /* The maximum page size for this backend. */
- bfd_vma maxpagesize;
-
- /* This is true if the linker should act like collect and gather
- global constructors and destructors by name. This is true for
- MIPS ELF because the Irix 5 tools can not handle the .init
- section. */
- boolean collect;
-
- /* This is true if the linker should ignore changes to the type of a
- symbol. This is true for MIPS ELF because some Irix 5 objects
- record undefined functions as STT_OBJECT although the definitions
- are STT_FUNC. */
- boolean type_change_ok;
-
- /* A function to translate an ELF RELA relocation to a BFD arelent
- structure. */
- void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
- Elf_Internal_Rela *));
-
- /* A function to translate an ELF REL relocation to a BFD arelent
- structure. */
- void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
- Elf_Internal_Rel *));
-
- /* A function to determine whether a symbol is global when
- partitioning the symbol table into local and global symbols.
- This should be NULL for most targets, in which case the correct
- thing will be done. MIPS ELF, at least on the Irix 5, has
- special requirements. */
- boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *));
-
- /* The remaining functions are hooks which are called only if they
- are not NULL. */
-
- /* A function to permit a backend specific check on whether a
- particular BFD format is relevant for an object file, and to
- permit the backend to set any global information it wishes. When
- this is called elf_elfheader is set, but anything else should be
- used with caution. If this returns false, the check_format
- routine will return a bfd_error_wrong_format error. */
- boolean (*elf_backend_object_p) PARAMS ((bfd *));
-
- /* A function to do additional symbol processing when reading the
- ELF symbol table. This is where any processor-specific special
- section indices are handled. */
- void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
-
- /* A function to do additional symbol processing after reading the
- entire ELF symbol table. */
- boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *,
- elf_symbol_type *,
- unsigned int));
-
- /* A function to do additional processing on the ELF section header
- just before writing it out. This is used to set the flags and
- type fields for some sections, or to actually write out data for
- unusual sections. */
- boolean (*elf_backend_section_processing) PARAMS ((bfd *,
- Elf32_Internal_Shdr *));
-
- /* A function to handle unusual section types when creating BFD
- sections from ELF sections. */
- boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *,
- Elf32_Internal_Shdr *,
- char *));
-
- /* A function to set up the ELF section header for a BFD section in
- preparation for writing it out. This is where the flags and type
- fields are set for unusual sections. */
- boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *,
- asection *));
-
- /* A function to get the ELF section index for a BFD section. If
- this returns true, the section was found. If it is a normal ELF
- section, *RETVAL should be left unchanged. If it is not a normal
- ELF section *RETVAL should be set to the SHN_xxxx index. */
- boolean (*elf_backend_section_from_bfd_section)
- PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval));
-
- /* If this field is not NULL, it is called by the add_symbols phase
- of a link just before adding a symbol to the global linker hash
- table. It may modify any of the fields as it wishes. If *NAME
- is set to NULL, the symbol will be skipped rather than being
- added to the hash table. This function is responsible for
- handling all processor dependent symbol bindings and section
- indices, and must set at least *FLAGS and *SEC for each processor
- dependent case; failure to do so will cause a link error. */
- boolean (*elf_add_symbol_hook)
- PARAMS ((bfd *abfd, struct bfd_link_info *info,
- const Elf_Internal_Sym *, const char **name,
- flagword *flags, asection **sec, bfd_vma *value));
-
- /* If this field is not NULL, it is called by the elf_link_output_sym
- phase of a link for each symbol which will appear in the object file. */
- boolean (*elf_backend_link_output_symbol_hook)
- PARAMS ((bfd *, struct bfd_link_info *info, const char *,
- Elf_Internal_Sym *, asection *));
-
- /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
- linker the first time it encounters a dynamic object in the link.
- This function must create any sections required for dynamic
- linking. The ABFD argument is a dynamic object. The .interp,
- .dynamic, .dynsym, .dynstr, and .hash functions have already been
- created, and this function may modify the section flags if
- desired. This function will normally create the .got and .plt
- sections, but different backends have different requirements. */
- boolean (*elf_backend_create_dynamic_sections)
- PARAMS ((bfd *abfd, struct bfd_link_info *info));
-
- /* The CHECK_RELOCS function is called by the add_symbols phase of
- the ELF backend linker. It is called once for each section with
- relocs of an object file, just after the symbols for the object
- file have been added to the global linker hash table. The
- function must look through the relocs and do any special handling
- required. This generally means allocating space in the global
- offset table, and perhaps allocating space for a reloc. The
- relocs are always passed as Rela structures; if the section
- actually uses Rel structures, the r_addend field will always be
- zero. */
- boolean (*check_relocs)
- PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
- const Elf_Internal_Rela *relocs));
-
- /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
- linker for every symbol which is defined by a dynamic object and
- referenced by a regular object. This is called after all the
- input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
- function has been called. The hash table entry should be
- bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
- defined in a section from a dynamic object. Dynamic object
- sections are not included in the final link, and this function is
- responsible for changing the value to something which the rest of
- the link can deal with. This will normally involve adding an
- entry to the .plt or .got or some such section, and setting the
- symbol to point to that. */
- boolean (*elf_backend_adjust_dynamic_symbol)
- PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
-
- /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
- linker after all the linker input files have been seen but before
- the sections sizes have been set. This is called after
- ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
- It is only called when linking against a dynamic object. It must
- set the sizes of the dynamic sections, and may fill in their
- contents as well. The generic ELF linker can handle the .dynsym,
- .dynstr and .hash sections. This function must handle the
- .interp section and any sections created by the
- CREATE_DYNAMIC_SECTIONS entry point. */
- boolean (*elf_backend_size_dynamic_sections)
- PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
-
- /* 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. */
- boolean (*elf_backend_relocate_section)
- PARAMS ((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));
-
- /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
- linker just before it writes a symbol out to the .dynsym section.
- The processor backend may make any required adjustment to the
- symbol. It may also take the opportunity to set contents of the
- dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on
- all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
- on those symbols which are defined by a dynamic object. */
- boolean (*elf_backend_finish_dynamic_symbol)
- PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
- struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
-
- /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
- linker just before it writes all the dynamic sections out to the
- output file. The FINISH_DYNAMIC_SYMBOL will have been called on
- all dynamic symbols. */
- boolean (*elf_backend_finish_dynamic_sections)
- PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
-
- /* A function to do any beginning processing needed for the ELF file
- before building the ELF headers and computing file positions. */
- void (*elf_backend_begin_write_processing)
- PARAMS ((bfd *, struct bfd_link_info *));
-
- /* A function to do any final processing needed for the ELF file
- before writing it out. The LINKER argument is true if this BFD
- was created by the ELF backend linker. */
- void (*elf_backend_final_write_processing)
- PARAMS ((bfd *, boolean linker));
-
- /* This function is called by get_program_header_size. It should
- return the number of additional program segments which this BFD
- will need. It should return -1 on error. */
- int (*elf_backend_additional_program_headers) PARAMS ((bfd *));
-
- /* This function is called to modify an existing segment map in a
- backend specific fashion. */
- boolean (*elf_backend_modify_segment_map) PARAMS ((bfd *));
-
- /* The swapping table to use when dealing with ECOFF information.
- Used for the MIPS ELF .mdebug section. */
- const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
-
- /* Alternate EM_xxxx machine codes for this backend. */
- int elf_machine_alt1;
- int elf_machine_alt2;
-
- const struct elf_size_info *s;
-
- unsigned want_got_plt : 1;
- unsigned plt_readonly : 1;
- unsigned want_plt_sym : 1;
-};
-
-/* Information stored for each BFD section in an ELF file. This
- structure is allocated by elf_new_section_hook. */
-
-struct bfd_elf_section_data
-{
- /* The ELF header for this section. */
- Elf_Internal_Shdr this_hdr;
- /* The ELF header for the reloc section associated with this
- section, if any. */
- Elf_Internal_Shdr rel_hdr;
- /* The ELF section number of this section. Only used for an output
- file. */
- int this_idx;
- /* The ELF section number of the reloc section associated with this
- section, if any. Only used for an output file. */
- int rel_idx;
- /* Used by the backend linker to store the symbol hash table entries
- associated with relocs against global symbols. */
- struct elf_link_hash_entry **rel_hashes;
- /* A pointer to the swapped relocs. If the section uses REL relocs,
- rather than RELA, all the r_addend fields will be zero. This
- pointer may be NULL. It is used by the backend linker. */
- Elf_Internal_Rela *relocs;
- /* Used by the backend linker when generating a shared library to
- record the dynamic symbol index for a section symbol
- corresponding to this section. */
- long dynindx;
- /* A pointer available for the processor specific ELF backend. */
- PTR tdata;
-};
-
-#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
-
-#define get_elf_backend_data(abfd) \
- ((struct elf_backend_data *) (abfd)->xvec->backend_data)
-
-/* Enumeration to specify the special section. */
-typedef enum elf_linker_section_enum
-{
- LINKER_SECTION_UNKNOWN, /* not used */
- LINKER_SECTION_GOT, /* .got section for global offset pointers */
- LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */
- LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */
- LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */
- LINKER_SECTION_MAX /* # of linker sections */
-} elf_linker_section_enum_t;
-
-/* Sections created by the linker. */
-
-typedef struct elf_linker_section
-{
- char *name; /* name of the section */
- char *rel_name; /* name of the associated .rel{,a}. section */
- char *bss_name; /* name of a related .bss section */
- char *sym_name; /* name of symbol to reference this section */
- asection *section; /* pointer to the section */
- asection *bss_section; /* pointer to the bss section associated with this */
- asection *rel_section; /* pointer to the relocations needed for this section */
- struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */
- bfd_vma initial_size; /* initial size before any linker generated allocations */
- bfd_vma sym_offset; /* offset of symbol from beginning of section */
- bfd_vma hole_size; /* size of reserved address hole in allocation */
- bfd_vma hole_offset; /* current offset for the hole */
- bfd_vma max_hole_offset; /* maximum offset for the hole */
- elf_linker_section_enum_t which; /* which section this is */
- boolean hole_written_p; /* whether the hole has been initialized */
- int alignment; /* alignment for the section */
- flagword flags; /* flags to use to create the section */
-} elf_linker_section_t;
-
-/* Linked list of allocated pointer entries. This hangs off of the symbol lists, and
- provides allows us to return different pointers, based on different addend's. */
-
-typedef struct elf_linker_section_pointers
-{
- struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
- bfd_vma offset; /* offset of pointer from beginning of section */
- bfd_signed_vma addend; /* addend used */
- elf_linker_section_enum_t which; /* which linker section this is */
- boolean written_address_p; /* whether address was written yet */
-} elf_linker_section_pointers_t;
-
-/* Some private data is stashed away for future use using the tdata pointer
- in the bfd structure. */
-
-struct elf_obj_tdata
-{
- Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
- Elf_Internal_Shdr **elf_sect_ptr;
- Elf_Internal_Phdr *phdr;
- struct elf_segment_map *segment_map;
- struct bfd_strtab_hash *strtab_ptr;
- int num_locals;
- int num_globals;
- asymbol **section_syms; /* STT_SECTION symbols for each section */
- Elf_Internal_Shdr symtab_hdr;
- Elf_Internal_Shdr shstrtab_hdr;
- Elf_Internal_Shdr strtab_hdr;
- Elf_Internal_Shdr dynsymtab_hdr;
- Elf_Internal_Shdr dynstrtab_hdr;
- unsigned int symtab_section, shstrtab_section;
- unsigned int strtab_section, dynsymtab_section;
- file_ptr next_file_pos;
- void *prstatus; /* The raw /proc prstatus structure */
- void *prpsinfo; /* The raw /proc prpsinfo structure */
- bfd_vma gp; /* The gp value (MIPS only, for now) */
- unsigned int gp_size; /* The gp size (MIPS only, for now) */
-
- /* This is set to true if the object was created by the backend
- linker. */
- boolean linker;
-
- /* A mapping from external symbols to entries in the linker hash
- table, used when linking. This is indexed by the symbol index
- minus the sh_info field of the symbol table header. */
- struct elf_link_hash_entry **sym_hashes;
-
- /* A mapping from local symbols to offsets into the global offset
- table, used when linking. This is indexed by the symbol index. */
- bfd_vma *local_got_offsets;
-
- /* A mapping from local symbols to offsets into the various linker
- sections added. This is index by the symbol index. */
- elf_linker_section_pointers_t **linker_section_pointers;
-
- /* The linker ELF emulation code needs to let the backend ELF linker
- know what filename should be used for a dynamic object if the
- dynamic object is found using a search. The emulation code then
- sometimes needs to know what name was actually used. Until the
- file has been added to the linker symbol table, this field holds
- the name the linker wants. After it has been added, it holds the
- name actually used, which will be the DT_SONAME entry if there is
- one. */
- const char *dt_name;
-
- /* Irix 5 often screws up the symbol table, sorting local symbols
- after global symbols. This flag is set if the symbol table in
- this BFD appears to be screwed up. If it is, we ignore the
- sh_info field in the symbol table header, and always read all the
- symbols. */
- boolean bad_symtab;
-
- /* Records the result of `get_program_header_size'. */
- bfd_size_type program_header_size;
-
- /* Used by find_nearest_line entry point. */
- PTR line_info;
-
- /* Used by MIPS ELF find_nearest_line entry point. The structure
- could be included directly in this one, but there's no point to
- wasting the memory just for the infrequently called
- find_nearest_line. */
- struct mips_elf_find_line *find_line_info;
-
- /* Used to determine if the e_flags field has been initialized */
- boolean flags_init;
-
- /* Linker sections that we are interested in. */
- struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
-};
-
-#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
-#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
-#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
-#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
-#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
-#define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
-#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
-#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
-#define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
-#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
-#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
-#define elf_gp(bfd) (elf_tdata(bfd) -> gp)
-#define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
-#define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
-#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got_offsets)
-#define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
-#define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
-#define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
-#define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
-#define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
-
-extern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));
-extern char *bfd_elf_string_from_elf_section
- PARAMS ((bfd *, unsigned, unsigned));
-extern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
-
-extern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
-extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
- bfd_print_symbol_type));
-#define elf_string_from_elf_strtab(abfd,strindex) \
- bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
-
-#define bfd_elf32_print_symbol bfd_elf_print_symbol
-#define bfd_elf64_print_symbol bfd_elf_print_symbol
-#define bfd_elf32_mkobject bfd_elf_mkobject
-#define bfd_elf64_mkobject bfd_elf_mkobject
-#define elf_mkobject bfd_elf_mkobject
-
-extern unsigned long bfd_elf_hash PARAMS ((CONST unsigned char *));
-
-extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
- arelent *,
- asymbol *,
- PTR,
- asection *,
- bfd *,
- char **));
-extern boolean bfd_elf_mkobject PARAMS ((bfd *));
-extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
-extern boolean _bfd_elf_make_section_from_shdr
- PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
-extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
- PARAMS ((bfd *));
-extern boolean _bfd_elf_link_hash_table_init
- PARAMS ((struct elf_link_hash_table *, bfd *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-extern boolean _bfd_elf_copy_private_symbol_data
- PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
-extern boolean _bfd_elf_copy_private_section_data
- PARAMS ((bfd *, asection *, bfd *, asection *));
-extern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
-extern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr,
- bfd_size_type));
-extern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
-extern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
-extern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
-extern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
-extern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
-extern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
- arelent **, asymbol **));
-extern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
-extern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
- symbol_info *));
-extern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
-extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
- unsigned long));
-extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
- asymbol **,
- bfd_vma, CONST char **,
- CONST char **,
- unsigned int *));
-#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
-#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-extern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
-extern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
-
-/* If the target doesn't have reloc handling written yet: */
-extern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
- Elf_Internal_Rela *));
-
-asection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
-boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
- struct bfd_link_info *));
-struct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
-boolean
-_bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
- struct elf_link_hash_entry *));
-boolean
-_bfd_elf_compute_section_file_positions PARAMS ((bfd *,
- struct bfd_link_info *));
-void _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
-file_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
- file_ptr,
- boolean));
-
-boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
- struct bfd_link_info *));
-boolean _bfd_elf_create_got_section PARAMS ((bfd *,
- struct bfd_link_info *));
-
-elf_linker_section_t *_bfd_elf_create_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- enum elf_linker_section_enum,
- elf_linker_section_t *defaults));
-
-elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
- PARAMS ((elf_linker_section_pointers_t *linker_pointers,
- bfd_signed_vma addend,
- elf_linker_section_enum_t which));
-
-boolean bfd_elf32_create_pointer_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- const Elf32_Internal_Rela *rel));
-
-bfd_vma bfd_elf32_finish_pointer_linker_section
- PARAMS ((bfd *output_abfd,
- bfd *input_bfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- bfd_vma relocation,
- const Elf32_Internal_Rela *rel,
- int relative_reloc));
-
-boolean bfd_elf64_create_pointer_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- const Elf64_Internal_Rela *rel));
-
-bfd_vma bfd_elf64_finish_pointer_linker_section
- PARAMS ((bfd *output_abfd,
- bfd *input_bfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- bfd_vma relocation,
- const Elf64_Internal_Rela *rel,
- int relative_reloc));
-
-boolean _bfd_elf_make_linker_section_rela
- PARAMS ((bfd *dynobj,
- elf_linker_section_t *lsect,
- int alignment));
-
-extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
-extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
-extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
-extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
-extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
- bfd *));
-
-extern boolean bfd_elf32_bfd_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_elf32_bfd_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-extern void bfd_elf32_swap_symbol_in
- PARAMS ((bfd *, Elf32_External_Sym *, Elf_Internal_Sym *));
-extern void bfd_elf32_swap_symbol_out
- PARAMS ((bfd *, Elf_Internal_Sym *, PTR));
-extern void bfd_elf32_swap_reloc_in
- PARAMS ((bfd *, Elf32_External_Rel *, Elf_Internal_Rel *));
-extern void bfd_elf32_swap_reloc_out
- PARAMS ((bfd *, Elf_Internal_Rel *, Elf32_External_Rel *));
-extern void bfd_elf32_swap_reloca_in
- PARAMS ((bfd *, Elf32_External_Rela *, Elf_Internal_Rela *));
-extern void bfd_elf32_swap_reloca_out
- PARAMS ((bfd *, Elf_Internal_Rela *, Elf32_External_Rela *));
-extern void bfd_elf32_swap_phdr_in
- PARAMS ((bfd *, Elf32_External_Phdr *, Elf_Internal_Phdr *));
-extern void bfd_elf32_swap_phdr_out
- PARAMS ((bfd *, Elf_Internal_Phdr *, Elf32_External_Phdr *));
-extern void bfd_elf32_swap_dyn_in
- PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
-extern void bfd_elf32_swap_dyn_out
- PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf32_External_Dyn *));
-extern boolean bfd_elf32_add_dynamic_entry
- PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
-extern boolean bfd_elf32_link_create_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-
-extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
-extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
-extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
-extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
-extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
- bfd *));
-extern boolean bfd_elf64_bfd_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_elf64_bfd_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-extern void bfd_elf64_swap_symbol_in
- PARAMS ((bfd *, Elf64_External_Sym *, Elf_Internal_Sym *));
-extern void bfd_elf64_swap_symbol_out
- PARAMS ((bfd *, Elf_Internal_Sym *, PTR));
-extern void bfd_elf64_swap_reloc_in
- PARAMS ((bfd *, Elf64_External_Rel *, Elf_Internal_Rel *));
-extern void bfd_elf64_swap_reloc_out
- PARAMS ((bfd *, Elf_Internal_Rel *, Elf64_External_Rel *));
-extern void bfd_elf64_swap_reloca_in
- PARAMS ((bfd *, Elf64_External_Rela *, Elf_Internal_Rela *));
-extern void bfd_elf64_swap_reloca_out
- PARAMS ((bfd *, Elf_Internal_Rela *, Elf64_External_Rela *));
-extern void bfd_elf64_swap_phdr_in
- PARAMS ((bfd *, Elf64_External_Phdr *, Elf_Internal_Phdr *));
-extern void bfd_elf64_swap_phdr_out
- PARAMS ((bfd *, Elf_Internal_Phdr *, Elf64_External_Phdr *));
-extern void bfd_elf64_swap_dyn_in
- PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
-extern void bfd_elf64_swap_dyn_out
- PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf64_External_Dyn *));
-extern boolean bfd_elf64_add_dynamic_entry
- PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
-extern boolean bfd_elf64_link_create_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-
-#define bfd_elf32_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
-#define bfd_elf64_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
-
-#endif /* _LIBELF_H_ */
diff --git a/contrib/gdb/bfd/elf.c b/contrib/gdb/bfd/elf.c
deleted file mode 100644
index 981d3ee23091..000000000000
--- a/contrib/gdb/bfd/elf.c
+++ /dev/null
@@ -1,3318 +0,0 @@
-/* ELF executable support for BFD.
- 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. */
-
-/*
-
-SECTION
- ELF backends
-
- BFD support for ELF formats is being worked on.
- Currently, the best supported back ends are for sparc and i386
- (running svr4 or Solaris 2).
-
- Documentation of the internals of the support code still needs
- to be written. The code is changing quickly enough that we
- haven't bothered yet.
- */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#define ARCH_SIZE 0
-#include "elf-bfd.h"
-
-static INLINE struct elf_segment_map *make_mapping
- PARAMS ((bfd *, asection **, unsigned int, unsigned int, boolean));
-static int elf_sort_sections PARAMS ((const PTR, const PTR));
-static boolean assign_file_positions_for_segments PARAMS ((bfd *));
-static boolean assign_file_positions_except_relocs PARAMS ((bfd *));
-static boolean prep_headers PARAMS ((bfd *));
-static boolean swap_out_syms PARAMS ((bfd *, struct bfd_strtab_hash **));
-static boolean copy_private_bfd_data PARAMS ((bfd *, bfd *));
-
-/* Standard ELF hash function. Do not change this function; you will
- cause invalid hash tables to be generated. (Well, you would if this
- were being used yet.) */
-unsigned long
-bfd_elf_hash (name)
- CONST unsigned char *name;
-{
- unsigned long h = 0;
- unsigned long g;
- int ch;
-
- while ((ch = *name++) != '\0')
- {
- h = (h << 4) + ch;
- if ((g = (h & 0xf0000000)) != 0)
- {
- h ^= g >> 24;
- h &= ~g;
- }
- }
- return h;
-}
-
-/* Read a specified number of bytes at a specified offset in an ELF
- file, into a newly allocated buffer, and return a pointer to the
- buffer. */
-
-static char *
-elf_read (abfd, offset, size)
- bfd * abfd;
- long offset;
- unsigned int size;
-{
- char *buf;
-
- if ((buf = bfd_alloc (abfd, size)) == NULL)
- return NULL;
- if (bfd_seek (abfd, offset, SEEK_SET) == -1)
- return NULL;
- if (bfd_read ((PTR) buf, size, 1, abfd) != size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_file_truncated);
- return NULL;
- }
- return buf;
-}
-
-boolean
-elf_mkobject (abfd)
- bfd * abfd;
-{
- /* this just does initialization */
- /* coff_mkobject zalloc's space for tdata.coff_obj_data ... */
- elf_tdata (abfd) = (struct elf_obj_tdata *)
- bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
- if (elf_tdata (abfd) == 0)
- return false;
- /* since everything is done at close time, do we need any
- initialization? */
-
- return true;
-}
-
-char *
-bfd_elf_get_str_section (abfd, shindex)
- bfd * abfd;
- unsigned int shindex;
-{
- Elf_Internal_Shdr **i_shdrp;
- char *shstrtab = NULL;
- unsigned int offset;
- unsigned int shstrtabsize;
-
- i_shdrp = elf_elfsections (abfd);
- if (i_shdrp == 0 || i_shdrp[shindex] == 0)
- return 0;
-
- shstrtab = (char *) i_shdrp[shindex]->contents;
- if (shstrtab == NULL)
- {
- /* No cached one, attempt to read, and cache what we read. */
- offset = i_shdrp[shindex]->sh_offset;
- shstrtabsize = i_shdrp[shindex]->sh_size;
- shstrtab = elf_read (abfd, offset, shstrtabsize);
- i_shdrp[shindex]->contents = (PTR) shstrtab;
- }
- return shstrtab;
-}
-
-char *
-bfd_elf_string_from_elf_section (abfd, shindex, strindex)
- bfd * abfd;
- unsigned int shindex;
- unsigned int strindex;
-{
- Elf_Internal_Shdr *hdr;
-
- if (strindex == 0)
- return "";
-
- hdr = elf_elfsections (abfd)[shindex];
-
- if (hdr->contents == NULL
- && bfd_elf_get_str_section (abfd, shindex) == NULL)
- return NULL;
-
- return ((char *) hdr->contents) + strindex;
-}
-
-/* Make a BFD section from an ELF section. We store a pointer to the
- BFD section in the bfd_section field of the header. */
-
-boolean
-_bfd_elf_make_section_from_shdr (abfd, hdr, name)
- bfd *abfd;
- Elf_Internal_Shdr *hdr;
- const char *name;
-{
- asection *newsect;
- flagword flags;
-
- if (hdr->bfd_section != NULL)
- {
- BFD_ASSERT (strcmp (name,
- bfd_get_section_name (abfd, hdr->bfd_section)) == 0);
- return true;
- }
-
- newsect = bfd_make_section_anyway (abfd, name);
- if (newsect == NULL)
- return false;
-
- newsect->filepos = hdr->sh_offset;
-
- if (! bfd_set_section_vma (abfd, newsect, hdr->sh_addr)
- || ! bfd_set_section_size (abfd, newsect, hdr->sh_size)
- || ! bfd_set_section_alignment (abfd, newsect,
- bfd_log2 (hdr->sh_addralign)))
- return false;
-
- flags = SEC_NO_FLAGS;
- if (hdr->sh_type != SHT_NOBITS)
- flags |= SEC_HAS_CONTENTS;
- if ((hdr->sh_flags & SHF_ALLOC) != 0)
- {
- flags |= SEC_ALLOC;
- if (hdr->sh_type != SHT_NOBITS)
- flags |= SEC_LOAD;
- }
- if ((hdr->sh_flags & SHF_WRITE) == 0)
- flags |= SEC_READONLY;
- if ((hdr->sh_flags & SHF_EXECINSTR) != 0)
- flags |= SEC_CODE;
- else if ((flags & SEC_LOAD) != 0)
- flags |= SEC_DATA;
-
- /* The debugging sections appear to be recognized only by name, not
- any sort of flag. */
- if (strncmp (name, ".debug", sizeof ".debug" - 1) == 0
- || strncmp (name, ".line", sizeof ".line" - 1) == 0
- || strncmp (name, ".stab", sizeof ".stab" - 1) == 0)
- flags |= SEC_DEBUGGING;
-
- if (! bfd_set_section_flags (abfd, newsect, flags))
- return false;
-
- if ((flags & SEC_ALLOC) != 0)
- {
- Elf_Internal_Phdr *phdr;
- unsigned int i;
-
- /* Look through the phdrs to see if we need to adjust the lma. */
- phdr = elf_tdata (abfd)->phdr;
- for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
- {
- if (phdr->p_type == PT_LOAD
- && phdr->p_paddr != 0
- && phdr->p_vaddr != phdr->p_paddr
- && phdr->p_vaddr <= hdr->sh_addr
- && phdr->p_vaddr + phdr->p_memsz >= hdr->sh_addr + hdr->sh_size)
- {
- newsect->lma += phdr->p_paddr - phdr->p_vaddr;
- break;
- }
- }
- }
-
- hdr->bfd_section = newsect;
- elf_section_data (newsect)->this_hdr = *hdr;
-
- return true;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_elf_find_section
-
-SYNOPSIS
- struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
-
-DESCRIPTION
- Helper functions for GDB to locate the string tables.
- Since BFD hides string tables from callers, GDB needs to use an
- internal hook to find them. Sun's .stabstr, in particular,
- isn't even pointed to by the .stab section, so ordinary
- mechanisms wouldn't work to find it, even if we had some.
-*/
-
-struct elf_internal_shdr *
-bfd_elf_find_section (abfd, name)
- bfd * abfd;
- char *name;
-{
- Elf_Internal_Shdr **i_shdrp;
- char *shstrtab;
- unsigned int max;
- unsigned int i;
-
- i_shdrp = elf_elfsections (abfd);
- if (i_shdrp != NULL)
- {
- shstrtab = bfd_elf_get_str_section (abfd, elf_elfheader (abfd)->e_shstrndx);
- if (shstrtab != NULL)
- {
- max = elf_elfheader (abfd)->e_shnum;
- for (i = 1; i < max; i++)
- if (!strcmp (&shstrtab[i_shdrp[i]->sh_name], name))
- return i_shdrp[i];
- }
- }
- return 0;
-}
-
-const char *const bfd_elf_section_type_names[] = {
- "SHT_NULL", "SHT_PROGBITS", "SHT_SYMTAB", "SHT_STRTAB",
- "SHT_RELA", "SHT_HASH", "SHT_DYNAMIC", "SHT_NOTE",
- "SHT_NOBITS", "SHT_REL", "SHT_SHLIB", "SHT_DYNSYM",
-};
-
-/* ELF relocs are against symbols. 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. */
-
-/*ARGSUSED*/
-bfd_reloc_status_type
-bfd_elf_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->howto->partial_inplace
- || reloc_entry->addend == 0))
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- return bfd_reloc_continue;
-}
-
-/* Print out the program headers. */
-
-boolean
-_bfd_elf_print_private_bfd_data (abfd, farg)
- bfd *abfd;
- PTR farg;
-{
- FILE *f = (FILE *) farg;
- Elf_Internal_Phdr *p;
- asection *s;
- bfd_byte *dynbuf = NULL;
-
- p = elf_tdata (abfd)->phdr;
- if (p != NULL)
- {
- unsigned int i, c;
-
- fprintf (f, "\nProgram Header:\n");
- c = elf_elfheader (abfd)->e_phnum;
- for (i = 0; i < c; i++, p++)
- {
- const char *s;
- char buf[20];
-
- switch (p->p_type)
- {
- case PT_NULL: s = "NULL"; break;
- case PT_LOAD: s = "LOAD"; break;
- case PT_DYNAMIC: s = "DYNAMIC"; break;
- case PT_INTERP: s = "INTERP"; break;
- case PT_NOTE: s = "NOTE"; break;
- case PT_SHLIB: s = "SHLIB"; break;
- case PT_PHDR: s = "PHDR"; break;
- default: sprintf (buf, "0x%lx", p->p_type); s = buf; break;
- }
- fprintf (f, "%8s off 0x", s);
- fprintf_vma (f, p->p_offset);
- fprintf (f, " vaddr 0x");
- fprintf_vma (f, p->p_vaddr);
- fprintf (f, " paddr 0x");
- fprintf_vma (f, p->p_paddr);
- fprintf (f, " align 2**%u\n", bfd_log2 (p->p_align));
- fprintf (f, " filesz 0x");
- fprintf_vma (f, p->p_filesz);
- fprintf (f, " memsz 0x");
- fprintf_vma (f, p->p_memsz);
- fprintf (f, " flags %c%c%c",
- (p->p_flags & PF_R) != 0 ? 'r' : '-',
- (p->p_flags & PF_W) != 0 ? 'w' : '-',
- (p->p_flags & PF_X) != 0 ? 'x' : '-');
- if ((p->p_flags &~ (PF_R | PF_W | PF_X)) != 0)
- fprintf (f, " %lx", p->p_flags &~ (PF_R | PF_W | PF_X));
- fprintf (f, "\n");
- }
- }
-
- s = bfd_get_section_by_name (abfd, ".dynamic");
- if (s != NULL)
- {
- int elfsec;
- unsigned long link;
- bfd_byte *extdyn, *extdynend;
- size_t extdynsize;
- void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
-
- fprintf (f, "\nDynamic Section:\n");
-
- dynbuf = (bfd_byte *) bfd_malloc (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;
-
- extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
- swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
-
- extdyn = dynbuf;
- extdynend = extdyn + s->_raw_size;
- for (; extdyn < extdynend; extdyn += extdynsize)
- {
- Elf_Internal_Dyn dyn;
- const char *name;
- char ab[20];
- boolean stringp;
-
- (*swap_dyn_in) (abfd, (PTR) extdyn, &dyn);
-
- if (dyn.d_tag == DT_NULL)
- break;
-
- stringp = false;
- switch (dyn.d_tag)
- {
- default:
- sprintf (ab, "0x%lx", (unsigned long) dyn.d_tag);
- name = ab;
- break;
-
- case DT_NEEDED: name = "NEEDED"; stringp = true; break;
- case DT_PLTRELSZ: name = "PLTRELSZ"; break;
- case DT_PLTGOT: name = "PLTGOT"; break;
- case DT_HASH: name = "HASH"; break;
- case DT_STRTAB: name = "STRTAB"; break;
- case DT_SYMTAB: name = "SYMTAB"; break;
- case DT_RELA: name = "RELA"; break;
- case DT_RELASZ: name = "RELASZ"; break;
- case DT_RELAENT: name = "RELAENT"; break;
- case DT_STRSZ: name = "STRSZ"; break;
- case DT_SYMENT: name = "SYMENT"; break;
- case DT_INIT: name = "INIT"; break;
- case DT_FINI: name = "FINI"; break;
- case DT_SONAME: name = "SONAME"; stringp = true; break;
- case DT_RPATH: name = "RPATH"; stringp = true; break;
- case DT_SYMBOLIC: name = "SYMBOLIC"; break;
- case DT_REL: name = "REL"; break;
- case DT_RELSZ: name = "RELSZ"; break;
- case DT_RELENT: name = "RELENT"; break;
- case DT_PLTREL: name = "PLTREL"; break;
- case DT_DEBUG: name = "DEBUG"; break;
- case DT_TEXTREL: name = "TEXTREL"; break;
- case DT_JMPREL: name = "JMPREL"; break;
- }
-
- fprintf (f, " %-11s ", name);
- if (! stringp)
- fprintf (f, "0x%lx", (unsigned long) dyn.d_un.d_val);
- else
- {
- const char *string;
-
- string = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
- if (string == NULL)
- goto error_return;
- fprintf (f, "%s", string);
- }
- fprintf (f, "\n");
- }
-
- free (dynbuf);
- dynbuf = NULL;
- }
-
- return true;
-
- error_return:
- if (dynbuf != NULL)
- free (dynbuf);
- return false;
-}
-
-/* Display ELF-specific fields of a symbol. */
-void
-bfd_elf_print_symbol (ignore_abfd, filep, symbol, how)
- bfd *ignore_abfd;
- PTR filep;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) filep;
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
- case bfd_print_symbol_more:
- fprintf (file, "elf ");
- 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", section_name);
- /* Print the "other" value for a symbol. For common symbols,
- we've already printed the size; now print the alignment.
- For other symbols, we have no specified alignment, and
- we've printed the address; now print the size. */
- fprintf_vma (file,
- (bfd_is_com_section (symbol->section)
- ? ((elf_symbol_type *) symbol)->internal_elf_sym.st_value
- : ((elf_symbol_type *) symbol)->internal_elf_sym.st_size));
- fprintf (file, " %s", symbol->name);
- }
- break;
- }
-}
-
-/* Create an entry in an ELF linker hash table. */
-
-struct bfd_hash_entry *
-_bfd_elf_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct elf_link_hash_entry *ret = (struct elf_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct elf_link_hash_entry *) NULL)
- ret = ((struct elf_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct elf_link_hash_entry)));
- if (ret == (struct elf_link_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct elf_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != (struct elf_link_hash_entry *) NULL)
- {
- /* Set local fields. */
- ret->indx = -1;
- ret->size = 0;
- ret->dynindx = -1;
- ret->dynstr_index = 0;
- ret->weakdef = NULL;
- ret->got_offset = (bfd_vma) -1;
- ret->plt_offset = (bfd_vma) -1;
- ret->linker_section_pointer = (elf_linker_section_pointers_t *)0;
- ret->type = STT_NOTYPE;
- /* Assume that we have been called by a non-ELF symbol reader.
- This flag is then reset by the code which reads an ELF input
- file. This ensures that a symbol created by a non-ELF symbol
- reader will have the flag set correctly. */
- ret->elf_link_hash_flags = ELF_LINK_NON_ELF;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize an ELF linker hash table. */
-
-boolean
-_bfd_elf_link_hash_table_init (table, abfd, newfunc)
- struct elf_link_hash_table *table;
- bfd *abfd;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- table->dynamic_sections_created = false;
- table->dynobj = NULL;
- /* The first dynamic symbol is a dummy. */
- table->dynsymcount = 1;
- table->dynstr = NULL;
- table->bucketcount = 0;
- table->needed = NULL;
- return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
-}
-
-/* Create an ELF linker hash table. */
-
-struct bfd_link_hash_table *
-_bfd_elf_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct elf_link_hash_table *ret;
-
- ret = ((struct elf_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_link_hash_table)));
- if (ret == (struct elf_link_hash_table *) NULL)
- return NULL;
-
- if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc))
- {
- bfd_release (abfd, ret);
- return NULL;
- }
-
- return &ret->root;
-}
-
-/* This is a hook for the ELF emulation code in the generic linker to
- tell the backend linker what file name to use for the DT_NEEDED
- entry for a dynamic object. The generic linker passes name as an
- empty string to indicate that no DT_NEEDED entry should be made. */
-
-void
-bfd_elf_set_dt_needed_name (abfd, name)
- bfd *abfd;
- const char *name;
-{
- if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
- && bfd_get_format (abfd) == bfd_object)
- elf_dt_name (abfd) = name;
-}
-
-/* Get the list of DT_NEEDED entries for a link. This is a hook for
- the ELF emulation code. */
-
-struct bfd_link_needed_list *
-bfd_elf_get_needed_list (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- if (info->hash->creator->flavour != bfd_target_elf_flavour)
- return NULL;
- return elf_hash_table (info)->needed;
-}
-
-/* Get the name actually used for a dynamic object for a link. This
- is the SONAME entry if there is one. Otherwise, it is the string
- passed to bfd_elf_set_dt_needed_name, or it is the filename. */
-
-const char *
-bfd_elf_get_dt_soname (abfd)
- bfd *abfd;
-{
- if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
- && bfd_get_format (abfd) == bfd_object)
- return elf_dt_name (abfd);
- return NULL;
-}
-
-/* Allocate an ELF string table--force the first byte to be zero. */
-
-struct bfd_strtab_hash *
-_bfd_elf_stringtab_init ()
-{
- struct bfd_strtab_hash *ret;
-
- ret = _bfd_stringtab_init ();
- if (ret != NULL)
- {
- bfd_size_type loc;
-
- loc = _bfd_stringtab_add (ret, "", true, false);
- BFD_ASSERT (loc == 0 || loc == (bfd_size_type) -1);
- if (loc == (bfd_size_type) -1)
- {
- _bfd_stringtab_free (ret);
- ret = NULL;
- }
- }
- return ret;
-}
-
-/* ELF .o/exec file reading */
-
-/* Create a new bfd section from an ELF section header. */
-
-boolean
-bfd_section_from_shdr (abfd, shindex)
- bfd *abfd;
- unsigned int shindex;
-{
- Elf_Internal_Shdr *hdr = elf_elfsections (abfd)[shindex];
- Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd);
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- char *name;
-
- name = elf_string_from_elf_strtab (abfd, hdr->sh_name);
-
- switch (hdr->sh_type)
- {
- case SHT_NULL:
- /* Inactive section. Throw it away. */
- return true;
-
- case SHT_PROGBITS: /* Normal section with contents. */
- case SHT_DYNAMIC: /* Dynamic linking information. */
- case SHT_NOBITS: /* .bss section. */
- case SHT_HASH: /* .hash section. */
- case SHT_NOTE: /* .note section. */
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
-
- case SHT_SYMTAB: /* A symbol table */
- if (elf_onesymtab (abfd) == shindex)
- return true;
-
- BFD_ASSERT (hdr->sh_entsize == bed->s->sizeof_sym);
- BFD_ASSERT (elf_onesymtab (abfd) == 0);
- elf_onesymtab (abfd) = shindex;
- elf_tdata (abfd)->symtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->symtab_hdr;
- abfd->flags |= HAS_SYMS;
-
- /* Sometimes a shared object will map in the symbol table. If
- SHF_ALLOC is set, and this is a shared object, then we also
- treat this section as a BFD section. We can not base the
- decision purely on SHF_ALLOC, because that flag is sometimes
- set in a relocateable object file, which would confuse the
- linker. */
- if ((hdr->sh_flags & SHF_ALLOC) != 0
- && (abfd->flags & DYNAMIC) != 0
- && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
- return false;
-
- return true;
-
- case SHT_DYNSYM: /* A dynamic symbol table */
- if (elf_dynsymtab (abfd) == shindex)
- return true;
-
- BFD_ASSERT (hdr->sh_entsize == bed->s->sizeof_sym);
- BFD_ASSERT (elf_dynsymtab (abfd) == 0);
- elf_dynsymtab (abfd) = shindex;
- elf_tdata (abfd)->dynsymtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->dynsymtab_hdr;
- abfd->flags |= HAS_SYMS;
-
- /* Besides being a symbol table, we also treat this as a regular
- section, so that objcopy can handle it. */
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
-
- case SHT_STRTAB: /* A string table */
- if (hdr->bfd_section != NULL)
- return true;
- if (ehdr->e_shstrndx == shindex)
- {
- elf_tdata (abfd)->shstrtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr;
- return true;
- }
- {
- unsigned int i;
-
- for (i = 1; i < ehdr->e_shnum; i++)
- {
- Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
- if (hdr2->sh_link == shindex)
- {
- if (! bfd_section_from_shdr (abfd, i))
- return false;
- if (elf_onesymtab (abfd) == i)
- {
- elf_tdata (abfd)->strtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] =
- &elf_tdata (abfd)->strtab_hdr;
- return true;
- }
- if (elf_dynsymtab (abfd) == i)
- {
- elf_tdata (abfd)->dynstrtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] = hdr =
- &elf_tdata (abfd)->dynstrtab_hdr;
- /* We also treat this as a regular section, so
- that objcopy can handle it. */
- break;
- }
-#if 0 /* Not handling other string tables specially right now. */
- hdr2 = elf_elfsections (abfd)[i]; /* in case it moved */
- /* We have a strtab for some random other section. */
- newsect = (asection *) hdr2->bfd_section;
- if (!newsect)
- break;
- hdr->bfd_section = newsect;
- hdr2 = &elf_section_data (newsect)->str_hdr;
- *hdr2 = *hdr;
- elf_elfsections (abfd)[shindex] = hdr2;
-#endif
- }
- }
- }
-
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
-
- case SHT_REL:
- case SHT_RELA:
- /* *These* do a lot of work -- but build no sections! */
- {
- asection *target_sect;
- Elf_Internal_Shdr *hdr2;
- int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
-
- /* For some incomprehensible reason Oracle distributes
- libraries for Solaris in which some of the objects have
- bogus sh_link fields. It would be nice if we could just
- reject them, but, unfortunately, some people need to use
- them. We scan through the section headers; if we find only
- one suitable symbol table, we clobber the sh_link to point
- to it. I hope this doesn't break anything. */
- if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_SYMTAB
- && elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_DYNSYM)
- {
- int scan;
- int found;
-
- found = 0;
- for (scan = 1; scan < ehdr->e_shnum; scan++)
- {
- if (elf_elfsections (abfd)[scan]->sh_type == SHT_SYMTAB
- || elf_elfsections (abfd)[scan]->sh_type == SHT_DYNSYM)
- {
- if (found != 0)
- {
- found = 0;
- break;
- }
- found = scan;
- }
- }
- if (found != 0)
- hdr->sh_link = found;
- }
-
- /* Get the symbol table. */
- if (elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
- && ! bfd_section_from_shdr (abfd, hdr->sh_link))
- return false;
-
- /* If this reloc section does not use the main symbol table we
- don't treat it as a reloc section. BFD can't adequately
- represent such a section, so at least for now, we don't
- try. We just present it as a normal section. */
- if (hdr->sh_link != elf_onesymtab (abfd))
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
-
- /* Don't allow REL relocations on a machine that uses RELA and
- vice versa. */
- /* @@ Actually, the generic ABI does suggest that both might be
- used in one file. But the four ABI Processor Supplements I
- have access to right now all specify that only one is used on
- each of those architectures. It's conceivable that, e.g., a
- bunch of absolute 32-bit relocs might be more compact in REL
- form even on a RELA machine... */
- BFD_ASSERT (use_rela_p
- ? (hdr->sh_type == SHT_RELA
- && hdr->sh_entsize == bed->s->sizeof_rela)
- : (hdr->sh_type == SHT_REL
- && hdr->sh_entsize == bed->s->sizeof_rel));
-
- if (! bfd_section_from_shdr (abfd, hdr->sh_info))
- return false;
- target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info);
- if (target_sect == NULL)
- return false;
-
- hdr2 = &elf_section_data (target_sect)->rel_hdr;
- *hdr2 = *hdr;
- elf_elfsections (abfd)[shindex] = hdr2;
- target_sect->reloc_count = hdr->sh_size / hdr->sh_entsize;
- target_sect->flags |= SEC_RELOC;
- target_sect->relocation = NULL;
- target_sect->rel_filepos = hdr->sh_offset;
- abfd->flags |= HAS_RELOC;
- return true;
- }
- break;
-
- case SHT_SHLIB:
- return true;
-
- default:
- /* Check for any processor-specific section types. */
- {
- if (bed->elf_backend_section_from_shdr)
- (*bed->elf_backend_section_from_shdr) (abfd, hdr, name);
- }
- break;
- }
-
- return true;
-}
-
-/* Given an ELF section number, retrieve the corresponding BFD
- section. */
-
-asection *
-bfd_section_from_elf_index (abfd, index)
- bfd *abfd;
- unsigned int index;
-{
- BFD_ASSERT (index > 0 && index < SHN_LORESERVE);
- if (index >= elf_elfheader (abfd)->e_shnum)
- return NULL;
- return elf_elfsections (abfd)[index]->bfd_section;
-}
-
-boolean
-_bfd_elf_new_section_hook (abfd, sec)
- bfd *abfd;
- asection *sec;
-{
- struct bfd_elf_section_data *sdata;
-
- sdata = (struct bfd_elf_section_data *) bfd_alloc (abfd, sizeof (*sdata));
- if (!sdata)
- return false;
- sec->used_by_bfd = (PTR) sdata;
- memset (sdata, 0, sizeof (*sdata));
- return true;
-}
-
-/* Create a new bfd section from an ELF program header.
-
- Since program segments have no names, we generate a synthetic name
- of the form segment<NUM>, where NUM is generally the index in the
- program header table. For segments that are split (see below) we
- generate the names segment<NUM>a and segment<NUM>b.
-
- Note that some program segments may have a file size that is different than
- (less than) the memory size. All this means is that at execution the
- system must allocate the amount of memory specified by the memory size,
- but only initialize it with the first "file size" bytes read from the
- file. This would occur for example, with program segments consisting
- of combined data+bss.
-
- To handle the above situation, this routine generates TWO bfd sections
- for the single program segment. The first has the length specified by
- the file size of the segment, and the second has the length specified
- by the difference between the two sizes. In effect, the segment is split
- into it's initialized and uninitialized parts.
-
- */
-
-boolean
-bfd_section_from_phdr (abfd, hdr, index)
- bfd *abfd;
- Elf_Internal_Phdr *hdr;
- int index;
-{
- asection *newsect;
- char *name;
- char namebuf[64];
- int split;
-
- split = ((hdr->p_memsz > 0) &&
- (hdr->p_filesz > 0) &&
- (hdr->p_memsz > hdr->p_filesz));
- sprintf (namebuf, split ? "segment%da" : "segment%d", index);
- name = bfd_alloc (abfd, strlen (namebuf) + 1);
- if (!name)
- return false;
- strcpy (name, namebuf);
- newsect = bfd_make_section (abfd, name);
- if (newsect == NULL)
- return false;
- newsect->vma = hdr->p_vaddr;
- newsect->lma = hdr->p_paddr;
- newsect->_raw_size = hdr->p_filesz;
- newsect->filepos = hdr->p_offset;
- newsect->flags |= SEC_HAS_CONTENTS;
- if (hdr->p_type == PT_LOAD)
- {
- newsect->flags |= SEC_ALLOC;
- newsect->flags |= SEC_LOAD;
- if (hdr->p_flags & PF_X)
- {
- /* FIXME: all we known is that it has execute PERMISSION,
- may be data. */
- newsect->flags |= SEC_CODE;
- }
- }
- if (!(hdr->p_flags & PF_W))
- {
- newsect->flags |= SEC_READONLY;
- }
-
- if (split)
- {
- sprintf (namebuf, "segment%db", index);
- name = bfd_alloc (abfd, strlen (namebuf) + 1);
- if (!name)
- return false;
- strcpy (name, namebuf);
- newsect = bfd_make_section (abfd, name);
- if (newsect == NULL)
- return false;
- newsect->vma = hdr->p_vaddr + hdr->p_filesz;
- newsect->lma = hdr->p_paddr + hdr->p_filesz;
- newsect->_raw_size = hdr->p_memsz - hdr->p_filesz;
- if (hdr->p_type == PT_LOAD)
- {
- newsect->flags |= SEC_ALLOC;
- if (hdr->p_flags & PF_X)
- newsect->flags |= SEC_CODE;
- }
- if (!(hdr->p_flags & PF_W))
- newsect->flags |= SEC_READONLY;
- }
-
- return true;
-}
-
-/* Set up an ELF internal section header for a section. */
-
-/*ARGSUSED*/
-static void
-elf_fake_sections (abfd, asect, failedptrarg)
- bfd *abfd;
- asection *asect;
- PTR failedptrarg;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- boolean *failedptr = (boolean *) failedptrarg;
- Elf_Internal_Shdr *this_hdr;
-
- if (*failedptr)
- {
- /* We already failed; just get out of the bfd_map_over_sections
- loop. */
- return;
- }
-
- this_hdr = &elf_section_data (asect)->this_hdr;
-
- this_hdr->sh_name = (unsigned long) _bfd_stringtab_add (elf_shstrtab (abfd),
- asect->name,
- true, false);
- if (this_hdr->sh_name == (unsigned long) -1)
- {
- *failedptr = true;
- return;
- }
-
- this_hdr->sh_flags = 0;
-
- if ((asect->flags & SEC_ALLOC) != 0)
- this_hdr->sh_addr = asect->vma;
- else
- this_hdr->sh_addr = 0;
-
- this_hdr->sh_offset = 0;
- this_hdr->sh_size = asect->_raw_size;
- this_hdr->sh_link = 0;
- this_hdr->sh_addralign = 1 << asect->alignment_power;
- /* The sh_entsize and sh_info fields may have been set already by
- copy_private_section_data. */
-
- this_hdr->bfd_section = asect;
- this_hdr->contents = NULL;
-
- /* FIXME: This should not be based on section names. */
- if (strcmp (asect->name, ".dynstr") == 0)
- this_hdr->sh_type = SHT_STRTAB;
- else if (strcmp (asect->name, ".hash") == 0)
- {
- this_hdr->sh_type = SHT_HASH;
- this_hdr->sh_entsize = bed->s->arch_size / 8;
- }
- else if (strcmp (asect->name, ".dynsym") == 0)
- {
- this_hdr->sh_type = SHT_DYNSYM;
- this_hdr->sh_entsize = bed->s->sizeof_sym;
- }
- else if (strcmp (asect->name, ".dynamic") == 0)
- {
- this_hdr->sh_type = SHT_DYNAMIC;
- this_hdr->sh_entsize = bed->s->sizeof_dyn;
- }
- else if (strncmp (asect->name, ".rela", 5) == 0
- && get_elf_backend_data (abfd)->use_rela_p)
- {
- this_hdr->sh_type = SHT_RELA;
- this_hdr->sh_entsize = bed->s->sizeof_rela;
- }
- else if (strncmp (asect->name, ".rel", 4) == 0
- && ! get_elf_backend_data (abfd)->use_rela_p)
- {
- this_hdr->sh_type = SHT_REL;
- this_hdr->sh_entsize = bed->s->sizeof_rel;
- }
- else if (strcmp (asect->name, ".note") == 0)
- this_hdr->sh_type = SHT_NOTE;
- else if (strncmp (asect->name, ".stab", 5) == 0
- && strcmp (asect->name + strlen (asect->name) - 3, "str") == 0)
- this_hdr->sh_type = SHT_STRTAB;
- else if ((asect->flags & SEC_ALLOC) != 0
- && (asect->flags & SEC_LOAD) != 0)
- this_hdr->sh_type = SHT_PROGBITS;
- else if ((asect->flags & SEC_ALLOC) != 0
- && ((asect->flags & SEC_LOAD) == 0))
- this_hdr->sh_type = SHT_NOBITS;
- else
- {
- /* Who knows? */
- this_hdr->sh_type = SHT_PROGBITS;
- }
-
- if ((asect->flags & SEC_ALLOC) != 0)
- this_hdr->sh_flags |= SHF_ALLOC;
- if ((asect->flags & SEC_READONLY) == 0)
- this_hdr->sh_flags |= SHF_WRITE;
- if ((asect->flags & SEC_CODE) != 0)
- this_hdr->sh_flags |= SHF_EXECINSTR;
-
- /* Check for processor-specific section types. */
- {
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- if (bed->elf_backend_fake_sections)
- (*bed->elf_backend_fake_sections) (abfd, this_hdr, asect);
- }
-
- /* If the section has relocs, set up a section header for the
- SHT_REL[A] section. */
- if ((asect->flags & SEC_RELOC) != 0)
- {
- Elf_Internal_Shdr *rela_hdr;
- int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
- char *name;
-
- rela_hdr = &elf_section_data (asect)->rel_hdr;
- name = bfd_alloc (abfd, sizeof ".rela" + strlen (asect->name));
- if (name == NULL)
- {
- *failedptr = true;
- return;
- }
- sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name);
- rela_hdr->sh_name =
- (unsigned int) _bfd_stringtab_add (elf_shstrtab (abfd), name,
- true, false);
- if (rela_hdr->sh_name == (unsigned int) -1)
- {
- *failedptr = true;
- return;
- }
- rela_hdr->sh_type = use_rela_p ? SHT_RELA : SHT_REL;
- rela_hdr->sh_entsize = (use_rela_p
- ? bed->s->sizeof_rela
- : bed->s->sizeof_rel);
- rela_hdr->sh_addralign = bed->s->file_align;
- rela_hdr->sh_flags = 0;
- rela_hdr->sh_addr = 0;
- rela_hdr->sh_size = 0;
- rela_hdr->sh_offset = 0;
- }
-}
-
-/* Assign all ELF section numbers. The dummy first section is handled here
- too. The link/info pointers for the standard section types are filled
- in here too, while we're at it. */
-
-static boolean
-assign_section_numbers (abfd)
- bfd *abfd;
-{
- struct elf_obj_tdata *t = elf_tdata (abfd);
- asection *sec;
- unsigned int section_number;
- Elf_Internal_Shdr **i_shdrp;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- section_number = 1;
-
- for (sec = abfd->sections; sec; sec = sec->next)
- {
- struct bfd_elf_section_data *d = elf_section_data (sec);
-
- d->this_idx = section_number++;
- if ((sec->flags & SEC_RELOC) == 0)
- d->rel_idx = 0;
- else
- d->rel_idx = section_number++;
- }
-
- t->shstrtab_section = section_number++;
- elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section;
- t->shstrtab_hdr.sh_size = _bfd_stringtab_size (elf_shstrtab (abfd));
-
- if (abfd->symcount > 0)
- {
- t->symtab_section = section_number++;
- t->strtab_section = section_number++;
- }
-
- elf_elfheader (abfd)->e_shnum = section_number;
-
- /* Set up the list of section header pointers, in agreement with the
- indices. */
- i_shdrp = ((Elf_Internal_Shdr **)
- bfd_alloc (abfd, section_number * sizeof (Elf_Internal_Shdr *)));
- if (i_shdrp == NULL)
- return false;
-
- i_shdrp[0] = ((Elf_Internal_Shdr *)
- bfd_alloc (abfd, sizeof (Elf_Internal_Shdr)));
- if (i_shdrp[0] == NULL)
- {
- bfd_release (abfd, i_shdrp);
- return false;
- }
- memset (i_shdrp[0], 0, sizeof (Elf_Internal_Shdr));
-
- elf_elfsections (abfd) = i_shdrp;
-
- i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr;
- if (abfd->symcount > 0)
- {
- i_shdrp[t->symtab_section] = &t->symtab_hdr;
- i_shdrp[t->strtab_section] = &t->strtab_hdr;
- t->symtab_hdr.sh_link = t->strtab_section;
- }
- for (sec = abfd->sections; sec; sec = sec->next)
- {
- struct bfd_elf_section_data *d = elf_section_data (sec);
- asection *s;
- const char *name;
-
- i_shdrp[d->this_idx] = &d->this_hdr;
- if (d->rel_idx != 0)
- i_shdrp[d->rel_idx] = &d->rel_hdr;
-
- /* Fill in the sh_link and sh_info fields while we're at it. */
-
- /* sh_link of a reloc section is the section index of the symbol
- table. sh_info is the section index of the section to which
- the relocation entries apply. */
- if (d->rel_idx != 0)
- {
- d->rel_hdr.sh_link = t->symtab_section;
- d->rel_hdr.sh_info = d->this_idx;
- }
-
- switch (d->this_hdr.sh_type)
- {
- case SHT_REL:
- case SHT_RELA:
- /* A reloc section which we are treating as a normal BFD
- section. sh_link is the section index of the symbol
- table. sh_info is the section index of the section to
- which the relocation entries apply. We assume that an
- allocated reloc section uses the dynamic symbol table.
- FIXME: How can we be sure? */
- s = bfd_get_section_by_name (abfd, ".dynsym");
- if (s != NULL)
- d->this_hdr.sh_link = elf_section_data (s)->this_idx;
-
- /* We look up the section the relocs apply to by name. */
- name = sec->name;
- if (d->this_hdr.sh_type == SHT_REL)
- name += 4;
- else
- name += 5;
- s = bfd_get_section_by_name (abfd, name);
- if (s != NULL)
- d->this_hdr.sh_info = elf_section_data (s)->this_idx;
- break;
-
- case SHT_STRTAB:
- /* We assume that a section named .stab*str is a stabs
- string section. We look for a section with the same name
- but without the trailing ``str'', and set its sh_link
- field to point to this section. */
- if (strncmp (sec->name, ".stab", sizeof ".stab" - 1) == 0
- && strcmp (sec->name + strlen (sec->name) - 3, "str") == 0)
- {
- size_t len;
- char *alc;
-
- len = strlen (sec->name);
- alc = (char *) bfd_malloc (len - 2);
- if (alc == NULL)
- return false;
- strncpy (alc, sec->name, len - 3);
- alc[len - 3] = '\0';
- s = bfd_get_section_by_name (abfd, alc);
- free (alc);
- if (s != NULL)
- {
- elf_section_data (s)->this_hdr.sh_link = d->this_idx;
-
- /* This is a .stab section. */
- elf_section_data (s)->this_hdr.sh_entsize =
- 4 + 2 * (bed->s->arch_size / 8);
- }
- }
- break;
-
- case SHT_DYNAMIC:
- case SHT_DYNSYM:
- /* sh_link is the section header index of the string table
- used for the dynamic entries or symbol table. */
- s = bfd_get_section_by_name (abfd, ".dynstr");
- if (s != NULL)
- d->this_hdr.sh_link = elf_section_data (s)->this_idx;
- break;
-
- case SHT_HASH:
- /* sh_link is the section header index of the symbol table
- this hash table is for. */
- s = bfd_get_section_by_name (abfd, ".dynsym");
- if (s != NULL)
- d->this_hdr.sh_link = elf_section_data (s)->this_idx;
- break;
- }
- }
-
- return true;
-}
-
-/* Map symbol from it's internal number to the external number, moving
- all local symbols to be at the head of the list. */
-
-static INLINE int
-sym_is_global (abfd, sym)
- bfd *abfd;
- asymbol *sym;
-{
- /* If the backend has a special mapping, use it. */
- if (get_elf_backend_data (abfd)->elf_backend_sym_is_global)
- return ((*get_elf_backend_data (abfd)->elf_backend_sym_is_global)
- (abfd, sym));
-
- return ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
- || bfd_is_und_section (bfd_get_section (sym))
- || bfd_is_com_section (bfd_get_section (sym)));
-}
-
-static boolean
-elf_map_symbols (abfd)
- bfd *abfd;
-{
- int symcount = bfd_get_symcount (abfd);
- asymbol **syms = bfd_get_outsymbols (abfd);
- asymbol **sect_syms;
- int num_locals = 0;
- int num_globals = 0;
- int num_locals2 = 0;
- int num_globals2 = 0;
- int max_index = 0;
- int num_sections = 0;
- int idx;
- asection *asect;
- asymbol **new_syms;
-
-#ifdef DEBUG
- fprintf (stderr, "elf_map_symbols\n");
- fflush (stderr);
-#endif
-
- /* Add a section symbol for each BFD section. FIXME: Is this really
- necessary? */
- for (asect = abfd->sections; asect; asect = asect->next)
- {
- if (max_index < asect->index)
- max_index = asect->index;
- }
-
- max_index++;
- sect_syms = (asymbol **) bfd_zalloc (abfd, max_index * sizeof (asymbol *));
- if (sect_syms == NULL)
- return false;
- elf_section_syms (abfd) = sect_syms;
-
- for (idx = 0; idx < symcount; idx++)
- {
- if ((syms[idx]->flags & BSF_SECTION_SYM) != 0
- && (syms[idx]->value + syms[idx]->section->vma) == 0)
- {
- asection *sec;
-
- sec = syms[idx]->section;
- if (sec->owner != NULL)
- {
- if (sec->owner != abfd)
- {
- if (sec->output_offset != 0)
- continue;
- sec = sec->output_section;
- BFD_ASSERT (sec->owner == abfd);
- }
- sect_syms[sec->index] = syms[idx];
- }
- }
- }
-
- for (asect = abfd->sections; asect; asect = asect->next)
- {
- asymbol *sym;
-
- if (sect_syms[asect->index] != NULL)
- continue;
-
- sym = bfd_make_empty_symbol (abfd);
- if (sym == NULL)
- return false;
- sym->the_bfd = abfd;
- sym->name = asect->name;
- sym->value = 0;
- /* Set the flags to 0 to indicate that this one was newly added. */
- sym->flags = 0;
- sym->section = asect;
- sect_syms[asect->index] = sym;
- num_sections++;
-#ifdef DEBUG
- fprintf (stderr,
- "creating section symbol, name = %s, value = 0x%.8lx, index = %d, section = 0x%.8lx\n",
- asect->name, (long) asect->vma, asect->index, (long) asect);
-#endif
- }
-
- /* Classify all of the symbols. */
- for (idx = 0; idx < symcount; idx++)
- {
- if (!sym_is_global (abfd, syms[idx]))
- num_locals++;
- else
- num_globals++;
- }
- for (asect = abfd->sections; asect; asect = asect->next)
- {
- if (sect_syms[asect->index] != NULL
- && sect_syms[asect->index]->flags == 0)
- {
- sect_syms[asect->index]->flags = BSF_SECTION_SYM;
- if (!sym_is_global (abfd, sect_syms[asect->index]))
- num_locals++;
- else
- num_globals++;
- sect_syms[asect->index]->flags = 0;
- }
- }
-
- /* Now sort the symbols so the local symbols are first. */
- new_syms = ((asymbol **)
- bfd_alloc (abfd,
- (num_locals + num_globals) * sizeof (asymbol *)));
- if (new_syms == NULL)
- return false;
-
- for (idx = 0; idx < symcount; idx++)
- {
- asymbol *sym = syms[idx];
- int i;
-
- if (!sym_is_global (abfd, sym))
- i = num_locals2++;
- else
- i = num_locals + num_globals2++;
- new_syms[i] = sym;
- sym->udata.i = i + 1;
- }
- for (asect = abfd->sections; asect; asect = asect->next)
- {
- if (sect_syms[asect->index] != NULL
- && sect_syms[asect->index]->flags == 0)
- {
- asymbol *sym = sect_syms[asect->index];
- int i;
-
- sym->flags = BSF_SECTION_SYM;
- if (!sym_is_global (abfd, sym))
- i = num_locals2++;
- else
- i = num_locals + num_globals2++;
- new_syms[i] = sym;
- sym->udata.i = i + 1;
- }
- }
-
- bfd_set_symtab (abfd, new_syms, num_locals + num_globals);
-
- elf_num_locals (abfd) = num_locals;
- elf_num_globals (abfd) = num_globals;
- return true;
-}
-
-/* Align to the maximum file alignment that could be required for any
- ELF data structure. */
-
-static INLINE file_ptr align_file_position PARAMS ((file_ptr, int));
-static INLINE file_ptr
-align_file_position (off, align)
- file_ptr off;
- int align;
-{
- return (off + align - 1) & ~(align - 1);
-}
-
-/* Assign a file position to a section, optionally aligning to the
- required section alignment. */
-
-INLINE file_ptr
-_bfd_elf_assign_file_position_for_section (i_shdrp, offset, align)
- Elf_Internal_Shdr *i_shdrp;
- file_ptr offset;
- boolean align;
-{
- if (align)
- {
- unsigned int al;
-
- al = i_shdrp->sh_addralign;
- if (al > 1)
- offset = BFD_ALIGN (offset, al);
- }
- i_shdrp->sh_offset = offset;
- if (i_shdrp->bfd_section != NULL)
- i_shdrp->bfd_section->filepos = offset;
- if (i_shdrp->sh_type != SHT_NOBITS)
- offset += i_shdrp->sh_size;
- return offset;
-}
-
-/* Compute the file positions we are going to put the sections at, and
- otherwise prepare to begin writing out the ELF file. If LINK_INFO
- is not NULL, this is being called by the ELF backend linker. */
-
-boolean
-_bfd_elf_compute_section_file_positions (abfd, link_info)
- bfd *abfd;
- struct bfd_link_info *link_info;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- boolean failed;
- struct bfd_strtab_hash *strtab;
- Elf_Internal_Shdr *shstrtab_hdr;
-
- if (abfd->output_has_begun)
- return true;
-
- /* Do any elf backend specific processing first. */
- if (bed->elf_backend_begin_write_processing)
- (*bed->elf_backend_begin_write_processing) (abfd, link_info);
-
- if (! prep_headers (abfd))
- return false;
-
- failed = false;
- bfd_map_over_sections (abfd, elf_fake_sections, &failed);
- if (failed)
- return false;
-
- if (!assign_section_numbers (abfd))
- return false;
-
- /* The backend linker builds symbol table information itself. */
- if (link_info == NULL && abfd->symcount > 0)
- {
- if (! swap_out_syms (abfd, &strtab))
- return false;
- }
-
- shstrtab_hdr = &elf_tdata (abfd)->shstrtab_hdr;
- /* sh_name was set in prep_headers. */
- shstrtab_hdr->sh_type = SHT_STRTAB;
- shstrtab_hdr->sh_flags = 0;
- shstrtab_hdr->sh_addr = 0;
- shstrtab_hdr->sh_size = _bfd_stringtab_size (elf_shstrtab (abfd));
- shstrtab_hdr->sh_entsize = 0;
- shstrtab_hdr->sh_link = 0;
- shstrtab_hdr->sh_info = 0;
- /* sh_offset is set in assign_file_positions_except_relocs. */
- shstrtab_hdr->sh_addralign = 1;
-
- if (!assign_file_positions_except_relocs (abfd))
- return false;
-
- if (link_info == NULL && abfd->symcount > 0)
- {
- file_ptr off;
- Elf_Internal_Shdr *hdr;
-
- off = elf_tdata (abfd)->next_file_pos;
-
- hdr = &elf_tdata (abfd)->symtab_hdr;
- off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
-
- hdr = &elf_tdata (abfd)->strtab_hdr;
- off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
-
- elf_tdata (abfd)->next_file_pos = off;
-
- /* Now that we know where the .strtab section goes, write it
- out. */
- if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
- || ! _bfd_stringtab_emit (abfd, strtab))
- return false;
- _bfd_stringtab_free (strtab);
- }
-
- abfd->output_has_begun = true;
-
- return true;
-}
-
-/* Create a mapping from a set of sections to a program segment. */
-
-static INLINE struct elf_segment_map *
-make_mapping (abfd, sections, from, to, phdr)
- bfd *abfd;
- asection **sections;
- unsigned int from;
- unsigned int to;
- boolean phdr;
-{
- struct elf_segment_map *m;
- unsigned int i;
- asection **hdrpp;
-
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd,
- (sizeof (struct elf_segment_map)
- + (to - from - 1) * sizeof (asection *))));
- if (m == NULL)
- return NULL;
- m->next = NULL;
- m->p_type = PT_LOAD;
- for (i = from, hdrpp = sections + from; i < to; i++, hdrpp++)
- m->sections[i - from] = *hdrpp;
- m->count = to - from;
-
- if (from == 0 && phdr)
- {
- /* Include the headers in the first PT_LOAD segment. */
- m->includes_filehdr = 1;
- m->includes_phdrs = 1;
- }
-
- return m;
-}
-
-/* Set up a mapping from BFD sections to program segments. */
-
-static boolean
-map_sections_to_segments (abfd)
- bfd *abfd;
-{
- asection **sections = NULL;
- asection *s;
- unsigned int i;
- unsigned int count;
- struct elf_segment_map *mfirst;
- struct elf_segment_map **pm;
- struct elf_segment_map *m;
- asection *last_hdr;
- unsigned int phdr_index;
- bfd_vma maxpagesize;
- asection **hdrpp;
- boolean phdr_in_section = true;
- boolean writable;
- asection *dynsec;
-
- if (elf_tdata (abfd)->segment_map != NULL)
- return true;
-
- if (bfd_count_sections (abfd) == 0)
- return true;
-
- /* Select the allocated sections, and sort them. */
-
- sections = (asection **) bfd_malloc (bfd_count_sections (abfd)
- * sizeof (asection *));
- if (sections == NULL)
- goto error_return;
-
- i = 0;
- for (s = abfd->sections; s != NULL; s = s->next)
- {
- if ((s->flags & SEC_ALLOC) != 0)
- {
- sections[i] = s;
- ++i;
- }
- }
- BFD_ASSERT (i <= bfd_count_sections (abfd));
- count = i;
-
- qsort (sections, (size_t) count, sizeof (asection *), elf_sort_sections);
-
- /* Build the mapping. */
-
- mfirst = NULL;
- pm = &mfirst;
-
- /* If we have a .interp section, then create a PT_PHDR segment for
- the program headers and a PT_INTERP segment for the .interp
- section. */
- s = bfd_get_section_by_name (abfd, ".interp");
- if (s != NULL && (s->flags & SEC_LOAD) != 0)
- {
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
- if (m == NULL)
- goto error_return;
- m->next = NULL;
- m->p_type = PT_PHDR;
- /* FIXME: UnixWare and Solaris set PF_X, Irix 5 does not. */
- m->p_flags = PF_R | PF_X;
- m->p_flags_valid = 1;
- m->includes_phdrs = 1;
-
- *pm = m;
- pm = &m->next;
-
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
- if (m == NULL)
- goto error_return;
- m->next = NULL;
- m->p_type = PT_INTERP;
- m->count = 1;
- m->sections[0] = s;
-
- *pm = m;
- pm = &m->next;
- }
-
- /* Look through the sections. We put sections in the same program
- segment when the start of the second section can be placed within
- a few bytes of the end of the first section. */
- last_hdr = NULL;
- phdr_index = 0;
- maxpagesize = get_elf_backend_data (abfd)->maxpagesize;
- writable = false;
- dynsec = bfd_get_section_by_name (abfd, ".dynamic");
- if (dynsec != NULL
- && (dynsec->flags & SEC_LOAD) == 0)
- dynsec = NULL;
-
- /* Deal with -Ttext or something similar such that the
- first section is not adjacent to the program headers. */
- if (count
- && ((sections[0]->lma % maxpagesize) <
- (elf_tdata (abfd)->program_header_size % maxpagesize)))
- phdr_in_section = false;
-
- for (i = 0, hdrpp = sections; i < count; i++, hdrpp++)
- {
- asection *hdr;
-
- hdr = *hdrpp;
-
- /* See if this section and the last one will fit in the same
- segment. Don't put a loadable section after a non-loadable
- section. If we are building a dynamic executable, don't put
- a writable section in a read only segment (we don't do this
- for a non-dynamic executable because some people prefer to
- have only one program segment; anybody can use PHDRS in their
- linker script to control what happens anyhow). */
- if (last_hdr == NULL
- || ((BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize)
- >= hdr->lma)
- && ((last_hdr->flags & SEC_LOAD) != 0
- || (hdr->flags & SEC_LOAD) == 0)
- && (dynsec == NULL
- || writable
- || (hdr->flags & SEC_READONLY) != 0)))
- {
- last_hdr = hdr;
- continue;
- }
-
- /* This section won't fit in the program segment. We must
- create a new program header holding all the sections from
- phdr_index until hdr. */
-
- m = make_mapping (abfd, sections, phdr_index, i, phdr_in_section);
- if (m == NULL)
- goto error_return;
-
- *pm = m;
- pm = &m->next;
-
- if ((hdr->flags & SEC_READONLY) == 0)
- writable = true;
-
- last_hdr = hdr;
- phdr_index = i;
- phdr_in_section = false;
- }
-
- /* Create a final PT_LOAD program segment. */
- if (last_hdr != NULL)
- {
- m = make_mapping (abfd, sections, phdr_index, i, phdr_in_section);
- if (m == NULL)
- goto error_return;
-
- *pm = m;
- pm = &m->next;
- }
-
- /* If there is a .dynamic section, throw in a PT_DYNAMIC segment. */
- if (dynsec != NULL)
- {
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
- if (m == NULL)
- goto error_return;
- m->next = NULL;
- m->p_type = PT_DYNAMIC;
- m->count = 1;
- m->sections[0] = dynsec;
-
- *pm = m;
- pm = &m->next;
- }
-
- free (sections);
- sections = NULL;
-
- elf_tdata (abfd)->segment_map = mfirst;
- return true;
-
- error_return:
- if (sections != NULL)
- free (sections);
- return false;
-}
-
-/* Sort sections by VMA. */
-
-static int
-elf_sort_sections (arg1, arg2)
- const PTR arg1;
- const PTR arg2;
-{
- const asection *sec1 = *(const asection **) arg1;
- const asection *sec2 = *(const asection **) arg2;
-
- if (sec1->vma < sec2->vma)
- return -1;
- else if (sec1->vma > sec2->vma)
- return 1;
-
- /* Put !SEC_LOAD sections after SEC_LOAD ones. */
-
-#define TOEND(x) (((x)->flags & SEC_LOAD) == 0)
-
- if (TOEND (sec1))
- if (TOEND (sec2))
- return sec1->target_index - sec2->target_index;
- else
- return 1;
-
- if (TOEND (sec2))
- return -1;
-
-#undef TOEND
-
- /* Sort by size, to put zero sized sections before others at the
- same address. */
-
- if (sec1->_raw_size < sec2->_raw_size)
- return -1;
- if (sec1->_raw_size > sec2->_raw_size)
- return 1;
-
- return sec1->target_index - sec2->target_index;
-}
-
-/* Assign file positions to the sections based on the mapping from
- sections to segments. This function also sets up some fields in
- the file header, and writes out the program headers. */
-
-static boolean
-assign_file_positions_for_segments (abfd)
- bfd *abfd;
-{
- const struct elf_backend_data *bed = get_elf_backend_data (abfd);
- unsigned int count;
- struct elf_segment_map *m;
- unsigned int alloc;
- Elf_Internal_Phdr *phdrs;
- file_ptr off;
- bfd_vma filehdr_vaddr, filehdr_paddr;
- bfd_vma phdrs_vaddr, phdrs_paddr;
- Elf_Internal_Phdr *p;
-
- if (elf_tdata (abfd)->segment_map == NULL)
- {
- if (! map_sections_to_segments (abfd))
- return false;
- }
-
- if (bed->elf_backend_modify_segment_map)
- {
- if (! (*bed->elf_backend_modify_segment_map) (abfd))
- return false;
- }
-
- count = 0;
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
- ++count;
-
- elf_elfheader (abfd)->e_phoff = bed->s->sizeof_ehdr;
- elf_elfheader (abfd)->e_phentsize = bed->s->sizeof_phdr;
- elf_elfheader (abfd)->e_phnum = count;
-
- if (count == 0)
- return true;
-
- /* If we already counted the number of program segments, make sure
- that we allocated enough space. This happens when SIZEOF_HEADERS
- is used in a linker script. */
- alloc = elf_tdata (abfd)->program_header_size / bed->s->sizeof_phdr;
- if (alloc != 0 && count > alloc)
- {
- ((*_bfd_error_handler)
- ("%s: Not enough room for program headers (allocated %u, need %u)",
- bfd_get_filename (abfd), alloc, count));
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- if (alloc == 0)
- alloc = count;
-
- phdrs = ((Elf_Internal_Phdr *)
- bfd_alloc (abfd, alloc * sizeof (Elf_Internal_Phdr)));
- if (phdrs == NULL)
- return false;
-
- off = bed->s->sizeof_ehdr;
- off += alloc * bed->s->sizeof_phdr;
-
- filehdr_vaddr = 0;
- filehdr_paddr = 0;
- phdrs_vaddr = 0;
- phdrs_paddr = 0;
- for (m = elf_tdata (abfd)->segment_map, p = phdrs;
- m != NULL;
- m = m->next, p++)
- {
- unsigned int i;
- asection **secpp;
-
- /* If elf_segment_map is not from map_sections_to_segments, the
- sections may not be correctly ordered. */
- if (m->count > 0)
- qsort (m->sections, (size_t) m->count, sizeof (asection *),
- elf_sort_sections);
-
- p->p_type = m->p_type;
-
- if (m->p_flags_valid)
- p->p_flags = m->p_flags;
- else
- p->p_flags = 0;
-
- if (p->p_type == PT_LOAD
- && m->count > 0
- && (m->sections[0]->flags & SEC_LOAD) != 0)
- off += (m->sections[0]->vma - off) % bed->maxpagesize;
-
- if (m->count == 0)
- p->p_vaddr = 0;
- else
- p->p_vaddr = m->sections[0]->vma;
-
- if (m->p_paddr_valid)
- p->p_paddr = m->p_paddr;
- else if (m->count == 0)
- p->p_paddr = 0;
- else
- p->p_paddr = m->sections[0]->lma;
-
- if (p->p_type == PT_LOAD)
- p->p_align = bed->maxpagesize;
- else if (m->count == 0)
- p->p_align = bed->s->file_align;
- else
- p->p_align = 0;
-
- p->p_offset = 0;
- p->p_filesz = 0;
- p->p_memsz = 0;
-
- if (m->includes_filehdr)
- {
- if (! m->p_flags_valid)
- p->p_flags |= PF_R;
- p->p_offset = 0;
- p->p_filesz = bed->s->sizeof_ehdr;
- p->p_memsz = bed->s->sizeof_ehdr;
- if (m->count > 0)
- {
- BFD_ASSERT (p->p_type == PT_LOAD);
- p->p_vaddr -= off;
- if (! m->p_paddr_valid)
- p->p_paddr -= off;
- }
- if (p->p_type == PT_LOAD)
- {
- filehdr_vaddr = p->p_vaddr;
- filehdr_paddr = p->p_paddr;
- }
- }
-
- if (m->includes_phdrs)
- {
- if (! m->p_flags_valid)
- p->p_flags |= PF_R;
- if (m->includes_filehdr)
- {
- if (p->p_type == PT_LOAD)
- {
- phdrs_vaddr = p->p_vaddr + bed->s->sizeof_ehdr;
- phdrs_paddr = p->p_paddr + bed->s->sizeof_ehdr;
- }
- }
- else
- {
- p->p_offset = bed->s->sizeof_ehdr;
- if (m->count > 0)
- {
- BFD_ASSERT (p->p_type == PT_LOAD);
- p->p_vaddr -= off - p->p_offset;
- if (! m->p_paddr_valid)
- p->p_paddr -= off - p->p_offset;
- }
- if (p->p_type == PT_LOAD)
- {
- phdrs_vaddr = p->p_vaddr;
- phdrs_paddr = p->p_paddr;
- }
- }
- p->p_filesz += alloc * bed->s->sizeof_phdr;
- p->p_memsz += alloc * bed->s->sizeof_phdr;
- }
-
- if (p->p_type == PT_LOAD)
- {
- if (! m->includes_filehdr && ! m->includes_phdrs)
- p->p_offset = off;
- else
- {
- file_ptr adjust;
-
- adjust = off - (p->p_offset + p->p_filesz);
- p->p_filesz += adjust;
- p->p_memsz += adjust;
- }
- }
-
- for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
- {
- asection *sec;
- flagword flags;
- bfd_size_type align;
-
- sec = *secpp;
- flags = sec->flags;
-
- if (p->p_type == PT_LOAD)
- {
- bfd_vma adjust;
-
- /* The section VMA must equal the file position modulo
- the page size. */
- if ((flags & SEC_ALLOC) != 0)
- {
- adjust = (sec->vma - off) % bed->maxpagesize;
- if (adjust != 0)
- {
- if (i == 0)
- abort ();
- p->p_memsz += adjust;
- off += adjust;
- if ((flags & SEC_LOAD) != 0)
- p->p_filesz += adjust;
- }
- }
-
- sec->filepos = off;
-
- if ((flags & SEC_LOAD) != 0)
- off += sec->_raw_size;
- }
-
- p->p_memsz += sec->_raw_size;
-
- if ((flags & SEC_LOAD) != 0)
- p->p_filesz += sec->_raw_size;
-
- align = 1 << bfd_get_section_alignment (abfd, sec);
- if (align > p->p_align)
- p->p_align = align;
-
- if (! m->p_flags_valid)
- {
- p->p_flags |= PF_R;
- if ((flags & SEC_CODE) != 0)
- p->p_flags |= PF_X;
- if ((flags & SEC_READONLY) == 0)
- p->p_flags |= PF_W;
- }
- }
- }
-
- /* Now that we have set the section file positions, we can set up
- the file positions for the non PT_LOAD segments. */
- for (m = elf_tdata (abfd)->segment_map, p = phdrs;
- m != NULL;
- m = m->next, p++)
- {
- if (p->p_type != PT_LOAD && m->count > 0)
- {
- BFD_ASSERT (! m->includes_filehdr && ! m->includes_phdrs);
- p->p_offset = m->sections[0]->filepos;
- }
- if (m->count == 0)
- {
- if (m->includes_filehdr)
- {
- p->p_vaddr = filehdr_vaddr;
- if (! m->p_paddr_valid)
- p->p_paddr = filehdr_paddr;
- }
- else if (m->includes_phdrs)
- {
- p->p_vaddr = phdrs_vaddr;
- if (! m->p_paddr_valid)
- p->p_paddr = phdrs_paddr;
- }
- }
- }
-
- /* Clear out any program headers we allocated but did not use. */
- for (; count < alloc; count++, p++)
- {
- memset (p, 0, sizeof *p);
- p->p_type = PT_NULL;
- }
-
- elf_tdata (abfd)->phdr = phdrs;
-
- elf_tdata (abfd)->next_file_pos = off;
-
- /* Write out the program headers. */
- if (bfd_seek (abfd, bed->s->sizeof_ehdr, SEEK_SET) != 0
- || bed->s->write_out_phdrs (abfd, phdrs, alloc) != 0)
- return false;
-
- return true;
-}
-
-/* Get the size of the program header.
-
- If this is called by the linker before any of the section VMA's are set, it
- can't calculate the correct value for a strange memory layout. This only
- happens when SIZEOF_HEADERS is used in a linker script. In this case,
- SORTED_HDRS is NULL and we assume the normal scenario of one text and one
- data segment (exclusive of .interp and .dynamic).
-
- ??? User written scripts must either not use SIZEOF_HEADERS, or assume there
- will be two segments. */
-
-static bfd_size_type
-get_program_header_size (abfd)
- bfd *abfd;
-{
- size_t segs;
- asection *s;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- /* We can't return a different result each time we're called. */
- if (elf_tdata (abfd)->program_header_size != 0)
- return elf_tdata (abfd)->program_header_size;
-
- if (elf_tdata (abfd)->segment_map != NULL)
- {
- struct elf_segment_map *m;
-
- segs = 0;
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
- ++segs;
- elf_tdata (abfd)->program_header_size = segs * bed->s->sizeof_phdr;
- return elf_tdata (abfd)->program_header_size;
- }
-
- /* Assume we will need exactly two PT_LOAD segments: one for text
- and one for data. */
- segs = 2;
-
- s = bfd_get_section_by_name (abfd, ".interp");
- if (s != NULL && (s->flags & SEC_LOAD) != 0)
- {
- /* If we have a loadable interpreter section, we need a
- PT_INTERP segment. In this case, assume we also need a
- PT_PHDR segment, although that may not be true for all
- targets. */
- segs += 2;
- }
-
- if (bfd_get_section_by_name (abfd, ".dynamic") != NULL)
- {
- /* We need a PT_DYNAMIC segment. */
- ++segs;
- }
-
- /* Let the backend count up any program headers it might need. */
- if (bed->elf_backend_additional_program_headers)
- {
- int a;
-
- a = (*bed->elf_backend_additional_program_headers) (abfd);
- if (a == -1)
- abort ();
- segs += a;
- }
-
- elf_tdata (abfd)->program_header_size = segs * bed->s->sizeof_phdr;
- return elf_tdata (abfd)->program_header_size;
-}
-
-/* Work out the file positions of all the sections. This is called by
- _bfd_elf_compute_section_file_positions. All the section sizes and
- VMAs must be known before this is called.
-
- We do not consider reloc sections at this point, unless they form
- part of the loadable image. Reloc sections are assigned file
- positions in assign_file_positions_for_relocs, which is called by
- write_object_contents and final_link.
-
- We also don't set the positions of the .symtab and .strtab here. */
-
-static boolean
-assign_file_positions_except_relocs (abfd)
- bfd *abfd;
-{
- struct elf_obj_tdata * const tdata = elf_tdata (abfd);
- Elf_Internal_Ehdr * const i_ehdrp = elf_elfheader (abfd);
- Elf_Internal_Shdr ** const i_shdrpp = elf_elfsections (abfd);
- file_ptr off;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
- {
- Elf_Internal_Shdr **hdrpp;
- unsigned int i;
-
- /* Start after the ELF header. */
- off = i_ehdrp->e_ehsize;
-
- /* We are not creating an executable, which means that we are
- not creating a program header, and that the actual order of
- the sections in the file is unimportant. */
- for (i = 1, hdrpp = i_shdrpp + 1; i < i_ehdrp->e_shnum; i++, hdrpp++)
- {
- Elf_Internal_Shdr *hdr;
-
- hdr = *hdrpp;
- if (hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
- {
- hdr->sh_offset = -1;
- continue;
- }
- if (i == tdata->symtab_section
- || i == tdata->strtab_section)
- {
- hdr->sh_offset = -1;
- continue;
- }
-
- off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
- }
- }
- else
- {
- unsigned int i;
- Elf_Internal_Shdr **hdrpp;
-
- /* Assign file positions for the loaded sections based on the
- assignment of sections to segments. */
- if (! assign_file_positions_for_segments (abfd))
- return false;
-
- /* Assign file positions for the other sections. */
-
- off = elf_tdata (abfd)->next_file_pos;
- for (i = 1, hdrpp = i_shdrpp + 1; i < i_ehdrp->e_shnum; i++, hdrpp++)
- {
- Elf_Internal_Shdr *hdr;
-
- hdr = *hdrpp;
- if (hdr->bfd_section != NULL
- && hdr->bfd_section->filepos != 0)
- hdr->sh_offset = hdr->bfd_section->filepos;
- else if ((hdr->sh_flags & SHF_ALLOC) != 0)
- {
- ((*_bfd_error_handler)
- ("%s: warning: allocated section `%s' not in segment",
- bfd_get_filename (abfd),
- (hdr->bfd_section == NULL
- ? "*unknown*"
- : hdr->bfd_section->name)));
- off += (hdr->sh_addr - off) % bed->maxpagesize;
- off = _bfd_elf_assign_file_position_for_section (hdr, off,
- false);
- }
- else if (hdr->sh_type == SHT_REL
- || hdr->sh_type == SHT_RELA
- || hdr == i_shdrpp[tdata->symtab_section]
- || hdr == i_shdrpp[tdata->strtab_section])
- hdr->sh_offset = -1;
- else
- off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
- }
- }
-
- /* Place the section headers. */
- off = align_file_position (off, bed->s->file_align);
- i_ehdrp->e_shoff = off;
- off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize;
-
- elf_tdata (abfd)->next_file_pos = off;
-
- return true;
-}
-
-static boolean
-prep_headers (abfd)
- bfd *abfd;
-{
- Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
- Elf_Internal_Phdr *i_phdrp = 0; /* Program header table, internal form */
- Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */
- int count;
- struct bfd_strtab_hash *shstrtab;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- i_ehdrp = elf_elfheader (abfd);
- i_shdrp = elf_elfsections (abfd);
-
- shstrtab = _bfd_elf_stringtab_init ();
- if (shstrtab == NULL)
- return false;
-
- elf_shstrtab (abfd) = shstrtab;
-
- i_ehdrp->e_ident[EI_MAG0] = ELFMAG0;
- i_ehdrp->e_ident[EI_MAG1] = ELFMAG1;
- i_ehdrp->e_ident[EI_MAG2] = ELFMAG2;
- i_ehdrp->e_ident[EI_MAG3] = ELFMAG3;
-
- i_ehdrp->e_ident[EI_CLASS] = bed->s->elfclass;
- i_ehdrp->e_ident[EI_DATA] =
- bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB;
- i_ehdrp->e_ident[EI_VERSION] = bed->s->ev_current;
-
- for (count = EI_PAD; count < EI_NIDENT; count++)
- i_ehdrp->e_ident[count] = 0;
-
- if ((abfd->flags & DYNAMIC) != 0)
- i_ehdrp->e_type = ET_DYN;
- else if ((abfd->flags & EXEC_P) != 0)
- i_ehdrp->e_type = ET_EXEC;
- else
- i_ehdrp->e_type = ET_REL;
-
- switch (bfd_get_arch (abfd))
- {
- case bfd_arch_unknown:
- i_ehdrp->e_machine = EM_NONE;
- break;
- case bfd_arch_sparc:
- if (bed->s->arch_size == 64)
- i_ehdrp->e_machine = EM_SPARC64;
- else
- i_ehdrp->e_machine = EM_SPARC;
- break;
- case bfd_arch_i386:
- i_ehdrp->e_machine = EM_386;
- break;
- case bfd_arch_m68k:
- i_ehdrp->e_machine = EM_68K;
- break;
- case bfd_arch_m88k:
- i_ehdrp->e_machine = EM_88K;
- break;
- case bfd_arch_i860:
- i_ehdrp->e_machine = EM_860;
- break;
- case bfd_arch_mips: /* MIPS Rxxxx */
- i_ehdrp->e_machine = EM_MIPS; /* only MIPS R3000 */
- break;
- case bfd_arch_hppa:
- i_ehdrp->e_machine = EM_PARISC;
- break;
- case bfd_arch_powerpc:
- i_ehdrp->e_machine = EM_PPC;
- break;
- /* also note that EM_M32, AT&T WE32100 is unknown to bfd */
- default:
- i_ehdrp->e_machine = EM_NONE;
- }
- i_ehdrp->e_version = bed->s->ev_current;
- i_ehdrp->e_ehsize = bed->s->sizeof_ehdr;
-
- /* no program header, for now. */
- i_ehdrp->e_phoff = 0;
- i_ehdrp->e_phentsize = 0;
- i_ehdrp->e_phnum = 0;
-
- /* each bfd section is section header entry */
- i_ehdrp->e_entry = bfd_get_start_address (abfd);
- i_ehdrp->e_shentsize = bed->s->sizeof_shdr;
-
- /* if we're building an executable, we'll need a program header table */
- if (abfd->flags & EXEC_P)
- {
- /* it all happens later */
-#if 0
- i_ehdrp->e_phentsize = sizeof (Elf_External_Phdr);
-
- /* elf_build_phdrs() returns a (NULL-terminated) array of
- Elf_Internal_Phdrs */
- i_phdrp = elf_build_phdrs (abfd, i_ehdrp, i_shdrp, &i_ehdrp->e_phnum);
- i_ehdrp->e_phoff = outbase;
- outbase += i_ehdrp->e_phentsize * i_ehdrp->e_phnum;
-#endif
- }
- else
- {
- i_ehdrp->e_phentsize = 0;
- i_phdrp = 0;
- i_ehdrp->e_phoff = 0;
- }
-
- elf_tdata (abfd)->symtab_hdr.sh_name =
- (unsigned int) _bfd_stringtab_add (shstrtab, ".symtab", true, false);
- elf_tdata (abfd)->strtab_hdr.sh_name =
- (unsigned int) _bfd_stringtab_add (shstrtab, ".strtab", true, false);
- elf_tdata (abfd)->shstrtab_hdr.sh_name =
- (unsigned int) _bfd_stringtab_add (shstrtab, ".shstrtab", true, false);
- if (elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
- || elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
- || elf_tdata (abfd)->shstrtab_hdr.sh_name == (unsigned int) -1)
- return false;
-
- return true;
-}
-
-/* Assign file positions for all the reloc sections which are not part
- of the loadable file image. */
-
-void
-_bfd_elf_assign_file_positions_for_relocs (abfd)
- bfd *abfd;
-{
- file_ptr off;
- unsigned int i;
- Elf_Internal_Shdr **shdrpp;
-
- off = elf_tdata (abfd)->next_file_pos;
-
- for (i = 1, shdrpp = elf_elfsections (abfd) + 1;
- i < elf_elfheader (abfd)->e_shnum;
- i++, shdrpp++)
- {
- Elf_Internal_Shdr *shdrp;
-
- shdrp = *shdrpp;
- if ((shdrp->sh_type == SHT_REL || shdrp->sh_type == SHT_RELA)
- && shdrp->sh_offset == -1)
- off = _bfd_elf_assign_file_position_for_section (shdrp, off, true);
- }
-
- elf_tdata (abfd)->next_file_pos = off;
-}
-
-boolean
-_bfd_elf_write_object_contents (abfd)
- bfd *abfd;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- Elf_Internal_Ehdr *i_ehdrp;
- Elf_Internal_Shdr **i_shdrp;
- boolean failed;
- unsigned int count;
-
- if (! abfd->output_has_begun
- && ! _bfd_elf_compute_section_file_positions (abfd,
- (struct bfd_link_info *) NULL))
- return false;
-
- i_shdrp = elf_elfsections (abfd);
- i_ehdrp = elf_elfheader (abfd);
-
- failed = false;
- bfd_map_over_sections (abfd, bed->s->write_relocs, &failed);
- if (failed)
- return false;
- _bfd_elf_assign_file_positions_for_relocs (abfd);
-
- /* After writing the headers, we need to write the sections too... */
- for (count = 1; count < i_ehdrp->e_shnum; count++)
- {
- if (bed->elf_backend_section_processing)
- (*bed->elf_backend_section_processing) (abfd, i_shdrp[count]);
- if (i_shdrp[count]->contents)
- {
- if (bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET) != 0
- || (bfd_write (i_shdrp[count]->contents, i_shdrp[count]->sh_size,
- 1, abfd)
- != i_shdrp[count]->sh_size))
- return false;
- }
- }
-
- /* Write out the section header names. */
- if (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0
- || ! _bfd_stringtab_emit (abfd, elf_shstrtab (abfd)))
- return false;
-
- if (bed->elf_backend_final_write_processing)
- (*bed->elf_backend_final_write_processing) (abfd,
- elf_tdata (abfd)->linker);
-
- return bed->s->write_shdrs_and_ehdr (abfd);
-}
-
-/* given a section, search the header to find them... */
-int
-_bfd_elf_section_from_bfd_section (abfd, asect)
- bfd *abfd;
- struct sec *asect;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
- int index;
- Elf_Internal_Shdr *hdr;
- int maxindex = elf_elfheader (abfd)->e_shnum;
-
- for (index = 0; index < maxindex; index++)
- {
- hdr = i_shdrp[index];
- if (hdr->bfd_section == asect)
- return index;
- }
-
- if (bed->elf_backend_section_from_bfd_section)
- {
- for (index = 0; index < maxindex; index++)
- {
- int retval;
-
- hdr = i_shdrp[index];
- retval = index;
- if ((*bed->elf_backend_section_from_bfd_section)
- (abfd, hdr, asect, &retval))
- return retval;
- }
- }
-
- if (bfd_is_abs_section (asect))
- return SHN_ABS;
- if (bfd_is_com_section (asect))
- return SHN_COMMON;
- if (bfd_is_und_section (asect))
- return SHN_UNDEF;
-
- return -1;
-}
-
-/* Given a BFD symbol, return the index in the ELF symbol table, or -1
- on error. */
-
-int
-_bfd_elf_symbol_from_bfd_symbol (abfd, asym_ptr_ptr)
- bfd *abfd;
- struct symbol_cache_entry **asym_ptr_ptr;
-{
- struct symbol_cache_entry *asym_ptr = *asym_ptr_ptr;
- int idx;
- flagword flags = asym_ptr->flags;
-
- /* When gas creates relocations against local labels, it creates its
- own symbol for the section, but does put the symbol into the
- symbol chain, so udata is 0. When the linker is generating
- relocatable output, this section symbol may be for one of the
- input sections rather than the output section. */
- if (asym_ptr->udata.i == 0
- && (flags & BSF_SECTION_SYM)
- && asym_ptr->section)
- {
- int indx;
-
- if (asym_ptr->section->output_section != NULL)
- indx = asym_ptr->section->output_section->index;
- else
- indx = asym_ptr->section->index;
- if (elf_section_syms (abfd)[indx])
- asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
- }
-
- idx = asym_ptr->udata.i;
-
- if (idx == 0)
- {
- /* This case can occur when using --strip-symbol on a symbol
- which is used in a relocation entry. */
- (*_bfd_error_handler)
- ("%s: symbol `%s' required but not present",
- bfd_get_filename (abfd), bfd_asymbol_name (asym_ptr));
- bfd_set_error (bfd_error_no_symbols);
- return -1;
- }
-
-#if DEBUG & 4
- {
- fprintf (stderr,
- "elf_symbol_from_bfd_symbol 0x%.8lx, name = %s, sym num = %d, flags = 0x%.8lx%s\n",
- (long) asym_ptr, asym_ptr->name, idx, flags,
- elf_symbol_flags (flags));
- fflush (stderr);
- }
-#endif
-
- return idx;
-}
-
-/* Copy private BFD data. This copies any program header information. */
-
-static boolean
-copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- Elf_Internal_Ehdr *iehdr;
- struct elf_segment_map *mfirst;
- struct elf_segment_map **pm;
- Elf_Internal_Phdr *p;
- unsigned int i, c;
-
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return true;
-
- if (elf_tdata (ibfd)->phdr == NULL)
- return true;
-
- iehdr = elf_elfheader (ibfd);
-
- mfirst = NULL;
- pm = &mfirst;
-
- c = elf_elfheader (ibfd)->e_phnum;
- for (i = 0, p = elf_tdata (ibfd)->phdr; i < c; i++, p++)
- {
- unsigned int csecs;
- asection *s;
- struct elf_segment_map *m;
- unsigned int isec;
-
- csecs = 0;
-
- /* The complicated case when p_vaddr is 0 is to handle the
- Solaris linker, which generates a PT_INTERP section with
- p_vaddr and p_memsz set to 0. */
- for (s = ibfd->sections; s != NULL; s = s->next)
- if (((s->vma >= p->p_vaddr
- && (s->vma + s->_raw_size <= p->p_vaddr + p->p_memsz
- || s->vma + s->_raw_size <= p->p_vaddr + p->p_filesz))
- || (p->p_vaddr == 0
- && p->p_filesz > 0
- && (s->flags & SEC_HAS_CONTENTS) != 0
- && (bfd_vma) s->filepos >= p->p_offset
- && ((bfd_vma) s->filepos + s->_raw_size
- <= p->p_offset + p->p_filesz)))
- && (s->flags & SEC_ALLOC) != 0
- && s->output_section != NULL)
- ++csecs;
-
- m = ((struct elf_segment_map *)
- bfd_alloc (obfd,
- (sizeof (struct elf_segment_map)
- + (csecs - 1) * sizeof (asection *))));
- if (m == NULL)
- return false;
-
- m->next = NULL;
- m->p_type = p->p_type;
- m->p_flags = p->p_flags;
- m->p_flags_valid = 1;
- m->p_paddr = p->p_paddr;
- m->p_paddr_valid = 1;
-
- m->includes_filehdr = (p->p_offset == 0
- && p->p_filesz >= iehdr->e_ehsize);
-
- m->includes_phdrs = (p->p_offset <= (bfd_vma) iehdr->e_phoff
- && (p->p_offset + p->p_filesz
- >= ((bfd_vma) iehdr->e_phoff
- + iehdr->e_phnum * iehdr->e_phentsize)));
-
- isec = 0;
- for (s = ibfd->sections; s != NULL; s = s->next)
- {
- if (((s->vma >= p->p_vaddr
- && (s->vma + s->_raw_size <= p->p_vaddr + p->p_memsz
- || s->vma + s->_raw_size <= p->p_vaddr + p->p_filesz))
- || (p->p_vaddr == 0
- && p->p_filesz > 0
- && (s->flags & SEC_HAS_CONTENTS) != 0
- && (bfd_vma) s->filepos >= p->p_offset
- && ((bfd_vma) s->filepos + s->_raw_size
- <= p->p_offset + p->p_filesz)))
- && (s->flags & SEC_ALLOC) != 0
- && s->output_section != NULL)
- {
- m->sections[isec] = s->output_section;
- ++isec;
- }
- }
- BFD_ASSERT (isec == csecs);
- m->count = csecs;
-
- *pm = m;
- pm = &m->next;
- }
-
- elf_tdata (obfd)->segment_map = mfirst;
-
- return true;
-}
-
-/* Copy private section information. This copies over the entsize
- field, and sometimes the info field. */
-
-boolean
-_bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec)
- bfd *ibfd;
- asection *isec;
- bfd *obfd;
- asection *osec;
-{
- Elf_Internal_Shdr *ihdr, *ohdr;
-
- if (ibfd->xvec->flavour != bfd_target_elf_flavour
- || obfd->xvec->flavour != bfd_target_elf_flavour)
- return true;
-
- /* Copy over private BFD data if it has not already been copied.
- This must be done here, rather than in the copy_private_bfd_data
- entry point, because the latter is called after the section
- contents have been set, which means that the program headers have
- already been worked out. */
- if (elf_tdata (obfd)->segment_map == NULL
- && elf_tdata (ibfd)->phdr != NULL)
- {
- asection *s;
-
- /* Only set up the segments when all the sections have been set
- up. */
- for (s = ibfd->sections; s != NULL; s = s->next)
- if (s->output_section == NULL)
- break;
- if (s == NULL)
- {
- if (! copy_private_bfd_data (ibfd, obfd))
- return false;
- }
- }
-
- ihdr = &elf_section_data (isec)->this_hdr;
- ohdr = &elf_section_data (osec)->this_hdr;
-
- ohdr->sh_entsize = ihdr->sh_entsize;
-
- if (ihdr->sh_type == SHT_SYMTAB
- || ihdr->sh_type == SHT_DYNSYM)
- ohdr->sh_info = ihdr->sh_info;
-
- return true;
-}
-
-/* Copy private symbol information. If this symbol is in a section
- which we did not map into a BFD section, try to map the section
- index correctly. We use special macro definitions for the mapped
- section indices; these definitions are interpreted by the
- swap_out_syms function. */
-
-#define MAP_ONESYMTAB (SHN_LORESERVE - 1)
-#define MAP_DYNSYMTAB (SHN_LORESERVE - 2)
-#define MAP_STRTAB (SHN_LORESERVE - 3)
-#define MAP_SHSTRTAB (SHN_LORESERVE - 4)
-
-boolean
-_bfd_elf_copy_private_symbol_data (ibfd, isymarg, obfd, osymarg)
- bfd *ibfd;
- asymbol *isymarg;
- bfd *obfd;
- asymbol *osymarg;
-{
- elf_symbol_type *isym, *osym;
-
- isym = elf_symbol_from (ibfd, isymarg);
- osym = elf_symbol_from (obfd, osymarg);
-
- if (isym != NULL
- && osym != NULL
- && bfd_is_abs_section (isym->symbol.section))
- {
- unsigned int shndx;
-
- shndx = isym->internal_elf_sym.st_shndx;
- if (shndx == elf_onesymtab (ibfd))
- shndx = MAP_ONESYMTAB;
- else if (shndx == elf_dynsymtab (ibfd))
- shndx = MAP_DYNSYMTAB;
- else if (shndx == elf_tdata (ibfd)->strtab_section)
- shndx = MAP_STRTAB;
- else if (shndx == elf_tdata (ibfd)->shstrtab_section)
- shndx = MAP_SHSTRTAB;
- osym->internal_elf_sym.st_shndx = shndx;
- }
-
- return true;
-}
-
-/* Swap out the symbols. */
-
-static boolean
-swap_out_syms (abfd, sttp)
- bfd *abfd;
- struct bfd_strtab_hash **sttp;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- if (!elf_map_symbols (abfd))
- return false;
-
- /* Dump out the symtabs. */
- {
- int symcount = bfd_get_symcount (abfd);
- asymbol **syms = bfd_get_outsymbols (abfd);
- struct bfd_strtab_hash *stt;
- Elf_Internal_Shdr *symtab_hdr;
- Elf_Internal_Shdr *symstrtab_hdr;
- char *outbound_syms;
- int idx;
-
- stt = _bfd_elf_stringtab_init ();
- if (stt == NULL)
- return false;
-
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- symtab_hdr->sh_type = SHT_SYMTAB;
- symtab_hdr->sh_entsize = bed->s->sizeof_sym;
- symtab_hdr->sh_size = symtab_hdr->sh_entsize * (symcount + 1);
- symtab_hdr->sh_info = elf_num_locals (abfd) + 1;
- symtab_hdr->sh_addralign = bed->s->file_align;
-
- symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
- symstrtab_hdr->sh_type = SHT_STRTAB;
-
- outbound_syms = bfd_alloc (abfd,
- (1 + symcount) * bed->s->sizeof_sym);
- if (outbound_syms == NULL)
- return false;
- symtab_hdr->contents = (PTR) outbound_syms;
-
- /* now generate the data (for "contents") */
- {
- /* Fill in zeroth symbol and swap it out. */
- Elf_Internal_Sym sym;
- sym.st_name = 0;
- sym.st_value = 0;
- sym.st_size = 0;
- sym.st_info = 0;
- sym.st_other = 0;
- sym.st_shndx = SHN_UNDEF;
- bed->s->swap_symbol_out (abfd, &sym, (PTR) outbound_syms);
- outbound_syms += bed->s->sizeof_sym;
- }
- for (idx = 0; idx < symcount; idx++)
- {
- Elf_Internal_Sym sym;
- bfd_vma value = syms[idx]->value;
- elf_symbol_type *type_ptr;
- flagword flags = syms[idx]->flags;
- int type;
-
- if (flags & BSF_SECTION_SYM)
- /* Section symbols have no names. */
- sym.st_name = 0;
- else
- {
- sym.st_name = (unsigned long) _bfd_stringtab_add (stt,
- syms[idx]->name,
- true, false);
- if (sym.st_name == (unsigned long) -1)
- return false;
- }
-
- type_ptr = elf_symbol_from (abfd, syms[idx]);
-
- if (bfd_is_com_section (syms[idx]->section))
- {
- /* ELF common symbols put the alignment into the `value' field,
- and the size into the `size' field. This is backwards from
- how BFD handles it, so reverse it here. */
- sym.st_size = value;
- if (type_ptr == NULL
- || type_ptr->internal_elf_sym.st_value == 0)
- sym.st_value = value >= 16 ? 16 : (1 << bfd_log2 (value));
- else
- sym.st_value = type_ptr->internal_elf_sym.st_value;
- sym.st_shndx = _bfd_elf_section_from_bfd_section (abfd,
- syms[idx]->section);
- }
- else
- {
- asection *sec = syms[idx]->section;
- int shndx;
-
- if (sec->output_section)
- {
- value += sec->output_offset;
- sec = sec->output_section;
- }
- value += sec->vma;
- sym.st_value = value;
- sym.st_size = type_ptr ? type_ptr->internal_elf_sym.st_size : 0;
-
- if (bfd_is_abs_section (sec)
- && type_ptr != NULL
- && type_ptr->internal_elf_sym.st_shndx != 0)
- {
- /* This symbol is in a real ELF section which we did
- not create as a BFD section. Undo the mapping done
- by copy_private_symbol_data. */
- shndx = type_ptr->internal_elf_sym.st_shndx;
- switch (shndx)
- {
- case MAP_ONESYMTAB:
- shndx = elf_onesymtab (abfd);
- break;
- case MAP_DYNSYMTAB:
- shndx = elf_dynsymtab (abfd);
- break;
- case MAP_STRTAB:
- shndx = elf_tdata (abfd)->strtab_section;
- break;
- case MAP_SHSTRTAB:
- shndx = elf_tdata (abfd)->shstrtab_section;
- break;
- default:
- break;
- }
- }
- else
- {
- shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
-
- if (shndx == -1)
- {
- asection *sec2;
-
- /* Writing this would be a hell of a lot easier if
- we had some decent documentation on bfd, and
- knew what to expect of the library, and what to
- demand of applications. For example, it
- appears that `objcopy' might not set the
- section of a symbol to be a section that is
- actually in the output file. */
- sec2 = bfd_get_section_by_name (abfd, sec->name);
- BFD_ASSERT (sec2 != 0);
- shndx = _bfd_elf_section_from_bfd_section (abfd, sec2);
- BFD_ASSERT (shndx != -1);
- }
- }
-
- sym.st_shndx = shndx;
- }
-
- if ((flags & BSF_FUNCTION) != 0)
- type = STT_FUNC;
- else if ((flags & BSF_OBJECT) != 0)
- type = STT_OBJECT;
- else
- type = STT_NOTYPE;
-
- if (bfd_is_com_section (syms[idx]->section))
- sym.st_info = ELF_ST_INFO (STB_GLOBAL, type);
- else if (bfd_is_und_section (syms[idx]->section))
- sym.st_info = ELF_ST_INFO (((flags & BSF_WEAK)
- ? STB_WEAK
- : STB_GLOBAL),
- type);
- else if (flags & BSF_SECTION_SYM)
- sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
- else if (flags & BSF_FILE)
- sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
- else
- {
- int bind = STB_LOCAL;
-
- if (flags & BSF_LOCAL)
- bind = STB_LOCAL;
- else if (flags & BSF_WEAK)
- bind = STB_WEAK;
- else if (flags & BSF_GLOBAL)
- bind = STB_GLOBAL;
-
- sym.st_info = ELF_ST_INFO (bind, type);
- }
-
- sym.st_other = 0;
- bed->s->swap_symbol_out (abfd, &sym, (PTR) outbound_syms);
- outbound_syms += bed->s->sizeof_sym;
- }
-
- *sttp = stt;
- symstrtab_hdr->sh_size = _bfd_stringtab_size (stt);
- symstrtab_hdr->sh_type = SHT_STRTAB;
-
- symstrtab_hdr->sh_flags = 0;
- symstrtab_hdr->sh_addr = 0;
- symstrtab_hdr->sh_entsize = 0;
- symstrtab_hdr->sh_link = 0;
- symstrtab_hdr->sh_info = 0;
- symstrtab_hdr->sh_addralign = 1;
- }
-
- return true;
-}
-
-/* Return the number of bytes required to hold the symtab vector.
-
- Note that we base it on the count plus 1, since we will null terminate
- the vector allocated based on this size. However, the ELF symbol table
- always has a dummy entry as symbol #0, so it ends up even. */
-
-long
-_bfd_elf_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- long symcount;
- long symtab_size;
- Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr;
-
- symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
- symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *));
-
- return symtab_size;
-}
-
-long
-_bfd_elf_get_dynamic_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- long symcount;
- long symtab_size;
- Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->dynsymtab_hdr;
-
- if (elf_dynsymtab (abfd) == 0)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
-
- symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
- symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *));
-
- return symtab_size;
-}
-
-long
-_bfd_elf_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- return (asect->reloc_count + 1) * sizeof (arelent *);
-}
-
-/* Canonicalize the relocs. */
-
-long
-_bfd_elf_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr;
- unsigned int i;
-
- if (! get_elf_backend_data (abfd)->s->slurp_reloc_table (abfd, section, symbols))
- return -1;
-
- tblptr = section->relocation;
- for (i = 0; i < section->reloc_count; i++)
- *relptr++ = tblptr++;
-
- *relptr = NULL;
-
- return section->reloc_count;
-}
-
-long
-_bfd_elf_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- long symcount = get_elf_backend_data (abfd)->s->slurp_symbol_table (abfd, alocation, false);
-
- if (symcount >= 0)
- bfd_get_symcount (abfd) = symcount;
- return symcount;
-}
-
-long
-_bfd_elf_canonicalize_dynamic_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- return get_elf_backend_data (abfd)->s->slurp_symbol_table (abfd, alocation, true);
-}
-
-asymbol *
-_bfd_elf_make_empty_symbol (abfd)
- bfd *abfd;
-{
- elf_symbol_type *newsym;
-
- newsym = (elf_symbol_type *) bfd_zalloc (abfd, sizeof (elf_symbol_type));
- if (!newsym)
- return NULL;
- else
- {
- newsym->symbol.the_bfd = abfd;
- return &newsym->symbol;
- }
-}
-
-void
-_bfd_elf_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-alent *
-_bfd_elf_get_lineno (ignore_abfd, symbol)
- bfd *ignore_abfd;
- asymbol *symbol;
-{
- abort ();
- return NULL;
-}
-
-boolean
-_bfd_elf_set_arch_mach (abfd, arch, machine)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- /* If this isn't the right architecture for this backend, and this
- isn't the generic backend, fail. */
- if (arch != get_elf_backend_data (abfd)->arch
- && arch != bfd_arch_unknown
- && get_elf_backend_data (abfd)->arch != bfd_arch_unknown)
- return false;
-
- return bfd_default_set_arch_mach (abfd, arch, machine);
-}
-
-/* Find the nearest line to a particular section and offset, for error
- reporting. */
-
-boolean
-_bfd_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;
-{
- boolean found;
- const char *filename;
- asymbol *func;
- bfd_vma low_func;
- asymbol **p;
-
- if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
- &found, filename_ptr,
- functionname_ptr, line_ptr,
- &elf_tdata (abfd)->line_info))
- return false;
- if (found)
- return true;
-
- if (symbols == NULL)
- return false;
-
- filename = NULL;
- func = NULL;
- low_func = 0;
-
- for (p = symbols; *p != NULL; p++)
- {
- elf_symbol_type *q;
-
- q = (elf_symbol_type *) *p;
-
- if (bfd_get_section (&q->symbol) != section)
- continue;
-
- switch (ELF_ST_TYPE (q->internal_elf_sym.st_info))
- {
- default:
- break;
- case STT_FILE:
- filename = bfd_asymbol_name (&q->symbol);
- break;
- case STT_FUNC:
- if (q->symbol.section == section
- && q->symbol.value >= low_func
- && q->symbol.value <= offset)
- {
- func = (asymbol *) q;
- low_func = q->symbol.value;
- }
- break;
- }
- }
-
- if (func == NULL)
- return false;
-
- *filename_ptr = filename;
- *functionname_ptr = bfd_asymbol_name (func);
- *line_ptr = 0;
- return true;
-}
-
-int
-_bfd_elf_sizeof_headers (abfd, reloc)
- bfd *abfd;
- boolean reloc;
-{
- int ret;
-
- ret = get_elf_backend_data (abfd)->s->sizeof_ehdr;
- if (! reloc)
- ret += get_program_header_size (abfd);
- return ret;
-}
-
-boolean
-_bfd_elf_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- Elf_Internal_Shdr *hdr;
-
- if (! abfd->output_has_begun
- && ! _bfd_elf_compute_section_file_positions (abfd,
- (struct bfd_link_info *) NULL))
- return false;
-
- hdr = &elf_section_data (section)->this_hdr;
-
- if (bfd_seek (abfd, hdr->sh_offset + offset, SEEK_SET) == -1)
- return false;
- if (bfd_write (location, 1, count, abfd) != count)
- return false;
-
- return true;
-}
-
-void
-_bfd_elf_no_info_to_howto (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf_Internal_Rela *dst;
-{
- abort ();
-}
-
-#if 0
-void
-_bfd_elf_no_info_to_howto_rel (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf_Internal_Rel *dst;
-{
- abort ();
-}
-#endif
diff --git a/contrib/gdb/bfd/elf32-gen.c b/contrib/gdb/bfd/elf32-gen.c
deleted file mode 100644
index 385fda208602..000000000000
--- 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 238673170322..000000000000
--- 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 63ee52200e0d..000000000000
--- 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 3b39aac91913..000000000000
--- 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 a8537a75508f..000000000000
--- 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 752dfaed2270..000000000000
--- 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 f3c535e07764..000000000000
--- 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 ced0000e2c51..000000000000
--- 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 a8e5ad3fdb19..000000000000
--- 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 918eb00e2a0b..000000000000
--- 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 f2229694406d..000000000000
--- 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 5daf4ee9f17d..000000000000
--- 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 5059b803c62e..000000000000
--- 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 69fb5b5e6e1d..000000000000
--- 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 a6199f0b0f48..000000000000
--- 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 8100627c9ade..000000000000
--- 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 7b204f763e09..000000000000
--- 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 4ef3c8b3c49b..000000000000
--- 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 f2c0c32cf62e..000000000000
--- 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 fd790b367867..000000000000
--- 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/format.c b/contrib/gdb/bfd/format.c
deleted file mode 100644
index 7a303424df65..000000000000
--- a/contrib/gdb/bfd/format.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* Generic BFD support for file formats.
- 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. */
-
-/*
-SECTION
- File formats
-
- A format is a BFD concept of high level file contents type. The
- formats supported by BFD are:
-
- o <<bfd_object>>
-
- The BFD may contain data, symbols, relocations and debug info.
-
- o <<bfd_archive>>
-
- The BFD contains other BFDs and an optional index.
-
- o <<bfd_core>>
-
- The BFD contains the result of an executable core dump.
-
-
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/* IMPORT from targets.c. */
-extern const size_t _bfd_target_vector_entries;
-
-/*
-FUNCTION
- bfd_check_format
-
-SYNOPSIS
- boolean bfd_check_format(bfd *abfd, bfd_format format);
-
-DESCRIPTION
- Verify if the file attached to the BFD @var{abfd} is compatible
- with the format @var{format} (i.e., one of <<bfd_object>>,
- <<bfd_archive>> or <<bfd_core>>).
-
- If the BFD has been set to a specific target before the
- call, only the named target and format combination is
- checked. If the target has not been set, or has been set to
- <<default>>, then all the known target backends is
- interrogated to determine a match. If the default target
- matches, it is used. If not, exactly one target must recognize
- the file, or an error results.
-
- The function returns <<true>> on success, otherwise <<false>>
- with one of the following error codes:
-
- o <<bfd_error_invalid_operation>> -
- if <<format>> is not one of <<bfd_object>>, <<bfd_archive>> or
- <<bfd_core>>.
-
- o <<bfd_error_system_call>> -
- if an error occured during a read - even some file mismatches
- can cause bfd_error_system_calls.
-
- o <<file_not_recognised>> -
- none of the backends recognised the file format.
-
- o <<bfd_error_file_ambiguously_recognized>> -
- more than one backend recognised the file format.
-*/
-
-boolean
-bfd_check_format (abfd, format)
- bfd *abfd;
- bfd_format format;
-{
- return bfd_check_format_matches (abfd, format, NULL);
-}
-
-/*
-FUNCTION
- bfd_check_format_matches
-
-SYNOPSIS
- boolean bfd_check_format_matches(bfd *abfd, bfd_format format, char ***matching);
-
-DESCRIPTION
- Like <<bfd_check_format>>, except when it returns false with
- <<bfd_errno>> set to <<bfd_error_file_ambiguously_recognized>>. In that
- case, if @var{matching} is not NULL, it will be filled in with
- a NULL-terminated list of the names of the formats that matched,
- allocated with <<malloc>>.
- Then the user may choose a format and try again.
-
- When done with the list that @var{matching} points to, the caller
- should free it.
-*/
-
-boolean
-bfd_check_format_matches (abfd, format, matching)
- bfd *abfd;
- bfd_format format;
- char ***matching;
-{
- const bfd_target * const *target, *save_targ, *right_targ;
- char **matching_vector = NULL;
- int match_count;
-
- if (!bfd_read_p (abfd) ||
- ((int)(abfd->format) < (int)bfd_unknown) ||
- ((int)(abfd->format) >= (int)bfd_type_end)) {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- if (abfd->format != bfd_unknown)
- return (abfd->format == format)? true: false;
-
-
- /* Since the target type was defaulted, check them
- all in the hope that one will be uniquely recognized. */
-
- save_targ = abfd->xvec;
- match_count = 0;
- if (matching)
- {
- matching_vector =
- (char **) bfd_malloc (sizeof (char *) *
- (_bfd_target_vector_entries + 1));
- if (!matching_vector)
- return false;
- matching_vector[0] = NULL;
- *matching = matching_vector;
- }
- right_targ = 0;
-
-
- /* presume the answer is yes */
- abfd->format = format;
-
- /* If the target type was explicitly specified, just check that target. */
-
- if (!abfd->target_defaulted) {
- if (bfd_seek (abfd, (file_ptr)0, SEEK_SET) != 0) /* rewind! */
- return false;
- right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
- if (right_targ) {
- abfd->xvec = right_targ; /* Set the target as returned */
- if (matching)
- free (matching_vector);
- return true; /* File position has moved, BTW */
- }
- }
-
- for (target = bfd_target_vector; *target != NULL; target++) {
- extern const bfd_target binary_vec;
- const bfd_target *temp;
-
- if (*target == &binary_vec)
- continue;
-
- abfd->xvec = *target; /* Change BFD's target temporarily */
- if (bfd_seek (abfd, (file_ptr)0, SEEK_SET) != 0)
- return false;
- /* If _bfd_check_format neglects to set bfd_error, assume bfd_error_wrong_format.
- We didn't used to even pay any attention to bfd_error, so I suspect
- that some _bfd_check_format might have this problem. */
- bfd_set_error (bfd_error_wrong_format);
- temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
- if (temp) { /* This format checks out as ok! */
- right_targ = temp;
- if (matching)
- {
- matching_vector[match_count] = temp->name;
- matching_vector[match_count + 1] = NULL;
- }
- match_count++;
- /* If this is the default target, accept it, even if other targets
- might match. People who want those other targets have to set
- the GNUTARGET variable. */
- if (temp == bfd_default_vector[0])
- {
- if (matching)
- {
- matching_vector[0] = temp->name;
- matching_vector[1] = NULL;
- }
- match_count = 1;
- break;
- }
-#ifdef GNU960
- /* Big- and little-endian b.out archives look the same, but it doesn't
- * matter: there is no difference in their headers, and member file byte
- * orders will (I hope) be handled appropriately by bfd. Ditto for big
- * and little coff archives. And the 4 coff/b.out object formats are
- * unambiguous. So accept the first match we find.
- */
- break;
-#endif
- } else if (bfd_get_error () != bfd_error_wrong_format) {
- abfd->xvec = save_targ;
- abfd->format = bfd_unknown;
- if (matching && bfd_get_error () != bfd_error_file_ambiguously_recognized)
- free (matching_vector);
- return false;
- }
- }
-
- if (match_count == 1) {
- abfd->xvec = right_targ; /* Change BFD's target permanently */
- if (matching)
- free (matching_vector);
- return true; /* File position has moved, BTW */
- }
-
- abfd->xvec = save_targ; /* Restore original target type */
- abfd->format = bfd_unknown; /* Restore original format */
- if (match_count == 0)
- {
- bfd_set_error (bfd_error_file_not_recognized);
- if (matching)
- free (matching_vector);
- }
- else
- bfd_set_error (bfd_error_file_ambiguously_recognized);
- return false;
-}
-
-/*
-FUNCTION
- bfd_set_format
-
-SYNOPSIS
- boolean bfd_set_format(bfd *abfd, bfd_format format);
-
-DESCRIPTION
- This function sets the file format of the BFD @var{abfd} to the
- format @var{format}. If the target set in the BFD does not
- support the format requested, the format is invalid, or the BFD
- is not open for writing, then an error occurs.
-
-*/
-
-boolean
-bfd_set_format (abfd, format)
- bfd *abfd;
- bfd_format format;
-{
-
- if (bfd_read_p (abfd) ||
- ((int)abfd->format < (int)bfd_unknown) ||
- ((int)abfd->format >= (int)bfd_type_end)) {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- if (abfd->format != bfd_unknown)
- return (abfd->format == format) ? true:false;
-
- /* presume the answer is yes */
- abfd->format = format;
-
- if (!BFD_SEND_FMT (abfd, _bfd_set_format, (abfd))) {
- abfd->format = bfd_unknown;
- return false;
- }
-
- return true;
-}
-
-
-/*
-FUNCTION
- bfd_format_string
-
-SYNOPSIS
- CONST char *bfd_format_string(bfd_format format);
-
-DESCRIPTION
- Return a pointer to a const string
- <<invalid>>, <<object>>, <<archive>>, <<core>>, or <<unknown>>,
- depending upon the value of @var{format}.
-*/
-
-CONST char *
-bfd_format_string (format)
- bfd_format format;
-{
- if (((int)format <(int) bfd_unknown)
- || ((int)format >=(int) bfd_type_end))
- return "invalid";
-
- switch (format) {
- case bfd_object:
- return "object"; /* linker/assember/compiler output */
- case bfd_archive:
- return "archive"; /* object archive file */
- case bfd_core:
- return "core"; /* core dump */
- default:
- return "unknown";
- }
-}
diff --git a/contrib/gdb/bfd/freebsd.h b/contrib/gdb/bfd/freebsd.h
deleted file mode 100644
index 7e1d69d0df74..000000000000
--- a/contrib/gdb/bfd/freebsd.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* BFD back-end definitions used by all FreeBSD targets.
- Copyright (C) 1990, 1991, 1992, 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.
-*/
-
-/* 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
-
-#define N_GETMAGIC_NET(exec) \
- (ntohl ((exec).a_info) & 0xffff)
-#define N_GETMID_NET(exec) \
- ((ntohl ((exec).a_info) >> 16) & 0x3ff)
-#define N_GETFLAG_NET(ex) \
- ((ntohl ((exec).a_info) >> 26) & 0x3f)
-
-#define N_MACHTYPE(exec) \
- ((enum machine_type) \
- ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETMID_NET (exec) : \
- ((exec).a_info >> 16) & 0x3ff))
-#define N_FLAGS(exec) \
- ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETFLAG_NET (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) << 26))
-#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 FreeBSD, the magic number is always in correct endian format */
-#define NO_SWAP_MAGIC
-
-
-#define MY_write_object_contents MY(write_object_contents)
-static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
-
-#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;
- }
-
- WRITE_HEADERS(abfd, execp);
-
- return true;
-}
diff --git a/contrib/gdb/bfd/gen-aout.c b/contrib/gdb/bfd/gen-aout.c
deleted file mode 100644
index d2224f762d35..000000000000
--- 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/genlink.h b/contrib/gdb/bfd/genlink.h
deleted file mode 100644
index 5f0809485747..000000000000
--- a/contrib/gdb/bfd/genlink.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* genlink.h -- interface to the BFD generic linker
- Copyright 1993, 1994 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. */
-
-#ifndef GENLINK_H
-#define GENLINK_H
-
-/* This header file is internal to BFD. It describes the internal
- structures and functions used by the BFD generic linker, in case
- any of the more specific linkers want to use or call them. Note
- that some functions, such as _bfd_generic_link_hash_table_create,
- are declared in libbfd.h, because they are expected to be widely
- used. The functions and structures in this file will probably only
- be used by a few files besides linker.c itself. In fact, this file
- is not particularly complete; I have only put in the interfaces I
- actually needed. */
-
-/* The generic linker uses a hash table which is a derived class of
- the standard linker hash table, just as the other backend specific
- linkers do. Do not confuse the generic linker hash table with the
- standard BFD linker hash table it is built upon. */
-
-/* Generic linker hash table entries. */
-
-struct generic_link_hash_entry
-{
- struct bfd_link_hash_entry root;
- /* Whether this symbol has been written out. */
- boolean written;
- /* Symbol from input BFD. */
- asymbol *sym;
-};
-
-/* Generic linker hash table. */
-
-struct generic_link_hash_table
-{
- struct bfd_link_hash_table root;
-};
-
-/* Look up an entry in an generic link hash table. */
-
-#define _bfd_generic_link_hash_lookup(table, string, create, copy, follow) \
- ((struct generic_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
-
-/* Traverse an generic link hash table. */
-
-#define _bfd_generic_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the generic link hash table from the info structure. This is
- just a cast. */
-
-#define _bfd_generic_hash_table(p) \
- ((struct generic_link_hash_table *) ((p)->hash))
-
-/* The generic linker reads in the asymbol structures for an input BFD
- and keeps them in the outsymbol and symcount fields. */
-
-#define _bfd_generic_link_get_symbols(abfd) ((abfd)->outsymbols)
-#define _bfd_generic_link_get_symcount(abfd) ((abfd)->symcount)
-
-/* Add the symbols of input_bfd to the symbols being built for
- output_bfd. */
-extern boolean _bfd_generic_link_output_symbols
- PARAMS ((bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *,
- size_t *psymalloc));
-
-/* This structure is used to pass information to
- _bfd_generic_link_write_global_symbol, which may be called via
- _bfd_generic_link_hash_traverse. */
-
-struct generic_write_global_symbol_info
-{
- struct bfd_link_info *info;
- bfd *output_bfd;
- size_t *psymalloc;
-};
-
-/* Write out a single global symbol. This is expected to be called
- via _bfd_generic_link_hash_traverse. The second argument must
- actually be a struct generic_write_global_symbol_info *. */
-extern boolean _bfd_generic_link_write_global_symbol
- PARAMS ((struct generic_link_hash_entry *, PTR));
-
-#endif
diff --git a/contrib/gdb/bfd/hash.c b/contrib/gdb/bfd/hash.c
deleted file mode 100644
index 35913fcfccc9..000000000000
--- a/contrib/gdb/bfd/hash.c
+++ /dev/null
@@ -1,734 +0,0 @@
-/* hash.c -- hash table routines for BFD
- Copyright (C) 1993, 94 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 "libbfd.h"
-#include "obstack.h"
-
-/*
-SECTION
- Hash Tables
-
-@cindex Hash tables
- BFD provides a simple set of hash table functions. Routines
- are provided to initialize a hash table, to free a hash table,
- to look up a string in a hash table and optionally create an
- entry for it, and to traverse a hash table. There is
- currently no routine to delete an string from a hash table.
-
- The basic hash table does not permit any data to be stored
- with a string. However, a hash table is designed to present a
- base class from which other types of hash tables may be
- derived. These derived types may store additional information
- with the string. Hash tables were implemented in this way,
- rather than simply providing a data pointer in a hash table
- entry, because they were designed for use by the linker back
- ends. The linker may create thousands of hash table entries,
- and the overhead of allocating private data and storing and
- following pointers becomes noticeable.
-
- The basic hash table code is in <<hash.c>>.
-
-@menu
-@* Creating and Freeing a Hash Table::
-@* Looking Up or Entering a String::
-@* Traversing a Hash Table::
-@* Deriving a New Hash Table Type::
-@end menu
-
-INODE
-Creating and Freeing a Hash Table, Looking Up or Entering a String, Hash Tables, Hash Tables
-SUBSECTION
- Creating and freeing a hash table
-
-@findex bfd_hash_table_init
-@findex bfd_hash_table_init_n
- To create a hash table, create an instance of a <<struct
- bfd_hash_table>> (defined in <<bfd.h>>) and call
- <<bfd_hash_table_init>> (if you know approximately how many
- entries you will need, the function <<bfd_hash_table_init_n>>,
- which takes a @var{size} argument, may be used).
- <<bfd_hash_table_init>> returns <<false>> if some sort of
- error occurs.
-
-@findex bfd_hash_newfunc
- The function <<bfd_hash_table_init>> take as an argument a
- function to use to create new entries. For a basic hash
- table, use the function <<bfd_hash_newfunc>>. @xref{Deriving
- a New Hash Table Type} for why you would want to use a
- different value for this argument.
-
-@findex bfd_hash_allocate
- <<bfd_hash_table_init>> will create an obstack which will be
- used to allocate new entries. You may allocate memory on this
- obstack using <<bfd_hash_allocate>>.
-
-@findex bfd_hash_table_free
- Use <<bfd_hash_table_free>> to free up all the memory that has
- been allocated for a hash table. This will not free up the
- <<struct bfd_hash_table>> itself, which you must provide.
-
-INODE
-Looking Up or Entering a String, Traversing a Hash Table, Creating and Freeing a Hash Table, Hash Tables
-SUBSECTION
- Looking up or entering a string
-
-@findex bfd_hash_lookup
- The function <<bfd_hash_lookup>> is used both to look up a
- string in the hash table and to create a new entry.
-
- If the @var{create} argument is <<false>>, <<bfd_hash_lookup>>
- will look up a string. If the string is found, it will
- returns a pointer to a <<struct bfd_hash_entry>>. If the
- string is not found in the table <<bfd_hash_lookup>> will
- return <<NULL>>. You should not modify any of the fields in
- the returns <<struct bfd_hash_entry>>.
-
- If the @var{create} argument is <<true>>, the string will be
- entered into the hash table if it is not already there.
- Either way a pointer to a <<struct bfd_hash_entry>> will be
- returned, either to the existing structure or to a newly
- created one. In this case, a <<NULL>> return means that an
- error occurred.
-
- If the @var{create} argument is <<true>>, and a new entry is
- created, the @var{copy} argument is used to decide whether to
- copy the string onto the hash table obstack or not. If
- @var{copy} is passed as <<false>>, you must be careful not to
- deallocate or modify the string as long as the hash table
- exists.
-
-INODE
-Traversing a Hash Table, Deriving a New Hash Table Type, Looking Up or Entering a String, Hash Tables
-SUBSECTION
- Traversing a hash table
-
-@findex bfd_hash_traverse
- The function <<bfd_hash_traverse>> may be used to traverse a
- hash table, calling a function on each element. The traversal
- is done in a random order.
-
- <<bfd_hash_traverse>> takes as arguments a function and a
- generic <<void *>> pointer. The function is called with a
- hash table entry (a <<struct bfd_hash_entry *>>) and the
- generic pointer passed to <<bfd_hash_traverse>>. The function
- must return a <<boolean>> value, which indicates whether to
- continue traversing the hash table. If the function returns
- <<false>>, <<bfd_hash_traverse>> will stop the traversal and
- return immediately.
-
-INODE
-Deriving a New Hash Table Type, , Traversing a Hash Table, Hash Tables
-SUBSECTION
- Deriving a new hash table type
-
- Many uses of hash tables want to store additional information
- which each entry in the hash table. Some also find it
- convenient to store additional information with the hash table
- itself. This may be done using a derived hash table.
-
- Since C is not an object oriented language, creating a derived
- hash table requires sticking together some boilerplate
- routines with a few differences specific to the type of hash
- table you want to create.
-
- An example of a derived hash table is the linker hash table.
- The structures for this are defined in <<bfdlink.h>>. The
- functions are in <<linker.c>>.
-
- You may also derive a hash table from an already derived hash
- table. For example, the a.out linker backend code uses a hash
- table derived from the linker hash table.
-
-@menu
-@* Define the Derived Structures::
-@* Write the Derived Creation Routine::
-@* Write Other Derived Routines::
-@end menu
-
-INODE
-Define the Derived Structures, Write the Derived Creation Routine, Deriving a New Hash Table Type, Deriving a New Hash Table Type
-SUBSUBSECTION
- Define the derived structures
-
- You must define a structure for an entry in the hash table,
- and a structure for the hash table itself.
-
- The first field in the structure for an entry in the hash
- table must be of the type used for an entry in the hash table
- you are deriving from. If you are deriving from a basic hash
- table this is <<struct bfd_hash_entry>>, which is defined in
- <<bfd.h>>. The first field in the structure for the hash
- table itself must be of the type of the hash table you are
- deriving from itself. If you are deriving from a basic hash
- table, this is <<struct bfd_hash_table>>.
-
- For example, the linker hash table defines <<struct
- bfd_link_hash_entry>> (in <<bfdlink.h>>). The first field,
- <<root>>, is of type <<struct bfd_hash_entry>>. Similarly,
- the first field in <<struct bfd_link_hash_table>>, <<table>>,
- is of type <<struct bfd_hash_table>>.
-
-INODE
-Write the Derived Creation Routine, Write Other Derived Routines, Define the Derived Structures, Deriving a New Hash Table Type
-SUBSUBSECTION
- Write the derived creation routine
-
- You must write a routine which will create and initialize an
- entry in the hash table. This routine is passed as the
- function argument to <<bfd_hash_table_init>>.
-
- In order to permit other hash tables to be derived from the
- hash table you are creating, this routine must be written in a
- standard way.
-
- The first argument to the creation routine is a pointer to a
- hash table entry. This may be <<NULL>>, in which case the
- routine should allocate the right amount of space. Otherwise
- the space has already been allocated by a hash table type
- derived from this one.
-
- After allocating space, the creation routine must call the
- creation routine of the hash table type it is derived from,
- passing in a pointer to the space it just allocated. This
- will initialize any fields used by the base hash table.
-
- Finally the creation routine must initialize any local fields
- for the new hash table type.
-
- Here is a boilerplate example of a creation routine.
- @var{function_name} is the name of the routine.
- @var{entry_type} is the type of an entry in the hash table you
- are creating. @var{base_newfunc} is the name of the creation
- routine of the hash table type your hash table is derived
- from.
-
-EXAMPLE
-
-.struct bfd_hash_entry *
-.@var{function_name} (entry, table, string)
-. struct bfd_hash_entry *entry;
-. struct bfd_hash_table *table;
-. const char *string;
-.{
-. struct @var{entry_type} *ret = (@var{entry_type} *) entry;
-.
-. {* Allocate the structure if it has not already been allocated by a
-. derived class. *}
-. if (ret == (@var{entry_type} *) NULL)
-. {
-. ret = ((@var{entry_type} *)
-. bfd_hash_allocate (table, sizeof (@var{entry_type})));
-. if (ret == (@var{entry_type} *) NULL)
-. return NULL;
-. }
-.
-. {* Call the allocation method of the base class. *}
-. ret = ((@var{entry_type} *)
-. @var{base_newfunc} ((struct bfd_hash_entry *) ret, table, string));
-.
-. {* Initialize the local fields here. *}
-.
-. return (struct bfd_hash_entry *) ret;
-.}
-
-DESCRIPTION
- The creation routine for the linker hash table, which is in
- <<linker.c>>, looks just like this example.
- @var{function_name} is <<_bfd_link_hash_newfunc>>.
- @var{entry_type} is <<struct bfd_link_hash_entry>>.
- @var{base_newfunc} is <<bfd_hash_newfunc>>, the creation
- routine for a basic hash table.
-
- <<_bfd_link_hash_newfunc>> also initializes the local fields
- in a linker hash table entry: <<type>>, <<written>> and
- <<next>>.
-
-INODE
-Write Other Derived Routines, , Write the Derived Creation Routine, Deriving a New Hash Table Type
-SUBSUBSECTION
- Write other derived routines
-
- You will want to write other routines for your new hash table,
- as well.
-
- You will want an initialization routine which calls the
- initialization routine of the hash table you are deriving from
- and initializes any other local fields. For the linker hash
- table, this is <<_bfd_link_hash_table_init>> in <<linker.c>>.
-
- You will want a lookup routine which calls the lookup routine
- of the hash table you are deriving from and casts the result.
- The linker hash table uses <<bfd_link_hash_lookup>> in
- <<linker.c>> (this actually takes an additional argument which
- it uses to decide how to return the looked up value).
-
- You may want a traversal routine. This should just call the
- traversal routine of the hash table you are deriving from with
- appropriate casts. The linker hash table uses
- <<bfd_link_hash_traverse>> in <<linker.c>>.
-
- These routines may simply be defined as macros. For example,
- the a.out backend linker hash table, which is derived from the
- linker hash table, uses macros for the lookup and traversal
- routines. These are <<aout_link_hash_lookup>> and
- <<aout_link_hash_traverse>> in aoutx.h.
-*/
-
-/* Obstack allocation and deallocation routines. */
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-
-/* The default number of entries to use when creating a hash table. */
-#define DEFAULT_SIZE (4051)
-
-/* Create a new hash table, given a number of entries. */
-
-boolean
-bfd_hash_table_init_n (table, newfunc, size)
- struct bfd_hash_table *table;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
- unsigned int size;
-{
- unsigned int alloc;
-
- alloc = size * sizeof (struct bfd_hash_entry *);
- if (!obstack_begin (&table->memory, alloc))
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- table->table = ((struct bfd_hash_entry **)
- obstack_alloc (&table->memory, alloc));
- if (!table->table)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- memset ((PTR) table->table, 0, alloc);
- table->size = size;
- table->newfunc = newfunc;
- return true;
-}
-
-/* Create a new hash table with the default number of entries. */
-
-boolean
-bfd_hash_table_init (table, newfunc)
- struct bfd_hash_table *table;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- return bfd_hash_table_init_n (table, newfunc, DEFAULT_SIZE);
-}
-
-/* Free a hash table. */
-
-void
-bfd_hash_table_free (table)
- struct bfd_hash_table *table;
-{
- obstack_free (&table->memory, (PTR) NULL);
-}
-
-/* Look up a string in a hash table. */
-
-struct bfd_hash_entry *
-bfd_hash_lookup (table, string, create, copy)
- struct bfd_hash_table *table;
- const char *string;
- boolean create;
- boolean copy;
-{
- register const unsigned char *s;
- register unsigned long hash;
- register unsigned int c;
- struct bfd_hash_entry *hashp;
- unsigned int len;
- unsigned int index;
-
- hash = 0;
- len = 0;
- s = (const unsigned char *) string;
- while ((c = *s++) != '\0')
- {
- hash += c + (c << 17);
- hash ^= hash >> 2;
- ++len;
- }
- hash += len + (len << 17);
- hash ^= hash >> 2;
-
- index = hash % table->size;
- for (hashp = table->table[index];
- hashp != (struct bfd_hash_entry *) NULL;
- hashp = hashp->next)
- {
- if (hashp->hash == hash
- && strcmp (hashp->string, string) == 0)
- return hashp;
- }
-
- if (! create)
- return (struct bfd_hash_entry *) NULL;
-
- hashp = (*table->newfunc) ((struct bfd_hash_entry *) NULL, table, string);
- if (hashp == (struct bfd_hash_entry *) NULL)
- return (struct bfd_hash_entry *) NULL;
- if (copy)
- {
- char *new;
-
- new = (char *) obstack_alloc (&table->memory, len + 1);
- if (!new)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_hash_entry *) NULL;
- }
- strcpy (new, string);
- string = new;
- }
- hashp->string = string;
- hashp->hash = hash;
- hashp->next = table->table[index];
- table->table[index] = hashp;
-
- return hashp;
-}
-
-/* Replace an entry in a hash table. */
-
-void
-bfd_hash_replace (table, old, nw)
- struct bfd_hash_table *table;
- struct bfd_hash_entry *old;
- struct bfd_hash_entry *nw;
-{
- unsigned int index;
- struct bfd_hash_entry **pph;
-
- index = old->hash % table->size;
- for (pph = &table->table[index];
- (*pph) != (struct bfd_hash_entry *) NULL;
- pph = &(*pph)->next)
- {
- if (*pph == old)
- {
- *pph = nw;
- return;
- }
- }
-
- abort ();
-}
-
-/* Base method for creating a new hash table entry. */
-
-/*ARGSUSED*/
-struct bfd_hash_entry *
-bfd_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- if (entry == (struct bfd_hash_entry *) NULL)
- entry = ((struct bfd_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct bfd_hash_entry)));
- return entry;
-}
-
-/* Allocate space in a hash table. */
-
-PTR
-bfd_hash_allocate (table, size)
- struct bfd_hash_table *table;
- unsigned int size;
-{
- PTR ret;
-
- ret = obstack_alloc (&table->memory, size);
- if (ret == NULL && size != 0)
- bfd_set_error (bfd_error_no_memory);
- return ret;
-}
-
-/* Traverse a hash table. */
-
-void
-bfd_hash_traverse (table, func, info)
- struct bfd_hash_table *table;
- boolean (*func) PARAMS ((struct bfd_hash_entry *, PTR));
- PTR info;
-{
- unsigned int i;
-
- for (i = 0; i < table->size; i++)
- {
- struct bfd_hash_entry *p;
-
- for (p = table->table[i]; p != NULL; p = p->next)
- {
- if (! (*func) (p, info))
- return;
- }
- }
-}
-
-/* A few different object file formats (a.out, COFF, ELF) use a string
- table. These functions support adding strings to a string table,
- returning the byte offset, and writing out the table.
-
- Possible improvements:
- + look for strings matching trailing substrings of other strings
- + better data structures? balanced trees?
- + look at reducing memory use elsewhere -- maybe if we didn't have
- to construct the entire symbol table at once, we could get by
- with smaller amounts of VM? (What effect does that have on the
- string table reductions?) */
-
-/* An entry in the strtab hash table. */
-
-struct strtab_hash_entry
-{
- struct bfd_hash_entry root;
- /* Index in string table. */
- bfd_size_type index;
- /* Next string in strtab. */
- struct strtab_hash_entry *next;
-};
-
-/* The strtab hash table. */
-
-struct bfd_strtab_hash
-{
- struct bfd_hash_table table;
- /* Size of strtab--also next available index. */
- bfd_size_type size;
- /* First string in strtab. */
- struct strtab_hash_entry *first;
- /* Last string in strtab. */
- struct strtab_hash_entry *last;
- /* Whether to precede strings with a two byte length, as in the
- XCOFF .debug section. */
- boolean xcoff;
-};
-
-static struct bfd_hash_entry *strtab_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-
-/* Routine to create an entry in a strtab. */
-
-static struct bfd_hash_entry *
-strtab_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct strtab_hash_entry *ret = (struct strtab_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct strtab_hash_entry *) NULL)
- ret = ((struct strtab_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct strtab_hash_entry)));
- if (ret == (struct strtab_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct strtab_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- ret->index = (bfd_size_type) -1;
- ret->next = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Look up an entry in an strtab. */
-
-#define strtab_hash_lookup(t, string, create, copy) \
- ((struct strtab_hash_entry *) \
- bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
-
-/* Create a new strtab. */
-
-struct bfd_strtab_hash *
-_bfd_stringtab_init ()
-{
- struct bfd_strtab_hash *table;
-
- table = ((struct bfd_strtab_hash *)
- bfd_malloc (sizeof (struct bfd_strtab_hash)));
- if (table == NULL)
- return NULL;
-
- if (! bfd_hash_table_init (&table->table, strtab_hash_newfunc))
- {
- free (table);
- return NULL;
- }
-
- table->size = 0;
- table->first = NULL;
- table->last = NULL;
- table->xcoff = false;
-
- return table;
-}
-
-/* Create a new strtab in which the strings are output in the format
- used in the XCOFF .debug section: a two byte length precedes each
- string. */
-
-struct bfd_strtab_hash *
-_bfd_xcoff_stringtab_init ()
-{
- struct bfd_strtab_hash *ret;
-
- ret = _bfd_stringtab_init ();
- if (ret != NULL)
- ret->xcoff = true;
- return ret;
-}
-
-/* Free a strtab. */
-
-void
-_bfd_stringtab_free (table)
- struct bfd_strtab_hash *table;
-{
- bfd_hash_table_free (&table->table);
- free (table);
-}
-
-/* Get the index of a string in a strtab, adding it if it is not
- already present. If HASH is false, we don't really use the hash
- table, and we don't eliminate duplicate strings. */
-
-bfd_size_type
-_bfd_stringtab_add (tab, str, hash, copy)
- struct bfd_strtab_hash *tab;
- const char *str;
- boolean hash;
- boolean copy;
-{
- register struct strtab_hash_entry *entry;
-
- if (hash)
- {
- entry = strtab_hash_lookup (tab, str, true, copy);
- if (entry == NULL)
- return (bfd_size_type) -1;
- }
- else
- {
- entry = ((struct strtab_hash_entry *)
- bfd_hash_allocate (&tab->table,
- sizeof (struct strtab_hash_entry)));
- if (entry == NULL)
- return (bfd_size_type) -1;
- if (! copy)
- entry->root.string = str;
- else
- {
- char *n;
-
- n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1);
- if (n == NULL)
- return (bfd_size_type) -1;
- entry->root.string = n;
- }
- entry->index = (bfd_size_type) -1;
- entry->next = NULL;
- }
-
- if (entry->index == (bfd_size_type) -1)
- {
- entry->index = tab->size;
- tab->size += strlen (str) + 1;
- if (tab->xcoff)
- {
- entry->index += 2;
- tab->size += 2;
- }
- if (tab->first == NULL)
- tab->first = entry;
- else
- tab->last->next = entry;
- tab->last = entry;
- }
-
- return entry->index;
-}
-
-/* Get the number of bytes in a strtab. */
-
-bfd_size_type
-_bfd_stringtab_size (tab)
- struct bfd_strtab_hash *tab;
-{
- return tab->size;
-}
-
-/* Write out a strtab. ABFD must already be at the right location in
- the file. */
-
-boolean
-_bfd_stringtab_emit (abfd, tab)
- register bfd *abfd;
- struct bfd_strtab_hash *tab;
-{
- register boolean xcoff;
- register struct strtab_hash_entry *entry;
-
- xcoff = tab->xcoff;
-
- for (entry = tab->first; entry != NULL; entry = entry->next)
- {
- register const char *str;
- register size_t len;
-
- str = entry->root.string;
- len = strlen (str) + 1;
-
- if (xcoff)
- {
- bfd_byte buf[2];
-
- /* The output length includes the null byte. */
- bfd_put_16 (abfd, len, buf);
- if (bfd_write ((PTR) buf, 1, 2, abfd) != 2)
- return false;
- }
-
- if (bfd_write ((PTR) str, 1, len, abfd) != len)
- return false;
- }
-
- return true;
-}
diff --git a/contrib/gdb/bfd/host-aout.c b/contrib/gdb/bfd/host-aout.c
deleted file mode 100644
index 99643dcc24ef..000000000000
--- 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/hosts/alphalinux.h b/contrib/gdb/bfd/hosts/alphalinux.h
deleted file mode 100644
index d9ba1b7ec6be..000000000000
--- a/contrib/gdb/bfd/hosts/alphalinux.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Linux dumps "struct task_struct" at the end of the core-file. This
- structure is currently 920 bytes long, but we allow up to 1024
- bytes to allow for some future growth. */
-#define TRAD_CORE_EXTRA_SIZE_ALLOWED 1024
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- ((abfd)->tdata.trad_core_data->u.signal)
diff --git a/contrib/gdb/bfd/hosts/decstation.h b/contrib/gdb/bfd/hosts/decstation.h
deleted file mode 100644
index a80c143d525e..000000000000
--- a/contrib/gdb/bfd/hosts/decstation.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Hopefully this should include either machine/param.h (Ultrix) or
- machine/machparam.h (Mach), whichever is its name on this system. */
-#include <sys/param.h>
-
-#include <machine/vmparam.h>
-
-#define HOST_PAGE_SIZE NBPG
-/* #define HOST_SEGMENT_SIZE NBPG -- we use HOST_DATA_START_ADDR */
-#define HOST_MACHINE_ARCH bfd_arch_mips
-/* #define HOST_MACHINE_MACHINE */
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_DATA_START_ADDR USRDATA
-#define HOST_STACK_END_ADDR USRSTACK
-
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
- ((core_bfd)->tdata.trad_core_data->u.u_arg[0])
diff --git a/contrib/gdb/bfd/hosts/delta68.h b/contrib/gdb/bfd/hosts/delta68.h
deleted file mode 100644
index 1a6a6e6f197e..000000000000
--- a/contrib/gdb/bfd/hosts/delta68.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Definitions for a Motorola Delta 3300 box running System V R3.0.
- Contributed by manfred@lts.sel.alcatel.de. */
-
-#include <sys/param.h>
-
-/* Definitions used by trad-core.c. */
-#define NBPG NBPC
-#define HOST_DATA_START_ADDR u.u_exdata.ux_datorg
-#define HOST_TEXT_START_ADDR u.u_exdata.ux_txtorg
-#if 0
-#define HOST_STACK_END_ADDR 0x40000000
-#else
-/* User's stack, copied from sys/param.h */
-#define HOST_STACK_END_ADDR USRSTACK
-#endif
-#define UPAGES USIZE
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- abfd->tdata.trad_core_data->u.u_abort
diff --git a/contrib/gdb/bfd/hosts/dpx2.h b/contrib/gdb/bfd/hosts/dpx2.h
deleted file mode 100644
index ea6395f2e5d7..000000000000
--- a/contrib/gdb/bfd/hosts/dpx2.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Definitions that are needed for core files. Core section sizes for
- the DPX2 are in bytes. */
-
-#include <sys/param.h>
-#define NBPG 1
-#define UPAGES (USIZE * NBPP)
-#define HOST_DATA_START_ADDR (u.u_exdata.ux_datorg)
-#define HOST_STACK_END_ADDR (USERSTACK)
diff --git a/contrib/gdb/bfd/hosts/hp300bsd.h b/contrib/gdb/bfd/hosts/hp300bsd.h
deleted file mode 100644
index 982871782073..000000000000
--- a/contrib/gdb/bfd/hosts/hp300bsd.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <sys/param.h>
-#ifdef BSD4_4
-#define NO_CORE_COMMAND
-#endif
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_SEGMENT_SIZE NBPG /* Data seg start addr rounds to NBPG */
-#define HOST_MACHINE_ARCH bfd_arch_m68k
-/* #define HOST_MACHINE_MACHINE */
-
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR 0xfff00000
-#define HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/hosts/i386bsd.h b/contrib/gdb/bfd/hosts/i386bsd.h
deleted file mode 100644
index ac0d8402edbf..000000000000
--- a/contrib/gdb/bfd/hosts/i386bsd.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Intel 386 running any BSD Unix */
-
-#include <machine/param.h>
-#include <machine/vmparam.h>
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_i386
-#define HOST_TEXT_START_ADDR USRTEXT
-
-/* Jolitz suggested defining HOST_STACK_END_ADDR to
- (u.u_kproc.kp_eproc.e_vm.vm_maxsaddr + MAXSSIZ), which should work on
- both BSDI and 386BSD, but that is believed not to work for BSD 4.4. */
-
-#ifdef __bsdi__
-/* This seems to be the right thing for BSDI. */
-#define HOST_STACK_END_ADDR USRSTACK
-#define HOST_DATA_START_ADDR ((bfd_vma)u.u_kproc.kp_eproc.e_vm.vm_daddr)
-#else
-/* This seems to be the right thing for 386BSD release 0.1. */
-#define HOST_STACK_END_ADDR (USRSTACK - MAXSSIZ)
-#endif
-
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
- ((core_bfd)->tdata.trad_core_data->u.u_sig)
-#define u_comm u_kproc.kp_proc.p_comm
diff --git a/contrib/gdb/bfd/hosts/i386linux.h b/contrib/gdb/bfd/hosts/i386linux.h
deleted file mode 100644
index 13a51f1bd14c..000000000000
--- a/contrib/gdb/bfd/hosts/i386linux.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Linux writes the task structure at the end of the core file. Currently it
- is 2912 bytes. It is possible that this should be a pickier check, but
- we should probably not be too picky (the size of the task structure might
- vary, and if it's not the length we expect it to be, it doesn't affect
- our ability to process the core file). So allow 0-4096 extra bytes at
- the end. */
-
-#define TRAD_CORE_EXTRA_SIZE_ALLOWED 4096
diff --git a/contrib/gdb/bfd/hosts/i386mach3.h b/contrib/gdb/bfd/hosts/i386mach3.h
deleted file mode 100644
index dcc61e3c8e89..000000000000
--- a/contrib/gdb/bfd/hosts/i386mach3.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <machine/vmparam.h>
-#include <sys/param.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. UPAGES is used only in trad-core.c.
- */
-#if UPAGES == 16
-#undef UPAGES
-#define UPAGES 2
-#endif
-
-#if UPAGES != 2
-FIXME!! UPAGES is neither 2 nor 16
-#endif
-
-#define HOST_PAGE_SIZE 1
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_i386
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/i386sco.h b/contrib/gdb/bfd/hosts/i386sco.h
deleted file mode 100644
index ec8608c61dd5..000000000000
--- a/contrib/gdb/bfd/hosts/i386sco.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Core file stuff. At least some, perhaps all, of the following
- defines work on many more systems than just SCO. */
-
-#define NBPG NBPC
-#define UPAGES USIZE
-#define HOST_DATA_START_ADDR u.u_exdata.ux_datorg
-#define HOST_STACK_START_ADDR u.u_sub
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- ((core_upage(abfd)->u_sysabort != 0) \
- ? core_upage(abfd)->u_sysabort \
- : -1)
-
-/* According to the manpage, a version 2 SCO corefile can contain
- various additional sections (it is cleverly arranged so the u area,
- data, and stack are first where we can find them). So without
- writing lots of code to parse all their headers and stuff, we can't
- know whether a corefile is bigger than it should be. */
-
-#define TRAD_CORE_ALLOW_ANY_EXTRA_SIZE 1
diff --git a/contrib/gdb/bfd/hosts/i860mach3.h b/contrib/gdb/bfd/hosts/i860mach3.h
deleted file mode 100644
index edd2aa10a7bb..000000000000
--- a/contrib/gdb/bfd/hosts/i860mach3.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* This file was hacked from i386mach3.h [dolan@ssd.intel.com] */
-
-#include <machine/vmparam.h>
-#include <sys/param.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. UPAGES is used only in trad-core.c.
- */
-#if UPAGES == 16
-#undef UPAGES
-#define UPAGES 2
-#endif
-
-#if UPAGES != 2
-FIXME!! UPAGES is neither 2 nor 16
-#endif
-
-#define HOST_PAGE_SIZE 1
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_i860
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/m68kaux.h b/contrib/gdb/bfd/hosts/m68kaux.h
deleted file mode 100644
index 6237755dba55..000000000000
--- a/contrib/gdb/bfd/hosts/m68kaux.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Definitions for an Apple Macintosh running A/UX 3.x. */
-
-#include <sys/param.h>
-#include <sys/page.h>
-
-/* Definitions used by trad-core.c. */
-#define NBPG NBPP
-
-#define HOST_DATA_START_ADDR u.u_exdata.ux_datorg
-#define HOST_TEXT_START_ADDR u.u_exdata.ux_txtorg
-#define HOST_STACK_END_ADDR 0x100000000
-
-#define UPAGES USIZE
-
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- (abfd->tdata.trad_core_data->u.u_arg[0])
diff --git a/contrib/gdb/bfd/hosts/m68klinux.h b/contrib/gdb/bfd/hosts/m68klinux.h
deleted file mode 100644
index 0067dfa6fda3..000000000000
--- a/contrib/gdb/bfd/hosts/m68klinux.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Linux dumps "struct task_struct" at the end of the core-file. This
- structure is currently 2512 bytes long, but we allow up to 4096
- bytes to allow for some future growth. */
-#define TRAD_CORE_EXTRA_SIZE_ALLOWED 4096
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- ((abfd)->tdata.trad_core_data->u.signal)
diff --git a/contrib/gdb/bfd/hosts/m88kmach3.h b/contrib/gdb/bfd/hosts/m88kmach3.h
deleted file mode 100644
index 421553893ec9..000000000000
--- a/contrib/gdb/bfd/hosts/m88kmach3.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <machine/vmparam.h>
-#include <sys/param.h>
-
-#undef UPAGES
-#define UPAGES 3
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_m88k
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/mipsbsd.h b/contrib/gdb/bfd/hosts/mipsbsd.h
deleted file mode 100644
index a2fad21fcf7a..000000000000
--- a/contrib/gdb/bfd/hosts/mipsbsd.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <machine/param.h>
-#include <machine/vmparam.h>
-#undef ALIGN
-
-#define HOST_PAGE_SIZE NBPG
-/* #define HOST_SEGMENT_SIZE NBPG -- we use HOST_DATA_START_ADDR */
-#define HOST_MACHINE_ARCH bfd_arch_mips
-/* #define HOST_MACHINE_MACHINE */
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
-#define NO_CORE_COMMAND
diff --git a/contrib/gdb/bfd/hosts/mipsmach3.h b/contrib/gdb/bfd/hosts/mipsmach3.h
deleted file mode 100644
index c5c468d37426..000000000000
--- a/contrib/gdb/bfd/hosts/mipsmach3.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <machine/vmparam.h>
-#include <machine/machparam.h>
-#include <sys/param.h>
-
-#define HOST_PAGE_SIZE NBPG
-/* #define HOST_SEGMENT_SIZE NBPG */
-#define HOST_MACHINE_ARCH bfd_arch_mips
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_DATA_START_ADDR USRDATA
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/news-mips.h b/contrib/gdb/bfd/hosts/news-mips.h
deleted file mode 100644
index 9e799bed9047..000000000000
--- a/contrib/gdb/bfd/hosts/news-mips.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Sony News running NewsOS 3.2. */
-
-#include <sys/param.h>
-#include <machine/vmparam.h>
-
-#define HOST_PAGE_SIZE NBPG
-
-#define HOST_MACHINE_ARCH bfd_arch_mips
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_DATA_START_ADDR USRDATA
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/news.h b/contrib/gdb/bfd/hosts/news.h
deleted file mode 100644
index bf7946cdb999..000000000000
--- a/contrib/gdb/bfd/hosts/news.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Sony News running NewsOS 3.2. */
-
-#include <machine/vmparam.h>
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_m68k
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR (KERNBASE - (UPAGES * NBPG))
diff --git a/contrib/gdb/bfd/hosts/pc532mach.h b/contrib/gdb/bfd/hosts/pc532mach.h
deleted file mode 100644
index ab96f597edd2..000000000000
--- a/contrib/gdb/bfd/hosts/pc532mach.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <machine/vmparam.h>
-#include <sys/param.h>
-
-/* This is an ugly way to hack around the incorrect
- * definition of UPAGES in ns532/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 ns532, i386 and i860. UPAGES is used only in trad-core.c.
- */
-#if UPAGES == 16
-#undef UPAGES
-#define UPAGES 2
-#endif
-
-#if UPAGES != 2
-#error UPAGES is neither 2 nor 16
-#endif
-
-#define HOST_PAGE_SIZE 1
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/riscos.h b/contrib/gdb/bfd/hosts/riscos.h
deleted file mode 100644
index 8ffa826bdcf5..000000000000
--- a/contrib/gdb/bfd/hosts/riscos.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* RISC/os 4.52C, and presumably other versions. */
-
-#include <bsd43/machine/machparam.h>
-#include <bsd43/machine/vmparam.h>
-
-#define NBPG BSD43_NBPG
-#define UPAGES BSD43_UPAGES
-#define HOST_TEXT_START_ADDR BSD43_USRTEXT
-#define HOST_DATA_START_ADDR BSD43_USRDATA
-#define HOST_STACK_END_ADDR BSD43_USRSTACK
diff --git a/contrib/gdb/bfd/hosts/symmetry.h b/contrib/gdb/bfd/hosts/symmetry.h
deleted file mode 100644
index 75717b31eb22..000000000000
--- a/contrib/gdb/bfd/hosts/symmetry.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Symmetry running either dynix 3.1 (bsd) or ptx (sysv). */
-
-#define NBPG 4096
-#define UPAGES 1
-
-#ifdef _SEQUENT_
-/* ptx */
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR 0x3fffe000
-#define TRAD_CORE_USER_OFFSET ((UPAGES * NBPG) - sizeof (struct user))
-#else
-/* dynix */
-#define HOST_TEXT_START_ADDR 0x1000
-#define HOST_DATA_START_ADDR (NBPG * u.u_tsize)
-#define HOST_STACK_END_ADDR 0x3ffff000
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
- ((core_bfd)->tdata.trad_core_data->u.u_arg[0])
-#endif
-
-#define TRAD_CORE_DSIZE_INCLUDES_TSIZE
diff --git a/contrib/gdb/bfd/hosts/tahoe.h b/contrib/gdb/bfd/hosts/tahoe.h
deleted file mode 100644
index 716cee2a171d..000000000000
--- a/contrib/gdb/bfd/hosts/tahoe.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#define NO_CORE_COMMAND
-
-#undef ALIGN /* They use it, we use it too */
-#include <machine/param.h>
-#undef ALIGN /* They use it, we use it too */
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_tahoe
-
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR (KERNBASE - (UPAGES * NBPG))
-#define HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/hosts/vaxbsd.h b/contrib/gdb/bfd/hosts/vaxbsd.h
deleted file mode 100644
index ceb9ccedfaf1..000000000000
--- a/contrib/gdb/bfd/hosts/vaxbsd.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#define NO_CORE_COMMAND /* No command name in core file */
-
-#if 0
-#undef ALIGN /* They use it, we use it too */
-/* Does not exist on BSD 4.3, it uses machine/machparam.h.
- Whatever it is, it's included by <sys/param.h>, which trad-core.c,
- the only place that uses this (I think), already includes. */
-#include <machine/param.h>
-#endif
-#undef ALIGN /* They use it, we use it too */
-
-/* Note that HOST_PAGE_SIZE -- the page size as far as executable files
- are concerned -- is not the same as NBPG, because of page clustering. */
-#define HOST_PAGE_SIZE 1024
-#define HOST_MACHINE_ARCH bfd_arch_vax
-
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR (0x80000000 - (UPAGES * NBPG))
-#undef HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/hosts/vaxult.h b/contrib/gdb/bfd/hosts/vaxult.h
deleted file mode 100644
index 13731b7479f6..000000000000
--- a/contrib/gdb/bfd/hosts/vaxult.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <machine/param.h>
-#include <machine/vmparam.h>
-#define HOST_PAGE_SIZE (NBPG*CLSIZE)
-#define HOST_MACHINE_ARCH bfd_arch_vax
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
-#undef HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/hosts/vaxult2.h b/contrib/gdb/bfd/hosts/vaxult2.h
deleted file mode 100644
index 13731b7479f6..000000000000
--- a/contrib/gdb/bfd/hosts/vaxult2.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <machine/param.h>
-#include <machine/vmparam.h>
-#define HOST_PAGE_SIZE (NBPG*CLSIZE)
-#define HOST_MACHINE_ARCH bfd_arch_vax
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
-#undef HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/hp300bsd.c b/contrib/gdb/bfd/hp300bsd.c
deleted file mode 100644
index 5767b18c179a..000000000000
--- 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 1d1acab8ae4e..000000000000
--- 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 ee893e8a57bb..000000000000
--- 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 a76ecc5aad15..000000000000
--- 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 675a5f8d0bd2..000000000000
--- 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/i386aout.c b/contrib/gdb/bfd/i386aout.c
deleted file mode 100644
index 0801832d16d7..000000000000
--- a/contrib/gdb/bfd/i386aout.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* BFD back-end for i386 a.out binaries.
- Copyright 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. */
-
-
-/* The only 386 aout system we have here is GO32 from DJ.
- These numbers make BFD work with that. If your aout 386 system
- doesn't work with these, we'll have to split them into different
- files. Send me (sac@cygnus.com) the runes to make it work on your
- system, and I'll stick it in for the next release. */
-
-#define N_HEADER_IN_TEXT(x) 0
-#define BYTES_IN_WORD 4
-
-#define N_TXTOFF(x) 0x20
-#define N_TXTADDR(x) (N_MAGIC(x)==ZMAGIC ? 0x1020 : 0)
-
-#define N_TXTSIZE(x) ((x).a_text)
-#if 0
-#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) : (SEGMENT_SIZE + ((0x1020+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
-#define NOSUBEXECB
-
-#endif
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE 0x400000
-#define DEFAULT_ARCH bfd_arch_i386
-
-#define MY(OP) CAT(i386aout_,OP)
-#define TARGETNAME "a.out-i386"
-#define NO_WRITE_HEADER_KLUDGE 1
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-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/i386bsd.c b/contrib/gdb/bfd/i386bsd.c
deleted file mode 100644
index 2328fe3e9e8c..000000000000
--- a/contrib/gdb/bfd/i386bsd.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* BFD back-end for i386 a.out binaries under BSD.
- 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. */
-
-/* This data should be correct for the format used under all the various
- BSD ports for 386 machines. */
-
-#define BYTES_IN_WORD 4
-
-/* ZMAGIC files never have the header in the text. */
-#define N_HEADER_IN_TEXT(x) 0
-
-/* ZMAGIC files start at address 0. This does not apply to QMAGIC. */
-#define TEXT_START_ADDR 0
-#define N_SHARED_LIB(x) 0
-
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-
-#define DEFAULT_ARCH bfd_arch_i386
-#define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN)
-
-#define MY(OP) CAT(i386bsd_,OP)
-#define TARGETNAME "a.out-i386-bsd"
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/i386dynix.c b/contrib/gdb/bfd/i386dynix.c
deleted file mode 100644
index ff50a1450a1c..000000000000
--- 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/i386freebsd.c b/contrib/gdb/bfd/i386freebsd.c
deleted file mode 100644
index 7a6371b5df69..000000000000
--- a/contrib/gdb/bfd/i386freebsd.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* BFD back-end for FreeBSD/386 a.out-ish binaries.
- Copyright (C) 1990, 1991, 1992, 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 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(i386freebsd_,OP)
-/* This needs to start with a.out so GDB knows it is an a.out variant. */
-#define TARGETNAME "a.out-i386-freebsd"
-
-#include "freebsd.h"
diff --git a/contrib/gdb/bfd/i386linux.c b/contrib/gdb/bfd/i386linux.c
deleted file mode 100644
index a45f97c42f80..000000000000
--- 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 2381cff02b1a..000000000000
--- 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 72a28f33bf0d..000000000000
--- 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 24a456bea23d..000000000000
--- 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 32feaa70c94e..000000000000
--- 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 fe1a021691bc..000000000000
--- 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 201f22515b3f..000000000000
--- 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/ihex.c b/contrib/gdb/bfd/ihex.c
deleted file mode 100644
index 80140da5976b..000000000000
--- a/contrib/gdb/bfd/ihex.c
+++ /dev/null
@@ -1,1005 +0,0 @@
-/* BFD back-end for Intel Hex objects.
- Copyright 1995 Free Software Foundation, Inc.
- Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This is what Intel Hex files look like:
-
-1. INTEL FORMATS
-
-A. Intel 1
-
- 16-bit address-field format, for files 64k bytes in length or less.
-
- DATA RECORD
- Byte 1 Header = colon(:)
- 2..3 The number of data bytes in hex notation
- 4..5 High byte of the record load address
- 6..7 Low byte of the record load address
- 8..9 Record type, must be "00"
- 10..x Data bytes in hex notation:
- x = (number of bytes - 1) * 2 + 11
- x+1..x+2 Checksum in hex notation
- x+3..x+4 Carriage return, line feed
-
- END RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count, must be "00"
- 4..7 Transfer-address (usually "0000")
- the jump-to address, execution start address
- 8..9 Record type, must be "01"
- 10..11 Checksum, in hex notation
- 12..13 Carriage return, line feed
-
-B. INTEL 2
-
- MCS-86 format, using a 20-bit address for files larger than 64K bytes.
-
- DATA RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count of this record, hex notation
- 4..5 High byte of the record load address
- 6..7 Low byte of the record load address
- 8..9 Record type, must be "00"
- 10..x The data bytes in hex notation:
- x = (number of data bytes - 1) * 2 + 11
- x+1..x+2 Checksum in hex notation
- x+3..x+4 Carriage return, line feed
-
- EXTENDED ADDRESS RECORD
- Byte 1 Header = colon(:)
- 2..3 The byte count, must be "02"
- 4..7 Load address, must be "0000"
- 8..9 Record type, must be "02"
- 10..11 High byte of the offset address
- 12..13 Low byte of the offset address
- 14..15 Checksum in hex notation
- 16..17 Carriage return, line feed
-
- The checksums are the two's complement of the 8-bit sum
- without carry of the byte count, offset address, and the
- record type.
-
- START ADDRESS RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count, must be "04"
- 4..7 Load address, must be "0000"
- 8..9 Record type, must be "03"
- 10..13 8086 CS value
- 14..17 8086 IP value
- 18..19 Checksum in hex notation
- 20..21 Carriage return, line feed
-
-Another document reports these additional types:
-
- EXTENDED LINEAR ADDRESS RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count, must be "02"
- 4..7 Load address, must be "0000"
- 8..9 Record type, must be "04"
- 10..13 Upper 16 bits of address of subsequent records
- 14..15 Checksum in hex notation
- 16..17 Carriage return, line feed
-
- START LINEAR ADDRESS RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count, must be "02"
- 4..7 Load address, must be "0000"
- 8..9 Record type, must be "05"
- 10..13 Upper 16 bits of start address
- 14..15 Checksum in hex notation
- 16..17 Carriage return, line feed
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libiberty.h"
-
-#include <ctype.h>
-
-static void ihex_init PARAMS ((void));
-static boolean ihex_mkobject PARAMS ((bfd *));
-static INLINE int ihex_get_byte PARAMS ((bfd *, boolean *));
-static void ihex_bad_byte PARAMS ((bfd *, unsigned int, int, boolean));
-static boolean ihex_scan PARAMS ((bfd *));
-static const bfd_target *ihex_object_p PARAMS ((bfd *));
-static boolean ihex_read_section PARAMS ((bfd *, asection *, bfd_byte *));
-static boolean ihex_get_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static boolean ihex_set_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static boolean ihex_write_record
- PARAMS ((bfd *, bfd_size_type, bfd_vma, unsigned int, bfd_byte *));
-static boolean ihex_write_object_contents PARAMS ((bfd *));
-static asymbol *ihex_make_empty_symbol PARAMS ((bfd *));
-static boolean ihex_set_arch_mach
- PARAMS ((bfd *, enum bfd_architecture, unsigned long));
-
-/* The number of bytes we put on one line during output. */
-
-#define CHUNK (21)
-
-/* Macros for converting between hex and binary. */
-
-#define NIBBLE(x) (hex_value (x))
-#define HEX2(buffer) ((NIBBLE ((buffer)[0]) << 4) + NIBBLE ((buffer)[1]))
-#define HEX4(buffer) ((HEX2 (buffer) << 8) + HEX2 ((buffer) + 2))
-#define ISHEX(x) (hex_p (x))
-
-/* When we write out an ihex value, the values can not be output as
- they are seen. Instead, we hold them in memory in this structure. */
-
-struct ihex_data_list
-{
- struct ihex_data_list *next;
- bfd_byte *data;
- bfd_vma where;
- bfd_size_type size;
-};
-
-/* The ihex tdata information. */
-
-struct ihex_data_struct
-{
- struct ihex_data_list *head;
- struct ihex_data_list *tail;
-};
-
-/* Initialize by filling in the hex conversion array. */
-
-static void
-ihex_init ()
-{
- static boolean inited;
-
- if (! inited)
- {
- inited = true;
- hex_init ();
- }
-}
-
-/* Create an ihex object. */
-
-static boolean
-ihex_mkobject (abfd)
- bfd *abfd;
-{
- if (abfd->tdata.ihex_data == NULL)
- {
- struct ihex_data_struct *tdata;
-
- tdata = ((struct ihex_data_struct *)
- bfd_alloc (abfd, sizeof (struct ihex_data_struct)));
- if (tdata == NULL)
- return false;
- abfd->tdata.ihex_data = tdata;
- tdata->head = NULL;
- tdata->tail = NULL;
- }
-
- return true;
-}
-
-/* Read a byte from a BFD. Set *ERRORPTR if an error occurred.
- Return EOF on error or end of file. */
-
-static INLINE int
-ihex_get_byte (abfd, errorptr)
- bfd *abfd;
- boolean *errorptr;
-{
- bfd_byte c;
-
- if (bfd_read (&c, 1, 1, abfd) != 1)
- {
- if (bfd_get_error () != bfd_error_file_truncated)
- *errorptr = true;
- return EOF;
- }
-
- return (int) (c & 0xff);
-}
-
-/* Report a problem in an Intel Hex file. */
-
-static void
-ihex_bad_byte (abfd, lineno, c, error)
- bfd *abfd;
- unsigned int lineno;
- int c;
- boolean error;
-{
- if (c == EOF)
- {
- if (! error)
- bfd_set_error (bfd_error_file_truncated);
- }
- else
- {
- char buf[10];
-
- if (! isprint (c))
- sprintf (buf, "\\%03o", (unsigned int) c);
- else
- {
- buf[0] = c;
- buf[1] = '\0';
- }
- (*_bfd_error_handler)
- ("%s:%d: unexpected character `%s' in Intel Hex file\n",
- bfd_get_filename (abfd), lineno, buf);
- bfd_set_error (bfd_error_bad_value);
- }
-}
-
-/* Read an Intel hex file and turn it into sections. We create a new
- section for each contiguous set of bytes. */
-
-static boolean
-ihex_scan (abfd)
- bfd *abfd;
-{
- bfd_vma segbase;
- bfd_vma extbase;
- asection *sec;
- int lineno;
- boolean error;
- bfd_byte *buf;
- size_t bufsize;
- int c;
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto error_return;
-
- abfd->start_address = 0;
-
- extbase = 0;
- segbase = 0;
- sec = NULL;
- lineno = 1;
- error = false;
- buf = NULL;
- bufsize = 0;
- while ((c = ihex_get_byte (abfd, &error)) != EOF)
- {
- if (c == '\r')
- continue;
- else if (c == '\n')
- {
- ++lineno;
- continue;
- }
- else if (c != ':')
- {
- ihex_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
- else
- {
- file_ptr pos;
- char hdr[8];
- unsigned int i;
- unsigned int len;
- bfd_vma addr;
- unsigned int type;
- unsigned int chars;
- unsigned int chksum;
-
- /* This is a data record. */
-
- pos = bfd_tell (abfd) - 1;
-
- /* Read the header bytes. */
-
- if (bfd_read (hdr, 1, 8, abfd) != 8)
- goto error_return;
-
- for (i = 0; i < 8; i++)
- {
- if (! ISHEX (hdr[i]))
- {
- ihex_bad_byte (abfd, lineno, hdr[i], error);
- goto error_return;
- }
- }
-
- len = HEX2 (hdr);
- addr = HEX4 (hdr + 2);
- type = HEX2 (hdr + 6);
-
- /* Read the data bytes. */
-
- chars = len * 2 + 2;
- if (chars >= bufsize)
- {
- buf = (bfd_byte *) bfd_realloc (buf, chars);
- if (buf == NULL)
- goto error_return;
- bufsize = chars;
- }
-
- if (bfd_read (buf, 1, chars, abfd) != chars)
- goto error_return;
-
- for (i = 0; i < chars; i++)
- {
- if (! ISHEX (buf[i]))
- {
- ihex_bad_byte (abfd, lineno, hdr[i], error);
- goto error_return;
- }
- }
-
- /* Check the checksum. */
- chksum = len + addr + (addr >> 8) + type;
- for (i = 0; i < len; i++)
- chksum += HEX2 (buf + 2 * i);
- if (((- chksum) & 0xff) != (unsigned int) HEX2 (buf + 2 * i))
- {
- (*_bfd_error_handler)
- ("%s:%d: bad checksum in Intel Hex file (expected %u, found %u)",
- bfd_get_filename (abfd), lineno,
- (- chksum) & 0xff, (unsigned int) HEX2 (buf + 2 * i));
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- switch (type)
- {
- case 0:
- /* This is a data record. */
- if (sec != NULL
- && sec->vma + sec->_raw_size == extbase + segbase + addr)
- {
- /* This data goes at the end of the section we are
- currently building. */
- sec->_raw_size += len;
- }
- else if (len > 0)
- {
- char secbuf[20];
- char *secname;
-
- sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
- secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
- if (secname == NULL)
- goto error_return;
- strcpy (secname, secbuf);
- sec = bfd_make_section (abfd, secname);
- if (sec == NULL)
- goto error_return;
- sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
- sec->vma = extbase + segbase + addr;
- sec->lma = extbase + segbase + addr;
- sec->_raw_size = len;
- sec->filepos = pos;
- }
- break;
-
- case 1:
- /* An end record. */
- if (abfd->start_address == 0)
- abfd->start_address = addr;
- if (buf != NULL)
- free (buf);
- return true;
-
- case 2:
- /* An extended address record. */
- if (len != 2)
- {
- (*_bfd_error_handler)
- ("%s:%d: bad extended address record length in Intel Hex file",
- bfd_get_filename (abfd), lineno);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- segbase = HEX4 (buf) << 4;
-
- sec = NULL;
-
- break;
-
- case 3:
- /* An extended start address record. */
- if (len != 4)
- {
- (*_bfd_error_handler)
- ("%s:%d: bad extended start address length in Intel Hex file",
- bfd_get_filename (abfd), lineno);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- abfd->start_address += (HEX4 (buf) << 4) + HEX4 (buf + 4);
-
- sec = NULL;
-
- break;
-
- case 4:
- /* An extended linear address record. */
- if (len != 2)
- {
- (*_bfd_error_handler)
- ("%s:%d: bad extended linear address record length in Intel Hex file",
- bfd_get_filename (abfd), lineno);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- segbase = HEX4 (buf) << 16;
-
- sec = NULL;
-
- break;
-
- case 5:
- /* An extended linear start address record. */
- if (len != 2)
- {
- (*_bfd_error_handler)
- ("%s:%d: bad extended linear start address length in Intel Hex file",
- bfd_get_filename (abfd), lineno);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- abfd->start_address += HEX4 (buf) << 16;
-
- sec = NULL;
-
- break;
-
- default:
- (*_bfd_error_handler)
- ("%s:%d: unrecognized ihex type %u in Intel Hex file\n",
- bfd_get_filename (abfd), lineno, type);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
- }
- }
-
- if (error)
- goto error_return;
-
- if (buf != NULL)
- free (buf);
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Try to recognize an Intel Hex file. */
-
-static const bfd_target *
-ihex_object_p (abfd)
- bfd *abfd;
-{
- bfd_byte b[9];
- unsigned int i;
- unsigned int type;
-
- ihex_init ();
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- return NULL;
- if (bfd_read (b, 1, 9, abfd) != 9)
- {
- if (bfd_get_error () == bfd_error_file_truncated)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if (b[0] != ':')
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- for (i = 1; i < 9; i++)
- {
- if (! ISHEX (b[i]))
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
- }
-
- type = HEX2 (b + 7);
- if (type > 5)
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* OK, it looks like it really is an Intel Hex file. */
-
- if (! ihex_mkobject (abfd)
- || ! ihex_scan (abfd))
- return NULL;
-
- return abfd->xvec;
-}
-
-/* Read the contents of a section in an Intel Hex file. */
-
-static boolean
-ihex_read_section (abfd, section, contents)
- bfd *abfd;
- asection *section;
- bfd_byte *contents;
-{
- int c;
- bfd_byte *p;
- bfd_byte *buf;
- size_t bufsize;
- boolean error;
-
- if (bfd_seek (abfd, section->filepos, SEEK_SET) != 0)
- goto error_return;
-
- p = contents;
- buf = NULL;
- bufsize = 0;
- error = false;
- while ((c = ihex_get_byte (abfd, &error)) != EOF)
- {
- char hdr[8];
- unsigned int len;
- bfd_vma addr;
- unsigned int type;
- unsigned int i;
-
- if (c == '\r' || c == '\n')
- continue;
-
- /* This is called after ihex_scan has succeeded, so we ought to
- know the exact format. */
- BFD_ASSERT (c == ':');
-
- if (bfd_read (hdr, 1, 8, abfd) != 8)
- goto error_return;
-
- len = HEX2 (hdr);
- addr = HEX4 (hdr + 2);
- type = HEX2 (hdr + 6);
-
- /* We should only see type 0 records here. */
- if (type != 0)
- {
- (*_bfd_error_handler)
- ("%s: internal error in ihex_read_section",
- bfd_get_filename (abfd));
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- if (len * 2 > bufsize)
- {
- buf = (bfd_byte *) bfd_realloc (buf, len * 2);
- if (buf == NULL)
- goto error_return;
- bufsize = len * 2;
- }
-
- if (bfd_read (buf, 1, len * 2, abfd) != len * 2)
- goto error_return;
-
- for (i = 0; i < len; i++)
- *p++ = HEX2 (buf + 2 * i);
- if ((bfd_size_type) (p - contents) >= section->_raw_size)
- {
- /* We've read everything in the section. */
- if (buf != NULL)
- free (buf);
- return true;
- }
-
- /* Skip the checksum. */
- if (bfd_read (buf, 1, 2, abfd) != 2)
- goto error_return;
- }
-
- if ((bfd_size_type) (p - contents) < section->_raw_size)
- {
- (*_bfd_error_handler)
- ("%s: bad section length in ihex_read_section",
- bfd_get_filename (abfd));
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- if (buf != NULL)
- free (buf);
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Get the contents of a section in an Intel Hex file. */
-
-static boolean
-ihex_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (section->used_by_bfd == NULL)
- {
- section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
- if (section->used_by_bfd == NULL)
- return false;
- if (! ihex_read_section (abfd, section, section->used_by_bfd))
- return false;
- }
-
- memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
- (size_t) count);
-
- return true;
-}
-
-/* Set the contents of a section in an Intel Hex file. */
-
-static boolean
-ihex_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- struct ihex_data_list *n;
- bfd_byte *data;
- struct ihex_data_struct *tdata;
-
- if (count == 0
- || (section->flags & SEC_ALLOC) == 0
- || (section->flags & SEC_LOAD) == 0)
- return true;
-
- n = ((struct ihex_data_list *)
- bfd_alloc (abfd, sizeof (struct ihex_data_list)));
- if (n == NULL)
- return false;
-
- data = (bfd_byte *) bfd_alloc (abfd, count);
- if (data == NULL)
- return false;
- memcpy (data, location, (size_t) count);
-
- n->data = data;
- n->where = section->lma + offset;
- n->size = count;
-
- /* Sort the records by address. Optimize for the common case of
- adding a record to the end of the list. */
- tdata = abfd->tdata.ihex_data;
- if (tdata->tail != NULL
- && n->where >= tdata->tail->where)
- {
- tdata->tail->next = n;
- n->next = NULL;
- tdata->tail = n;
- }
- else
- {
- register struct ihex_data_list **pp;
-
- for (pp = &tdata->head;
- *pp != NULL && (*pp)->where < n->where;
- pp = &(*pp)->next)
- ;
- n->next = *pp;
- *pp = n;
- if (n->next == NULL)
- tdata->tail = n;
- }
-
- return true;
-}
-
-/* Write a record out to an Intel Hex file. */
-
-static boolean
-ihex_write_record (abfd, count, addr, type, data)
- bfd *abfd;
- bfd_size_type count;
- bfd_vma addr;
- unsigned int type;
- bfd_byte *data;
-{
- static const char digs[] = "0123456789ABCDEF";
- char buf[9 + CHUNK * 2 + 4];
- char *p;
- unsigned int chksum;
- unsigned int i;
-
-#define TOHEX(buf, v) \
- ((buf)[0] = digs[((v) >> 4) & 0xf], (buf)[1] = digs[(v) & 0xf])
-
- buf[0] = ':';
- TOHEX (buf + 1, count);
- TOHEX (buf + 3, (addr >> 8) & 0xff);
- TOHEX (buf + 5, addr & 0xff);
- TOHEX (buf + 7, type);
-
- chksum = count + addr + (addr >> 8) + type;
-
- for (i = 0, p = buf + 9; i < count; i++, p += 2, data++)
- {
- TOHEX (p, *data);
- chksum += *data;
- }
-
- TOHEX (p, (- chksum) & 0xff);
- p[2] = '\r';
- p[3] = '\n';
-
- if (bfd_write (buf, 1, 9 + count * 2 + 4, abfd) != 9 + count * 2 + 4)
- return false;
-
- return true;
-}
-
-/* Write out an Intel Hex file. */
-
-static boolean
-ihex_write_object_contents (abfd)
- bfd *abfd;
-{
- bfd_vma extbase;
- bfd_vma segbase;
- struct ihex_data_list *l;
-
- extbase = 0;
- segbase = 0;
- for (l = abfd->tdata.ihex_data->head; l != NULL; l = l->next)
- {
- bfd_vma where;
- bfd_byte *p;
- bfd_size_type count;
-
- where = l->where;
- p = l->data;
- count = l->size;
- while (count > 0)
- {
- bfd_size_type now;
-
- now = count;
- if (now > CHUNK)
- now = CHUNK;
-
- if (where > extbase + segbase + 0xffff)
- {
- bfd_byte addr[2];
-
- /* We need a new base address. */
- if (where <= 0xfffff)
- {
- segbase = where & 0xf0000;
- addr[0] = (segbase >> 12) & 0xff;
- addr[1] = (segbase >> 4) & 0xff;
- if (! ihex_write_record (abfd, 2, 0, 2, addr))
- return false;
- }
- else
- {
- extbase = where & 0xffff0000;
- if (where > extbase + 0xffff)
- {
- char buf[20];
-
- sprintf_vma (buf, where);
- (*_bfd_error_handler)
- ("%s: address 0x%s out of range for Intex Hex file",
- bfd_get_filename (abfd), buf);
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- addr[0] = (extbase >> 24) & 0xff;
- addr[1] = (extbase >> 16) & 0xff;
- if (! ihex_write_record (abfd, 2, 0, 4, addr))
- return false;
- }
- }
-
- if (! ihex_write_record (abfd, now, where - (extbase + segbase),
- 0, p))
- return false;
-
- where += now;
- p += now;
- count -= now;
- }
- }
-
- if (abfd->start_address != 0)
- {
- bfd_vma start;
- bfd_byte startbuf[4];
-
- start = abfd->start_address;
-
- if (start > 0xfffff)
- {
- startbuf[0] = (start >> 24) & 0xff;
- startbuf[1] = (start >> 16) & 0xff;
- if (! ihex_write_record (abfd, 2, 0, 5, startbuf))
- return false;
- start &= 0xffff;
- }
-
- startbuf[0] = ((start & 0xf0000) >> 12) & 0xff;
- startbuf[1] = 0;
- startbuf[2] = (start >> 8) & 0xff;
- startbuf[3] = start & 0xff;
- if (! ihex_write_record (abfd, 4, 0, 3, startbuf))
- return false;
- }
-
- if (! ihex_write_record (abfd, 0, 0, 1, NULL))
- return false;
-
- return true;
-}
-
-/* Make an empty symbol. This is required only because
- bfd_make_section_anyway wants to create a symbol for the section. */
-
-static asymbol *
-ihex_make_empty_symbol (abfd)
- bfd *abfd;
-{
- asymbol *new;
-
- new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
- if (new != NULL)
- new->the_bfd = abfd;
- return new;
-}
-
-/* Set the architecture for the output file. The architecture is
- irrelevant, so we ignore errors about unknown architectures. */
-
-static boolean
-ihex_set_arch_mach (abfd, arch, mach)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long mach;
-{
- if (! bfd_default_set_arch_mach (abfd, arch, mach))
- {
- if (arch != bfd_arch_unknown)
- return false;
- }
- return true;
-}
-
-/* Get the size of the headers, for the linker. */
-
-/*ARGSUSED*/
-static int
-ihex_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-{
- return 0;
-}
-
-/* Some random definitions for the target vector. */
-
-#define ihex_close_and_cleanup _bfd_generic_close_and_cleanup
-#define ihex_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define ihex_new_section_hook _bfd_generic_new_section_hook
-#define ihex_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-#define ihex_get_symtab_upper_bound bfd_0l
-#define ihex_get_symtab \
- ((long (*) PARAMS ((bfd *, asymbol **))) bfd_0l)
-#define ihex_print_symbol _bfd_nosymbols_print_symbol
-#define ihex_get_symbol_info _bfd_nosymbols_get_symbol_info
-#define ihex_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
-#define ihex_get_lineno _bfd_nosymbols_get_lineno
-#define ihex_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define ihex_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define ihex_read_minisymbols _bfd_nosymbols_read_minisymbols
-#define ihex_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
-
-#define ihex_get_reloc_upper_bound \
- ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
-#define ihex_canonicalize_reloc \
- ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
-#define ihex_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-#define ihex_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define ihex_bfd_relax_section bfd_generic_relax_section
-#define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define ihex_bfd_final_link _bfd_generic_final_link
-#define ihex_bfd_link_split_section _bfd_generic_link_split_section
-
-/* The Intel Hex target vector. */
-
-const bfd_target ihex_vec =
-{
- "ihex", /* name */
- bfd_target_ihex_flavour,
- BFD_ENDIAN_UNKNOWN, /* target byte order */
- BFD_ENDIAN_UNKNOWN, /* target headers byte order */
- 0, /* object flags */
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD), /* 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,
- ihex_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- ihex_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- ihex_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (ihex),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (ihex),
- BFD_JUMP_TABLE_RELOCS (ihex),
- BFD_JUMP_TABLE_WRITE (ihex),
- BFD_JUMP_TABLE_LINK (ihex),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/init.c b/contrib/gdb/bfd/init.c
deleted file mode 100644
index 1fa1d505bee6..000000000000
--- a/contrib/gdb/bfd/init.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* bfd initialization stuff
- Copyright (C) 1990, 91, 92, 93, 94, 1995 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"
-
-/*
-SECTION
- Initialization
-
- These are the functions that handle initializing a BFD.
-*/
-
-/*
-FUNCTION
- bfd_init
-
-SYNOPSIS
- void bfd_init(void);
-
-DESCRIPTION
- This routine must be called before any other BFD function to
- initialize magical internal data structures.
-*/
-
-/* Actually, there is currently nothing for this function to do.
- However, someday it may be needed, so keep it around. */
-
-void
-bfd_init ()
-{
-}
diff --git a/contrib/gdb/bfd/irix-core.c b/contrib/gdb/bfd/irix-core.c
deleted file mode 100644
index 3fd39772ce84..000000000000
--- 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/libaout.h b/contrib/gdb/bfd/libaout.h
deleted file mode 100644
index 76c1dff7cdbd..000000000000
--- a/contrib/gdb/bfd/libaout.h
+++ /dev/null
@@ -1,608 +0,0 @@
-/* BFD back-end data structures for a.out (and similar) 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. */
-
-#ifndef LIBAOUT_H
-#define LIBAOUT_H
-
-/* We try to encapsulate the differences in the various a.out file
- variants in a few routines, and otherwise share large masses of code.
- This means we only have to fix bugs in one place, most of the time. */
-
-#include "bfdlink.h"
-
-/* Parameterize the a.out code based on whether it is being built
- for a 32-bit architecture or a 64-bit architecture. */
-#if ARCH_SIZE==64
-#define GET_WORD bfd_h_get_64
-#define GET_SWORD bfd_h_get_signed_64
-#define PUT_WORD bfd_h_put_64
-#ifndef NAME
-#define NAME(x,y) CAT3(x,_64_,y)
-#endif
-#define JNAME(x) CAT(x,_64)
-#define BYTES_IN_WORD 8
-#else /* ARCH_SIZE == 32 */
-#define GET_WORD bfd_h_get_32
-#define GET_SWORD bfd_h_get_signed_32
-#define PUT_WORD bfd_h_put_32
-#ifndef NAME
-#define NAME(x,y) CAT3(x,_32_,y)
-#endif
-#define JNAME(x) CAT(x,_32)
-#define BYTES_IN_WORD 4
-#endif /* ARCH_SIZE==32 */
-
-/* Declare at file level, since used in parameter lists, which have
- weird scope. */
-struct external_exec;
-struct external_nlist;
-struct reloc_ext_external;
-struct reloc_std_external;
-
-/* a.out backend linker hash table entries. */
-
-struct aout_link_hash_entry
-{
- struct bfd_link_hash_entry root;
- /* Whether this symbol has been written out. */
- boolean written;
- /* Symbol index in output file. */
- int indx;
-};
-
-/* a.out backend linker hash table. */
-
-struct aout_link_hash_table
-{
- struct bfd_link_hash_table root;
-};
-
-/* Look up an entry in an a.out link hash table. */
-
-#define aout_link_hash_lookup(table, string, create, copy, follow) \
- ((struct aout_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
-
-/* Traverse an a.out link hash table. */
-
-#define aout_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the a.out link hash table from the info structure. This is
- just a cast. */
-
-#define aout_hash_table(p) ((struct aout_link_hash_table *) ((p)->hash))
-
-/* Back-end information for various a.out targets. */
-struct aout_backend_data
-{
- /* Are ZMAGIC files mapped contiguously? If so, the text section may
- need more padding, if the segment size (granularity for memory access
- control) is larger than the page size. */
- unsigned char zmagic_mapped_contiguous;
- /* If this flag is set, ZMAGIC/NMAGIC file headers get mapped in with the
- text section, which starts immediately after the file header.
- If not, the text section starts on the next page. */
- unsigned char text_includes_header;
-
- /* The value to pass to N_SET_FLAGS. */
- unsigned char exec_hdr_flags;
-
- /* If the text section VMA isn't specified, and we need an absolute
- address, use this as the default. If we're producing a relocatable
- file, zero is always used. */
- /* ?? Perhaps a callback would be a better choice? Will this do anything
- reasonable for a format that handles multiple CPUs with different
- load addresses for each? */
- bfd_vma default_text_vma;
-
- /* Callback for setting the page and segment sizes, if they can't be
- trivially determined from the architecture. */
- boolean (*set_sizes) PARAMS ((bfd *));
-
- /* zmagic files only. For go32, the length of the exec header contributes
- to the size of the text section in the file for alignment purposes but
- does *not* get counted in the length of the text section. */
- unsigned char exec_header_not_counted;
-
- /* Callback from the add symbols phase of the linker code to handle
- a dynamic object. */
- boolean (*add_dynamic_symbols) PARAMS ((bfd *, struct bfd_link_info *,
- struct external_nlist **,
- bfd_size_type *, char **));
-
- /* Callback from the add symbols phase of the linker code to handle
- adding a single symbol to the global linker hash table. */
- boolean (*add_one_symbol) PARAMS ((struct bfd_link_info *, bfd *,
- const char *, flagword, asection *,
- bfd_vma, const char *, boolean,
- boolean,
- struct bfd_link_hash_entry **));
-
- /* Called to handle linking a dynamic object. */
- boolean (*link_dynamic_object) PARAMS ((struct bfd_link_info *, bfd *));
-
- /* Called for each global symbol being written out by the linker.
- This should write out the dynamic symbol information. */
- boolean (*write_dynamic_symbol) PARAMS ((bfd *, struct bfd_link_info *,
- struct aout_link_hash_entry *));
-
- /* If this callback is not NULL, the linker calls it for each reloc.
- RELOC is a pointer to the unswapped reloc. If *SKIP is set to
- true, the reloc will be skipped. *RELOCATION may be changed to
- change the effects of the relocation. */
- boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *info,
- bfd *input_bfd,
- asection *input_section,
- struct aout_link_hash_entry *h,
- PTR reloc, bfd_byte *contents,
- boolean *skip,
- bfd_vma *relocation));
-
- /* Called at the end of a link to finish up any dynamic linking
- information. */
- boolean (*finish_dynamic_link) PARAMS ((bfd *, struct bfd_link_info *));
-};
-#define aout_backend_info(abfd) \
- ((CONST struct aout_backend_data *)((abfd)->xvec->backend_data))
-
-/* This is the layout in memory of a "struct exec" while we process it.
- All 'lengths' are given as a number of bytes.
- All 'alignments' are for relinkable files only; an alignment of
- 'n' indicates the corresponding segment must begin at an
- address that is a multiple of (2**n). */
-
-struct internal_exec
-{
- long a_info; /* Magic number and flags, packed */
- bfd_vma a_text; /* length of text, in bytes */
- bfd_vma a_data; /* length of data, in bytes */
- bfd_vma a_bss; /* length of uninitialized data area in mem */
- bfd_vma a_syms; /* length of symbol table data in file */
- bfd_vma a_entry; /* start address */
- bfd_vma a_trsize; /* length of text's relocation info, in bytes */
- bfd_vma a_drsize; /* length of data's relocation info, in bytes */
- /* Added for i960 */
- bfd_vma a_tload; /* Text runtime load address */
- bfd_vma a_dload; /* Data runtime load address */
- unsigned char a_talign; /* Alignment of text segment */
- unsigned char a_dalign; /* Alignment of data segment */
- unsigned char a_balign; /* Alignment of bss segment */
- char a_relaxable; /* Enough info for linker relax */
-};
-
-/* Magic number is written
-< MSB >
-3130292827262524232221201918171615141312111009080706050403020100
-< FLAGS >< MACHINE TYPE >< MAGIC NUMBER >
-*/
-/* Magic number for NetBSD is
-<MSB >
-3130292827262524232221201918171615141312111009080706050403020100
-< FLAGS >< >< MAGIC NUMBER >
-*/
-
-enum machine_type {
- M_UNKNOWN = 0,
- M_68010 = 1,
- M_68020 = 2,
- M_SPARC = 3,
- /* skip a bunch so we don't run into any of suns numbers */
- /* make these up for the ns32k*/
- M_NS32032 = (64), /* ns32032 running ? */
- M_NS32532 = (64 + 5), /* ns32532 running mach */
-
- M_386 = 100,
- M_29K = 101, /* AMD 29000 */
- M_386_DYNIX = 102, /* Sequent running dynix */
- M_ARM = 103, /* Advanced Risc Machines ARM */
- M_386_NETBSD = 134, /* NetBSD/i386 binary */
- M_68K_NETBSD = 135, /* NetBSD/m68k binary */
- M_68K4K_NETBSD = 136, /* NetBSD/m68k4k binary */
- M_532_NETBSD = 137, /* NetBSD/ns32k binary */
- M_SPARC_NETBSD = 138, /* NetBSD/sparc binary */
- M_MIPS1 = 151, /* MIPS R2000/R3000 binary */
- M_MIPS2 = 152, /* MIPS R4000/R6000 binary */
- M_HP200 = 200, /* HP 200 (68010) BSD binary */
- M_HP300 = (300 % 256), /* HP 300 (68020+68881) BSD binary */
- M_HPUX = (0x20c % 256)/* HP 200/300 HPUX binary */
-};
-
-#define N_DYNAMIC(exec) ((exec).a_info & 0x80000000)
-
-#ifndef N_MAGIC
-# define N_MAGIC(exec) ((exec).a_info & 0xffff)
-#endif
-
-#ifndef N_MACHTYPE
-# define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
-#endif
-
-#ifndef N_FLAGS
-# define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
-#endif
-
-#ifndef N_SET_INFO
-# define N_SET_INFO(exec, magic, type, flags) \
-((exec).a_info = ((magic) & 0xffff) \
- | (((int)(type) & 0xff) << 16) \
- | (((flags) & 0xff) << 24))
-#endif
-
-#ifndef N_SET_DYNAMIC
-# define N_SET_DYNAMIC(exec, dynamic) \
-((exec).a_info = (dynamic) ? ((exec).a_info | 0x80000000) : \
-((exec).a_info & 0x7fffffff))
-#endif
-
-#ifndef N_SET_MAGIC
-# define N_SET_MAGIC(exec, magic) \
-((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
-#endif
-
-#ifndef N_SET_MACHTYPE
-# define N_SET_MACHTYPE(exec, machtype) \
-((exec).a_info = \
- ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
-#endif
-
-#ifndef N_SET_FLAGS
-# define N_SET_FLAGS(exec, flags) \
-((exec).a_info = \
- ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
-#endif
-
-typedef struct aout_symbol {
- asymbol symbol;
- short desc;
- char other;
- unsigned char type;
-} aout_symbol_type;
-
-/* The `tdata' struct for all a.out-like object file formats.
- Various things depend on this struct being around any time an a.out
- file is being handled. An example is dbxread.c in GDB. */
-
-struct aoutdata {
- struct internal_exec *hdr; /* exec file header */
- aout_symbol_type *symbols; /* symtab for input bfd */
-
- /* For ease, we do this */
- asection *textsec;
- asection *datasec;
- asection *bsssec;
-
- /* We remember these offsets so that after check_file_format, we have
- no dependencies on the particular format of the exec_hdr. */
- file_ptr sym_filepos;
- file_ptr str_filepos;
-
- /* Size of a relocation entry in external form */
- unsigned reloc_entry_size;
-
- /* Size of a symbol table entry in external form */
- unsigned symbol_entry_size;
-
- /* Page size - needed for alignment of demand paged files. */
- unsigned long page_size;
-
- /* Segment size - needed for alignment of demand paged files. */
- unsigned long segment_size;
-
- /* Zmagic disk block size - need to align the start of the text
- section in ZMAGIC binaries. Normally the same as page_size. */
- unsigned long zmagic_disk_block_size;
-
- unsigned exec_bytes_size;
- unsigned vma_adjusted : 1;
-
- /* used when a bfd supports several highly similar formats */
- enum
- {
- default_format = 0,
- /* Used on HP 9000/300 running HP/UX. See hp300hpux.c. */
- gnu_encap_format,
- /* Used on Linux, 386BSD, etc. See include/aout/aout64.h. */
- q_magic_format
- } subformat;
-
- enum
- {
- undecided_magic = 0,
- z_magic,
- o_magic,
- n_magic
- } magic;
-
- /* A buffer for find_nearest_line. */
- char *line_buf;
-
- /* The external symbol information. */
- struct external_nlist *external_syms;
- bfd_size_type external_sym_count;
- bfd_window sym_window;
- char *external_strings;
- bfd_size_type external_string_size;
- bfd_window string_window;
- struct aout_link_hash_entry **sym_hashes;
-
- /* A pointer for shared library information. */
- PTR dynamic_info;
-
- /* A mapping from local symbols to offsets into the global offset
- table, used when linking on SunOS. This is indexed by the symbol
- index. */
- bfd_vma *local_got_offsets;
-};
-
-struct aout_data_struct {
- struct aoutdata a;
- struct internal_exec e;
-};
-
-#define adata(bfd) ((bfd)->tdata.aout_data->a)
-#define exec_hdr(bfd) (adata(bfd).hdr)
-#define obj_aout_symbols(bfd) (adata(bfd).symbols)
-#define obj_textsec(bfd) (adata(bfd).textsec)
-#define obj_datasec(bfd) (adata(bfd).datasec)
-#define obj_bsssec(bfd) (adata(bfd).bsssec)
-#define obj_sym_filepos(bfd) (adata(bfd).sym_filepos)
-#define obj_str_filepos(bfd) (adata(bfd).str_filepos)
-#define obj_reloc_entry_size(bfd) (adata(bfd).reloc_entry_size)
-#define obj_symbol_entry_size(bfd) (adata(bfd).symbol_entry_size)
-#define obj_aout_subformat(bfd) (adata(bfd).subformat)
-#define obj_aout_external_syms(bfd) (adata(bfd).external_syms)
-#define obj_aout_external_sym_count(bfd) (adata(bfd).external_sym_count)
-#define obj_aout_sym_window(bfd) (adata(bfd).sym_window)
-#define obj_aout_external_strings(bfd) (adata(bfd).external_strings)
-#define obj_aout_external_string_size(bfd) (adata(bfd).external_string_size)
-#define obj_aout_string_window(bfd) (adata(bfd).string_window)
-#define obj_aout_sym_hashes(bfd) (adata(bfd).sym_hashes)
-#define obj_aout_dynamic_info(bfd) (adata(bfd).dynamic_info)
-
-/* We take the address of the first element of an asymbol to ensure that the
- macro is only ever applied to an asymbol */
-#define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd))
-
-/* Information we keep for each a.out section. This is currently only
- used by the a.out backend linker. */
-
-struct aout_section_data_struct
-{
- /* The unswapped relocation entries for this section. */
- PTR relocs;
-};
-
-#define aout_section_data(s) \
- ((struct aout_section_data_struct *) (s)->used_by_bfd)
-
-#define set_aout_section_data(s,v) \
- ((s)->used_by_bfd = (PTR)&(v)->relocs)
-
-/* Prototype declarations for functions defined in aoutx.h */
-
-boolean
-NAME(aout,squirt_out_relocs) PARAMS ((bfd *abfd, asection *section));
-
-boolean
-NAME(aout,make_sections) PARAMS ((bfd *));
-
-const bfd_target *
-NAME(aout,some_aout_object_p) PARAMS ((bfd *abfd,
- struct internal_exec *execp,
- const bfd_target *(*callback)(bfd *)));
-
-boolean
-NAME(aout,mkobject) PARAMS ((bfd *abfd));
-
-enum machine_type
-NAME(aout,machine_type) PARAMS ((enum bfd_architecture arch,
- unsigned long machine,
- boolean *unknown));
-
-boolean
-NAME(aout,set_arch_mach) PARAMS ((bfd *abfd, enum bfd_architecture arch,
- unsigned long machine));
-
-boolean
-NAME(aout,new_section_hook) PARAMS ((bfd *abfd, asection *newsect));
-
-boolean
-NAME(aout,set_section_contents) PARAMS ((bfd *abfd, sec_ptr section,
- PTR location, file_ptr offset, bfd_size_type count));
-
-asymbol *
-NAME(aout,make_empty_symbol) PARAMS ((bfd *abfd));
-
-boolean
-NAME(aout,translate_symbol_table) PARAMS ((bfd *, aout_symbol_type *,
- struct external_nlist *,
- bfd_size_type, char *,
- bfd_size_type,
- boolean dynamic));
-
-boolean
-NAME(aout,slurp_symbol_table) PARAMS ((bfd *abfd));
-
-boolean
-NAME(aout,write_syms) PARAMS ((bfd *abfd));
-
-void
-NAME(aout,reclaim_symbol_table) PARAMS ((bfd *abfd));
-
-long
-NAME(aout,get_symtab_upper_bound) PARAMS ((bfd *abfd));
-
-long
-NAME(aout,get_symtab) PARAMS ((bfd *abfd, asymbol **location));
-
-void
-NAME(aout,swap_ext_reloc_in) PARAMS ((bfd *, struct reloc_ext_external *,
- arelent *, asymbol **, bfd_size_type));
-void
-NAME(aout,swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
- arelent *, asymbol **, bfd_size_type));
-
-reloc_howto_type *
-NAME(aout,reloc_type_lookup) PARAMS ((bfd *abfd,
- bfd_reloc_code_real_type code));
-
-boolean
-NAME(aout,slurp_reloc_table) PARAMS ((bfd *abfd, sec_ptr asect,
- asymbol **symbols));
-
-long
-NAME(aout,canonicalize_reloc) PARAMS ((bfd *abfd, sec_ptr section,
- arelent **relptr, asymbol **symbols));
-
-long
-NAME(aout,get_reloc_upper_bound) PARAMS ((bfd *abfd, sec_ptr asect));
-
-void
-NAME(aout,reclaim_reloc) PARAMS ((bfd *ignore_abfd, sec_ptr ignore));
-
-alent *
-NAME(aout,get_lineno) PARAMS ((bfd *ignore_abfd, asymbol *ignore_symbol));
-
-void
-NAME(aout,print_symbol) PARAMS ((bfd *ignore_abfd, PTR file,
- asymbol *symbol, bfd_print_symbol_type how));
-
-void
-NAME(aout,get_symbol_info) PARAMS ((bfd *ignore_abfd,
- asymbol *symbol, symbol_info *ret));
-
-boolean
-NAME(aout,find_nearest_line) PARAMS ((bfd *abfd, asection *section,
- asymbol **symbols, bfd_vma offset, CONST char **filename_ptr,
- CONST char **functionname_ptr, unsigned int *line_ptr));
-
-long
-NAME(aout,read_minisymbols) PARAMS ((bfd *, boolean, PTR *, unsigned int *));
-
-asymbol *
-NAME(aout,minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
- asymbol *));
-
-int
-NAME(aout,sizeof_headers) PARAMS ((bfd *abfd, boolean exec));
-
-boolean
-NAME(aout,adjust_sizes_and_vmas) PARAMS ((bfd *abfd,
- bfd_size_type *text_size, file_ptr *text_end));
-
-void
-NAME(aout,swap_exec_header_in) PARAMS ((bfd *abfd,
- struct external_exec *raw_bytes, struct internal_exec *execp));
-
-void
-NAME(aout,swap_exec_header_out) PARAMS ((bfd *abfd,
- struct internal_exec *execp, struct external_exec *raw_bytes));
-
-struct bfd_hash_entry *
-NAME(aout,link_hash_newfunc)
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-
-boolean
-NAME(aout,link_hash_table_init)
- PARAMS ((struct aout_link_hash_table *, bfd *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-struct bfd_link_hash_table *
-NAME(aout,link_hash_table_create) PARAMS ((bfd *));
-
-boolean
-NAME(aout,link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
-
-boolean
-NAME(aout,final_link) PARAMS ((bfd *, struct bfd_link_info *,
- void (*) (bfd *, file_ptr *, file_ptr *,
- file_ptr *)));
-
-boolean
-NAME(aout,bfd_free_cached_info) PARAMS ((bfd *));
-
-/* A.out uses the generic versions of these routines... */
-
-#define aout_32_get_section_contents _bfd_generic_get_section_contents
-
-#define aout_64_get_section_contents _bfd_generic_get_section_contents
-#ifndef NO_WRITE_HEADER_KLUDGE
-#define NO_WRITE_HEADER_KLUDGE 0
-#endif
-
-#ifndef aout_32_bfd_is_local_label
-#define aout_32_bfd_is_local_label bfd_generic_is_local_label
-#endif
-
-#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_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 (!NAME(aout,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; \
- } \
- }
-#endif
-
-#endif /* ! defined (LIBAOUT_H) */
diff --git a/contrib/gdb/bfd/libbfd-in.h b/contrib/gdb/bfd/libbfd-in.h
deleted file mode 100644
index 14935ebbeabc..000000000000
--- 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/libbfd.c b/contrib/gdb/bfd/libbfd.c
deleted file mode 100644
index 1052a3a17be5..000000000000
--- a/contrib/gdb/bfd/libbfd.c
+++ /dev/null
@@ -1,1197 +0,0 @@
-/* Assorted BFD support routines, only used internally.
- 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"
-
-static int real_read PARAMS ((PTR, size_t, size_t, FILE *));
-
-/*
-SECTION
- Internal functions
-
-DESCRIPTION
- These routines are used within BFD.
- They are not intended for export, but are documented here for
- completeness.
-*/
-
-/* A routine which is used in target vectors for unsupported
- operations. */
-
-/*ARGSUSED*/
-boolean
-bfd_false (ignore)
- bfd *ignore;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return false;
-}
-
-/* A routine which is used in target vectors for supported operations
- which do not actually do anything. */
-
-/*ARGSUSED*/
-boolean
-bfd_true (ignore)
- bfd *ignore;
-{
- return true;
-}
-
-/* A routine which is used in target vectors for unsupported
- operations which return a pointer value. */
-
-/*ARGSUSED*/
-PTR
-bfd_nullvoidptr (ignore)
- bfd *ignore;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
-}
-
-/*ARGSUSED*/
-int
-bfd_0 (ignore)
- bfd *ignore;
-{
- return 0;
-}
-
-/*ARGSUSED*/
-unsigned int
-bfd_0u (ignore)
- bfd *ignore;
-{
- return 0;
-}
-
-/*ARGUSED*/
-long
-bfd_0l (ignore)
- bfd *ignore;
-{
- return 0;
-}
-
-/* A routine which is used in target vectors for unsupported
- operations which return -1 on error. */
-
-/*ARGSUSED*/
-long
-_bfd_n1 (ignore_abfd)
- bfd *ignore_abfd;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
-}
-
-/*ARGSUSED*/
-void
-bfd_void (ignore)
- bfd *ignore;
-{
-}
-
-/*ARGSUSED*/
-boolean
-_bfd_nocore_core_file_matches_executable_p (ignore_core_bfd, ignore_exec_bfd)
- bfd *ignore_core_bfd;
- bfd *ignore_exec_bfd;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return false;
-}
-
-/* Routine to handle core_file_failing_command entry point for targets
- without core file support. */
-
-/*ARGSUSED*/
-char *
-_bfd_nocore_core_file_failing_command (ignore_abfd)
- bfd *ignore_abfd;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return (char *)NULL;
-}
-
-/* Routine to handle core_file_failing_signal entry point for targets
- without core file support. */
-
-/*ARGSUSED*/
-int
-_bfd_nocore_core_file_failing_signal (ignore_abfd)
- bfd *ignore_abfd;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return 0;
-}
-
-/*ARGSUSED*/
-const bfd_target *
-_bfd_dummy_target (ignore_abfd)
- bfd *ignore_abfd;
-{
- bfd_set_error (bfd_error_wrong_format);
- return 0;
-}
-
-/* Allocate memory using malloc. */
-
-PTR
-bfd_malloc (size)
- size_t size;
-{
- PTR ptr;
-
- ptr = (PTR) malloc (size);
- if (ptr == NULL && size != 0)
- bfd_set_error (bfd_error_no_memory);
- return ptr;
-}
-
-/* Reallocate memory using realloc. */
-
-PTR
-bfd_realloc (ptr, size)
- PTR ptr;
- size_t size;
-{
- PTR ret;
-
- if (ptr == NULL)
- ret = malloc (size);
- else
- ret = realloc (ptr, size);
-
- if (ret == NULL)
- bfd_set_error (bfd_error_no_memory);
-
- return ret;
-}
-
-/* Allocate memory using malloc and clear it. */
-
-PTR
-bfd_zmalloc (size)
- size_t size;
-{
- PTR ptr;
-
- ptr = (PTR) malloc (size);
-
- if (size != 0)
- {
- if (ptr == NULL)
- bfd_set_error (bfd_error_no_memory);
- else
- memset (ptr, 0, size);
- }
-
- return ptr;
-}
-
-/* Some IO code */
-
-
-/* Note that archive entries don't have streams; they share their parent's.
- This allows someone to play with the iostream behind BFD's back.
-
- Also, note that the origin pointer points to the beginning of a file's
- contents (0 for non-archive elements). For archive entries this is the
- first octet in the file, NOT the beginning of the archive header. */
-
-static int
-real_read (where, a,b, file)
- PTR where;
- size_t a;
- size_t b;
- FILE *file;
-{
- return fread (where, a, b, file);
-}
-
-/* Return value is amount read (FIXME: how are errors and end of file dealt
- with? We never call bfd_set_error, which is probably a mistake). */
-
-bfd_size_type
-bfd_read (ptr, size, nitems, abfd)
- PTR ptr;
- bfd_size_type size;
- bfd_size_type nitems;
- bfd *abfd;
-{
- int nread;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- {
- struct bfd_in_memory *bim;
- bfd_size_type get;
-
- bim = (struct bfd_in_memory *) abfd->iostream;
- get = size * nitems;
- if (abfd->where + get > bim->size)
- {
- get = bim->size - abfd->where;
- bfd_set_error (bfd_error_file_truncated);
- }
- memcpy (ptr, bim->buffer + abfd->where, get);
- abfd->where += get;
- return get;
- }
-
- nread = real_read (ptr, 1, (size_t)(size*nitems), bfd_cache_lookup(abfd));
-#ifdef FILE_OFFSET_IS_CHAR_INDEX
- if (nread > 0)
- abfd->where += nread;
-#endif
-
- /* Set bfd_error if we did not read as much data as we expected.
-
- If the read failed due to an error set the bfd_error_system_call,
- else set bfd_error_file_truncated.
-
- A BFD backend may wish to override bfd_error_file_truncated to
- provide something more useful (eg. no_symbols or wrong_format). */
- if (nread < (int)(size * nitems))
- {
- if (ferror (bfd_cache_lookup (abfd)))
- bfd_set_error (bfd_error_system_call);
- else
- bfd_set_error (bfd_error_file_truncated);
- }
-
- return nread;
-}
-
-/* The window support stuff should probably be broken out into
- another file.... */
-/* The idea behind the next and refcount fields is that one mapped
- region can suffice for multiple read-only windows or multiple
- non-overlapping read-write windows. It's not implemented yet
- though. */
-struct _bfd_window_internal {
- struct _bfd_window_internal *next;
- PTR data;
- bfd_size_type size;
- int refcount : 31; /* should be enough... */
- unsigned mapped : 1; /* 1 = mmap, 0 = malloc */
-};
-
-void
-bfd_init_window (windowp)
- bfd_window *windowp;
-{
- windowp->data = 0;
- windowp->i = 0;
- windowp->size = 0;
-}
-
-#undef HAVE_MPROTECT /* code's not tested yet */
-
-#if HAVE_MMAP || HAVE_MPROTECT || HAVE_MADVISE
-#include <sys/types.h>
-#include <sys/mman.h>
-#endif
-
-#ifndef MAP_FILE
-#define MAP_FILE 0
-#endif
-
-static int debug_windows;
-
-/* Currently, if USE_MMAP is undefined, none if the window stuff is
- used. Okay, so it's mis-named. At least the command-line option
- "--without-mmap" is more obvious than "--without-windows" or some
- such. */
-#ifdef USE_MMAP
-
-void
-bfd_free_window (windowp)
- bfd_window *windowp;
-{
- bfd_window_internal *i = windowp->i;
- windowp->i = 0;
- windowp->data = 0;
- if (i == 0)
- return;
- i->refcount--;
- if (debug_windows)
- fprintf (stderr, "freeing window @%p<%p,%lx,%p>\n",
- windowp, windowp->data, windowp->size, windowp->i);
- if (i->refcount != 0)
- return;
-
- if (i->mapped)
- {
-#ifdef HAVE_MMAP
- munmap (i->data, i->size);
- goto no_free;
-#else
- abort ();
-#endif
- }
-#ifdef HAVE_MPROTECT
- mprotect (i->data, i->size, PROT_READ | PROT_WRITE);
-#endif
- free (i->data);
-#ifdef HAVE_MMAP
- no_free:
-#endif
- i->data = 0;
- /* There should be no more references to i at this point. */
- free (i);
-}
-#endif
-
-static int ok_to_map = 1;
-
-boolean
-bfd_get_file_window (abfd, offset, size, windowp, writable)
- bfd *abfd;
- file_ptr offset;
- bfd_size_type size;
- bfd_window *windowp;
- boolean writable;
-{
- static size_t pagesize;
- bfd_window_internal *i = windowp->i;
- size_t size_to_alloc = size;
-
-#ifndef USE_MMAP
- abort ();
-#endif
-
- if (debug_windows)
- fprintf (stderr, "bfd_get_file_window (%p, %6ld, %6ld, %p<%p,%lx,%p>, %d)",
- abfd, (long) offset, (long) size,
- windowp, windowp->data, windowp->size, windowp->i,
- writable);
-
- /* Make sure we know the page size, so we can be friendly to mmap. */
- if (pagesize == 0)
- pagesize = getpagesize ();
- if (pagesize == 0)
- abort ();
-
- if (i == 0)
- {
- windowp->i = i = (bfd_window_internal *) bfd_zmalloc (sizeof (bfd_window_internal));
- if (i == 0)
- return false;
- i->data = 0;
- }
-#ifdef HAVE_MMAP
- if (ok_to_map
- && (i->data == 0 || i->mapped == 1)
- && (abfd->flags & BFD_IN_MEMORY) == 0)
- {
- file_ptr file_offset, offset2;
- size_t real_size;
- int fd;
- FILE *f;
-
- /* Find the real file and the real offset into it. */
- while (abfd->my_archive != NULL)
- {
- offset += abfd->origin;
- abfd = abfd->my_archive;
- }
- f = bfd_cache_lookup (abfd);
- fd = fileno (f);
-
- /* Compute offsets and size for mmap and for the user's data. */
- offset2 = offset % pagesize;
- if (offset2 < 0)
- abort ();
- file_offset = offset - offset2;
- real_size = offset + size - file_offset;
- real_size = real_size + pagesize - 1;
- real_size -= real_size % pagesize;
-
- /* If we're re-using a memory region, make sure it's big enough. */
- if (i->data && i->size < size)
- {
- munmap (i->data, i->size);
- i->data = 0;
- }
- i->data = mmap (i->data, real_size,
- writable ? PROT_WRITE | PROT_READ : PROT_READ,
- (writable
- ? MAP_FILE | MAP_PRIVATE
- : MAP_FILE | MAP_SHARED),
- fd, file_offset);
- if (i->data == (PTR) -1)
- {
- /* An error happened. Report it, or try using malloc, or
- something. */
- bfd_set_error (bfd_error_system_call);
- i->data = 0;
- windowp->data = 0;
- if (debug_windows)
- fprintf (stderr, "\t\tmmap failed!\n");
- return false;
- }
- if (debug_windows)
- fprintf (stderr, "\n\tmapped %ld at %p, offset is %ld\n",
- (long) real_size, i->data, (long) offset2);
- i->size = real_size;
- windowp->data = (PTR) ((bfd_byte *) i->data + offset2);
- windowp->size = size;
- i->mapped = 1;
- return true;
- }
- else if (debug_windows)
- {
- if (ok_to_map)
- fprintf (stderr, "not mapping: data=%lx mapped=%d\n",
- (unsigned long) i->data, (int) i->mapped);
- else
- fprintf (stderr, "not mapping: env var not set\n");
- }
-#else
- ok_to_map = 0;
-#endif
-
-#ifdef HAVE_MPROTECT
- if (!writable)
- {
- size_to_alloc += pagesize - 1;
- size_to_alloc -= size_to_alloc % pagesize;
- }
-#endif
- if (debug_windows)
- fprintf (stderr, "\n\t%s(%6ld)",
- i->data ? "realloc" : " malloc", (long) size_to_alloc);
- i->data = (PTR) bfd_realloc (i->data, size_to_alloc);
- if (debug_windows)
- fprintf (stderr, "\t-> %p\n", i->data);
- i->refcount = 1;
- if (i->data == NULL)
- {
- if (size_to_alloc == 0)
- return true;
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (bfd_seek (abfd, offset, SEEK_SET) != 0)
- return false;
- i->size = bfd_read (i->data, size, 1, abfd);
- if (i->size != size)
- return false;
- i->mapped = 0;
-#ifdef HAVE_MPROTECT
- if (!writable)
- {
- if (debug_windows)
- fprintf (stderr, "\tmprotect (%p, %ld, PROT_READ)\n", i->data,
- (long) i->size);
- mprotect (i->data, i->size, PROT_READ);
- }
-#endif
- windowp->data = i->data;
- windowp->size = i->size;
- return true;
-}
-
-bfd_size_type
-bfd_write (ptr, size, nitems, abfd)
- CONST PTR ptr;
- bfd_size_type size;
- bfd_size_type nitems;
- bfd *abfd;
-{
- long nwrote;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- abort ();
-
- nwrote = fwrite (ptr, 1, (size_t) (size * nitems),
- bfd_cache_lookup (abfd));
-#ifdef FILE_OFFSET_IS_CHAR_INDEX
- if (nwrote > 0)
- abfd->where += nwrote;
-#endif
- if ((bfd_size_type) nwrote != size * nitems)
- {
-#ifdef ENOSPC
- if (nwrote >= 0)
- errno = ENOSPC;
-#endif
- bfd_set_error (bfd_error_system_call);
- }
- return nwrote;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_write_bigendian_4byte_int
-
-SYNOPSIS
- void bfd_write_bigendian_4byte_int(bfd *abfd, int i);
-
-DESCRIPTION
- Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big
- endian order regardless of what else is going on. This is useful in
- archives.
-
-*/
-void
-bfd_write_bigendian_4byte_int (abfd, i)
- bfd *abfd;
- int i;
-{
- bfd_byte buffer[4];
- bfd_putb32(i, buffer);
- if (bfd_write((PTR)buffer, 4, 1, abfd) != 4)
- abort ();
-}
-
-long
-bfd_tell (abfd)
- bfd *abfd;
-{
- file_ptr ptr;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- return abfd->where;
-
- ptr = ftell (bfd_cache_lookup(abfd));
-
- if (abfd->my_archive)
- ptr -= abfd->origin;
- abfd->where = ptr;
- return ptr;
-}
-
-int
-bfd_flush (abfd)
- bfd *abfd;
-{
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- return 0;
- return fflush (bfd_cache_lookup(abfd));
-}
-
-/* Returns 0 for success, negative value for failure (in which case
- bfd_get_error can retrieve the error code). */
-int
-bfd_stat (abfd, statbuf)
- bfd *abfd;
- struct stat *statbuf;
-{
- FILE *f;
- int result;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- abort ();
-
- f = bfd_cache_lookup (abfd);
- if (f == NULL)
- {
- bfd_set_error (bfd_error_system_call);
- return -1;
- }
- result = fstat (fileno (f), statbuf);
- if (result < 0)
- bfd_set_error (bfd_error_system_call);
- return result;
-}
-
-/* Returns 0 for success, nonzero for failure (in which case bfd_get_error
- can retrieve the error code). */
-
-int
-bfd_seek (abfd, position, direction)
- bfd *abfd;
- file_ptr position;
- int direction;
-{
- int result;
- FILE *f;
- file_ptr file_position;
- /* For the time being, a BFD may not seek to it's end. The problem
- is that we don't easily have a way to recognize the end of an
- element in an archive. */
-
- BFD_ASSERT (direction == SEEK_SET || direction == SEEK_CUR);
-
- if (direction == SEEK_CUR && position == 0)
- return 0;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- {
- if (direction == SEEK_SET)
- abfd->where = position;
- else
- abfd->where += position;
- return 0;
- }
-
-#ifdef FILE_OFFSET_IS_CHAR_INDEX
- if (abfd->format != bfd_archive && abfd->my_archive == 0)
- {
-#if 0
- /* Explanation for this code: I'm only about 95+% sure that the above
- conditions are sufficient and that all i/o calls are properly
- adjusting the `where' field. So this is sort of an `assert'
- that the `where' field is correct. If we can go a while without
- tripping the abort, we can probably safely disable this code,
- so that the real optimizations happen. */
- file_ptr where_am_i_now;
- where_am_i_now = ftell (bfd_cache_lookup (abfd));
- if (abfd->my_archive)
- where_am_i_now -= abfd->origin;
- if (where_am_i_now != abfd->where)
- abort ();
-#endif
- if (direction == SEEK_SET && position == abfd->where)
- return 0;
- }
- else
- {
- /* We need something smarter to optimize access to archives.
- Currently, anything inside an archive is read via the file
- handle for the archive. Which means that a bfd_seek on one
- component affects the `current position' in the archive, as
- well as in any other component.
-
- It might be sufficient to put a spike through the cache
- abstraction, and look to the archive for the file position,
- but I think we should try for something cleaner.
-
- In the meantime, no optimization for archives. */
- }
-#endif
-
- f = bfd_cache_lookup (abfd);
- file_position = position;
- if (direction == SEEK_SET && abfd->my_archive != NULL)
- file_position += abfd->origin;
-
- result = fseek (f, file_position, direction);
-
- if (result != 0)
- {
- /* Force redetermination of `where' field. */
- bfd_tell (abfd);
- bfd_set_error (bfd_error_system_call);
- }
- else
- {
-#ifdef FILE_OFFSET_IS_CHAR_INDEX
- /* Adjust `where' field. */
- if (direction == SEEK_SET)
- abfd->where = position;
- else
- abfd->where += position;
-#endif
- }
- return result;
-}
-
-/** The do-it-yourself (byte) sex-change kit */
-
-/* The middle letter e.g. get<b>short indicates Big or Little endian
- target machine. It doesn't matter what the byte order of the host
- machine is; these routines work for either. */
-
-/* FIXME: Should these take a count argument?
- Answer (gnu@cygnus.com): No, but perhaps they should be inline
- functions in swap.h #ifdef __GNUC__.
- Gprof them later and find out. */
-
-/*
-FUNCTION
- bfd_put_size
-FUNCTION
- bfd_get_size
-
-DESCRIPTION
- These macros as used for reading and writing raw data in
- sections; each access (except for bytes) is vectored through
- the target format of the BFD and mangled accordingly. The
- mangling performs any necessary endian translations and
- removes alignment restrictions. Note that types accepted and
- returned by these macros are identical so they can be swapped
- around in macros---for example, @file{libaout.h} defines <<GET_WORD>>
- to either <<bfd_get_32>> or <<bfd_get_64>>.
-
- In the put routines, @var{val} must be a <<bfd_vma>>. If we are on a
- system without prototypes, the caller is responsible for making
- sure that is true, with a cast if necessary. We don't cast
- them in the macro definitions because that would prevent <<lint>>
- or <<gcc -Wall>> from detecting sins such as passing a pointer.
- To detect calling these with less than a <<bfd_vma>>, use
- <<gcc -Wconversion>> on a host with 64 bit <<bfd_vma>>'s.
-
-.
-.{* Byte swapping macros for user section data. *}
-.
-.#define bfd_put_8(abfd, val, ptr) \
-. (*((unsigned char *)(ptr)) = (unsigned char)(val))
-.#define bfd_put_signed_8 \
-. bfd_put_8
-.#define bfd_get_8(abfd, ptr) \
-. (*(unsigned char *)(ptr))
-.#define bfd_get_signed_8(abfd, ptr) \
-. ((*(unsigned char *)(ptr) ^ 0x80) - 0x80)
-.
-.#define bfd_put_16(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
-.#define bfd_put_signed_16 \
-. bfd_put_16
-.#define bfd_get_16(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx16, (ptr))
-.#define bfd_get_signed_16(abfd, ptr) \
-. BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
-.
-.#define bfd_put_32(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
-.#define bfd_put_signed_32 \
-. bfd_put_32
-.#define bfd_get_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx32, (ptr))
-.#define bfd_get_signed_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
-.
-.#define bfd_put_64(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
-.#define bfd_put_signed_64 \
-. bfd_put_64
-.#define bfd_get_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx64, (ptr))
-.#define bfd_get_signed_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
-.
-*/
-
-/*
-FUNCTION
- bfd_h_put_size
- bfd_h_get_size
-
-DESCRIPTION
- These macros have the same function as their <<bfd_get_x>>
- bretheren, except that they are used for removing information
- for the header records of object files. Believe it or not,
- some object files keep their header records in big endian
- order and their data in little endian order.
-.
-.{* Byte swapping macros for file header data. *}
-.
-.#define bfd_h_put_8(abfd, val, ptr) \
-. bfd_put_8 (abfd, val, ptr)
-.#define bfd_h_put_signed_8(abfd, val, ptr) \
-. bfd_put_8 (abfd, val, ptr)
-.#define bfd_h_get_8(abfd, ptr) \
-. bfd_get_8 (abfd, ptr)
-.#define bfd_h_get_signed_8(abfd, ptr) \
-. bfd_get_signed_8 (abfd, ptr)
-.
-.#define bfd_h_put_16(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
-.#define bfd_h_put_signed_16 \
-. bfd_h_put_16
-.#define bfd_h_get_16(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx16,(ptr))
-.#define bfd_h_get_signed_16(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
-.
-.#define bfd_h_put_32(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
-.#define bfd_h_put_signed_32 \
-. bfd_h_put_32
-.#define bfd_h_get_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx32,(ptr))
-.#define bfd_h_get_signed_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
-.
-.#define bfd_h_put_64(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
-.#define bfd_h_put_signed_64 \
-. bfd_h_put_64
-.#define bfd_h_get_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx64,(ptr))
-.#define bfd_h_get_signed_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
-.
-*/
-
-/* Sign extension to bfd_signed_vma. */
-#define COERCE16(x) (((bfd_signed_vma) (x) ^ 0x8000) - 0x8000)
-#define COERCE32(x) (((bfd_signed_vma) (x) ^ 0x80000000) - 0x80000000)
-#define EIGHT_GAZILLION (((BFD_HOST_64_BIT)0x80000000) << 32)
-#define COERCE64(x) \
- (((bfd_signed_vma) (x) ^ EIGHT_GAZILLION) - EIGHT_GAZILLION)
-
-bfd_vma
-bfd_getb16 (addr)
- register const bfd_byte *addr;
-{
- return (addr[0] << 8) | addr[1];
-}
-
-bfd_vma
-bfd_getl16 (addr)
- register const bfd_byte *addr;
-{
- return (addr[1] << 8) | addr[0];
-}
-
-bfd_signed_vma
-bfd_getb_signed_16 (addr)
- register const bfd_byte *addr;
-{
- return COERCE16((addr[0] << 8) | addr[1]);
-}
-
-bfd_signed_vma
-bfd_getl_signed_16 (addr)
- register const bfd_byte *addr;
-{
- return COERCE16((addr[1] << 8) | addr[0]);
-}
-
-void
-bfd_putb16 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
- addr[0] = (bfd_byte)(data >> 8);
- addr[1] = (bfd_byte )data;
-}
-
-void
-bfd_putl16 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
- addr[0] = (bfd_byte )data;
- addr[1] = (bfd_byte)(data >> 8);
-}
-
-bfd_vma
-bfd_getb32 (addr)
- register const bfd_byte *addr;
-{
- return (((((bfd_vma)addr[0] << 8) | addr[1]) << 8)
- | addr[2]) << 8 | addr[3];
-}
-
-bfd_vma
-bfd_getl32 (addr)
- register const bfd_byte *addr;
-{
- return (((((bfd_vma)addr[3] << 8) | addr[2]) << 8)
- | addr[1]) << 8 | addr[0];
-}
-
-bfd_signed_vma
-bfd_getb_signed_32 (addr)
- register const bfd_byte *addr;
-{
- return COERCE32((((((bfd_vma)addr[0] << 8) | addr[1]) << 8)
- | addr[2]) << 8 | addr[3]);
-}
-
-bfd_signed_vma
-bfd_getl_signed_32 (addr)
- register const bfd_byte *addr;
-{
- return COERCE32((((((bfd_vma)addr[3] << 8) | addr[2]) << 8)
- | addr[1]) << 8 | addr[0]);
-}
-
-bfd_vma
-bfd_getb64 (addr)
- register const bfd_byte *addr;
-{
-#ifdef BFD64
- bfd_vma low, high;
-
- high= ((((((((addr[0]) << 8) |
- addr[1]) << 8) |
- addr[2]) << 8) |
- addr[3]) );
-
- low = (((((((((bfd_vma)addr[4]) << 8) |
- addr[5]) << 8) |
- addr[6]) << 8) |
- addr[7]));
-
- return high << 32 | low;
-#else
- BFD_FAIL();
- return 0;
-#endif
-}
-
-bfd_vma
-bfd_getl64 (addr)
- register const bfd_byte *addr;
-{
-#ifdef BFD64
- bfd_vma low, high;
- high= (((((((addr[7] << 8) |
- addr[6]) << 8) |
- addr[5]) << 8) |
- addr[4]));
-
- low = ((((((((bfd_vma)addr[3] << 8) |
- addr[2]) << 8) |
- addr[1]) << 8) |
- addr[0]) );
-
- return high << 32 | low;
-#else
- BFD_FAIL();
- return 0;
-#endif
-
-}
-
-bfd_signed_vma
-bfd_getb_signed_64 (addr)
- register const bfd_byte *addr;
-{
-#ifdef BFD64
- bfd_vma low, high;
-
- high= ((((((((addr[0]) << 8) |
- addr[1]) << 8) |
- addr[2]) << 8) |
- addr[3]) );
-
- low = (((((((((bfd_vma)addr[4]) << 8) |
- addr[5]) << 8) |
- addr[6]) << 8) |
- addr[7]));
-
- return COERCE64(high << 32 | low);
-#else
- BFD_FAIL();
- return 0;
-#endif
-}
-
-bfd_signed_vma
-bfd_getl_signed_64 (addr)
- register const bfd_byte *addr;
-{
-#ifdef BFD64
- bfd_vma low, high;
- high= (((((((addr[7] << 8) |
- addr[6]) << 8) |
- addr[5]) << 8) |
- addr[4]));
-
- low = ((((((((bfd_vma)addr[3] << 8) |
- addr[2]) << 8) |
- addr[1]) << 8) |
- addr[0]) );
-
- return COERCE64(high << 32 | low);
-#else
- BFD_FAIL();
- return 0;
-#endif
-}
-
-void
-bfd_putb32 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
- addr[0] = (bfd_byte)(data >> 24);
- addr[1] = (bfd_byte)(data >> 16);
- addr[2] = (bfd_byte)(data >> 8);
- addr[3] = (bfd_byte)data;
-}
-
-void
-bfd_putl32 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
- addr[0] = (bfd_byte)data;
- addr[1] = (bfd_byte)(data >> 8);
- addr[2] = (bfd_byte)(data >> 16);
- addr[3] = (bfd_byte)(data >> 24);
-}
-
-void
-bfd_putb64 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
-#ifdef BFD64
- addr[0] = (bfd_byte)(data >> (7*8));
- addr[1] = (bfd_byte)(data >> (6*8));
- addr[2] = (bfd_byte)(data >> (5*8));
- addr[3] = (bfd_byte)(data >> (4*8));
- addr[4] = (bfd_byte)(data >> (3*8));
- addr[5] = (bfd_byte)(data >> (2*8));
- addr[6] = (bfd_byte)(data >> (1*8));
- addr[7] = (bfd_byte)(data >> (0*8));
-#else
- BFD_FAIL();
-#endif
-}
-
-void
-bfd_putl64 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
-#ifdef BFD64
- addr[7] = (bfd_byte)(data >> (7*8));
- addr[6] = (bfd_byte)(data >> (6*8));
- addr[5] = (bfd_byte)(data >> (5*8));
- addr[4] = (bfd_byte)(data >> (4*8));
- addr[3] = (bfd_byte)(data >> (3*8));
- addr[2] = (bfd_byte)(data >> (2*8));
- addr[1] = (bfd_byte)(data >> (1*8));
- addr[0] = (bfd_byte)(data >> (0*8));
-#else
- BFD_FAIL();
-#endif
-}
-
-/* Default implementation */
-
-boolean
-_bfd_generic_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)
- 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);
-}
-
-boolean
-_bfd_generic_get_section_contents_in_window (abfd, section, w, offset, count)
- bfd *abfd;
- sec_ptr section;
- bfd_window *w;
- file_ptr offset;
- bfd_size_type count;
-{
-#ifdef USE_MMAP
- if (count == 0)
- return true;
- if (abfd->xvec->_bfd_get_section_contents != _bfd_generic_get_section_contents)
- {
- /* We don't know what changes the bfd's get_section_contents
- method may have to make. So punt trying to map the file
- window, and let get_section_contents do its thing. */
- /* @@ FIXME : If the internal window has a refcount of 1 and was
- allocated with malloc instead of mmap, just reuse it. */
- bfd_free_window (w);
- w->i = (bfd_window_internal *) bfd_zmalloc (sizeof (bfd_window_internal));
- if (w->i == NULL)
- return false;
- w->i->data = (PTR) bfd_malloc ((size_t) count);
- if (w->i->data == NULL)
- {
- free (w->i);
- w->i = NULL;
- return false;
- }
- w->i->mapped = 0;
- w->i->refcount = 1;
- w->size = w->i->size = count;
- w->data = w->i->data;
- return bfd_get_section_contents (abfd, section, w->data, offset, count);
- }
- if ((bfd_size_type) (offset+count) > section->_raw_size
- || (bfd_get_file_window (abfd, section->filepos + offset, count, w, true)
- == false))
- return false;
- return true;
-#else
- abort ();
-#endif
-}
-
-/* This generic function can only be used in implementations where creating
- NEW sections is disallowed. It is useful in patching existing sections
- in read-write files, though. See other set_section_contents functions
- to see why it doesn't work for new sections. */
-boolean
-_bfd_generic_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;
-
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) == -1
- || bfd_write (location, (bfd_size_type) 1, count, abfd) != count)
- return false;
-
- return true;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_log2
-
-SYNOPSIS
- unsigned int bfd_log2(bfd_vma x);
-
-DESCRIPTION
- Return the log base 2 of the value supplied, rounded up. E.g., an
- @var{x} of 1025 returns 11.
-*/
-
-unsigned
-bfd_log2(x)
- bfd_vma x;
-{
- unsigned result = 0;
- while ( (bfd_vma)(1<< result) < x)
- result++;
- return result;
-}
-
-boolean
-bfd_generic_is_local_label (abfd, sym)
- bfd *abfd;
- asymbol *sym;
-{
- char locals_prefix = (bfd_get_symbol_leading_char (abfd) == '_') ? 'L' : '.';
-
- return (sym->name[0] == locals_prefix);
-}
-
diff --git a/contrib/gdb/bfd/libbfd.h b/contrib/gdb/bfd/libbfd.h
deleted file mode 100644
index 5cf504cdc751..000000000000
--- a/contrib/gdb/bfd/libbfd.h
+++ /dev/null
@@ -1,735 +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 */
-
-void
-bfd_write_bigendian_4byte_int PARAMS ((bfd *abfd, int i));
-
-unsigned int
-bfd_log2 PARAMS ((bfd_vma x));
-
-#define BFD_CACHE_MAX_OPEN 10
-extern bfd *bfd_last_cache;
-
-#define bfd_cache_lookup(x) \
- ((x)==bfd_last_cache? \
- (FILE*)(bfd_last_cache->iostream): \
- bfd_cache_lookup_worker(x))
-boolean
-bfd_cache_init PARAMS ((bfd *abfd));
-
-boolean
-bfd_cache_close PARAMS ((bfd *abfd));
-
-FILE*
-bfd_open_file PARAMS ((bfd *abfd));
-
-FILE *
-bfd_cache_lookup_worker PARAMS ((bfd *abfd));
-
-#ifdef _BFD_MAKE_TABLE_bfd_reloc_code_real
-
-static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
-
- "BFD_RELOC_64",
- "BFD_RELOC_32",
- "BFD_RELOC_26",
- "BFD_RELOC_16",
- "BFD_RELOC_14",
- "BFD_RELOC_8",
- "BFD_RELOC_64_PCREL",
- "BFD_RELOC_32_PCREL",
- "BFD_RELOC_24_PCREL",
- "BFD_RELOC_16_PCREL",
- "BFD_RELOC_12_PCREL",
- "BFD_RELOC_8_PCREL",
- "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",
- "BFD_RELOC_68K_GLOB_DAT",
- "BFD_RELOC_68K_JMP_SLOT",
- "BFD_RELOC_68K_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",
- "BFD_RELOC_8_FFnn",
- "BFD_RELOC_32_PCREL_S2",
- "BFD_RELOC_16_PCREL_S2",
- "BFD_RELOC_23_PCREL_S2",
- "BFD_RELOC_HI22",
- "BFD_RELOC_LO10",
- "BFD_RELOC_GPREL16",
- "BFD_RELOC_GPREL32",
- "BFD_RELOC_I960_CALLJ",
- "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",
- "BFD_RELOC_SPARC_BASE13",
- "BFD_RELOC_SPARC_BASE22",
- "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",
- "BFD_RELOC_ALPHA_GPDISP_HI16",
- "BFD_RELOC_ALPHA_GPDISP_LO16",
- "BFD_RELOC_ALPHA_LITERAL",
- "BFD_RELOC_ALPHA_LITUSE",
- "BFD_RELOC_ALPHA_HINT",
- "BFD_RELOC_MIPS_JMP",
- "BFD_RELOC_HI16",
- "BFD_RELOC_HI16_S",
- "BFD_RELOC_LO16",
- "BFD_RELOC_PCREL_HI16_S",
- "BFD_RELOC_PCREL_LO16",
- "BFD_RELOC_MIPS_LITERAL",
- "BFD_RELOC_MIPS_GOT16",
- "BFD_RELOC_MIPS_CALL16",
- "BFD_RELOC_MIPS_GOT_HI16",
- "BFD_RELOC_MIPS_GOT_LO16",
- "BFD_RELOC_MIPS_CALL_HI16",
- "BFD_RELOC_MIPS_CALL_LO16",
- "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",
- "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",
- "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",
- "BFD_RELOC_CTOR",
- "BFD_RELOC_ARM_PCREL_BRANCH",
- "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",
- "@@overflow: BFD_RELOC_UNUSED@@",
-};
-#endif
-
-reloc_howto_type *
-bfd_default_reloc_type_lookup
- PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-
-boolean
-bfd_generic_relax_section
- PARAMS ((bfd *abfd,
- asection *section,
- struct bfd_link_info *,
- boolean *));
-
-bfd_byte *
-
-bfd_generic_get_relocated_section_contents PARAMS ((bfd *abfd,
- struct bfd_link_info *link_info,
- struct bfd_link_order *link_order,
- bfd_byte *data,
- boolean relocateable,
- asymbol **symbols));
-
-extern const bfd_arch_info_type bfd_default_arch_struct;
-boolean
-bfd_default_set_arch_mach PARAMS ((bfd *abfd,
- enum bfd_architecture arch,
- unsigned long mach));
-
-const bfd_arch_info_type *
-bfd_default_compatible
- PARAMS ((const bfd_arch_info_type *a,
- const bfd_arch_info_type *b));
-
-boolean
-bfd_default_scan PARAMS ((const struct bfd_arch_info *info, const char *string));
-
-struct elf_internal_shdr *
-bfd_elf_find_section PARAMS ((bfd *abfd, char *name));
-
diff --git a/contrib/gdb/bfd/libcoff-in.h b/contrib/gdb/bfd/libcoff-in.h
deleted file mode 100644
index 648ed8066386..000000000000
--- 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/libcoff.h b/contrib/gdb/bfd/libcoff.h
deleted file mode 100644
index daa39b52bd4e..000000000000
--- a/contrib/gdb/bfd/libcoff.h
+++ /dev/null
@@ -1,823 +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 .. */
-
-typedef struct coff_ptr_struct
-{
-
- /* Remembers the offset from the first symbol in the file for
- this symbol. Generated by coff_renumber_symbols. */
-unsigned int offset;
-
- /* Should the value of this symbol be renumbered. Used for
- XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */
-unsigned int fix_value : 1;
-
- /* Should the tag field of this symbol be renumbered.
- Created by coff_pointerize_aux. */
-unsigned int fix_tag : 1;
-
- /* Should the endidx field of this symbol be renumbered.
- Created by coff_pointerize_aux. */
-unsigned int fix_end : 1;
-
- /* Should the x_csect.x_scnlen field be renumbered.
- Created by coff_pointerize_aux. */
-unsigned int fix_scnlen : 1;
-
- /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
- index into the line number entries. Set by
- coff_slurp_symbol_table. */
-unsigned int fix_line : 1;
-
- /* The container for the symbol structure as read and translated
- from the file. */
-
-union {
- union internal_auxent auxent;
- struct internal_syment syment;
- } u;
-} combined_entry_type;
-
-
- /* Each canonical asymbol really looks like this: */
-
-typedef struct coff_symbol_struct
-{
- /* The actual symbol which the rest of BFD works with */
-asymbol symbol;
-
- /* A pointer to the hidden information for this symbol */
-combined_entry_type *native;
-
- /* A pointer to the linenumber information for this symbol */
-struct lineno_cache_entry *lineno;
-
- /* Have the line numbers been relocated yet ? */
-boolean done_lineno;
-} coff_symbol_type;
-typedef struct
-{
- void (*_bfd_coff_swap_aux_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- int type,
- int class,
- int indaux,
- int numaux,
- PTR in));
-
- void (*_bfd_coff_swap_sym_in) PARAMS ((
- bfd *abfd ,
- PTR ext,
- PTR in));
-
- void (*_bfd_coff_swap_lineno_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
-
- unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
- bfd *abfd,
- PTR in,
- int type,
- int class,
- int indaux,
- int numaux,
- PTR ext));
-
- unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR ext));
-
- unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR ext));
-
- unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
- bfd *abfd,
- PTR src,
- PTR dst));
-
- unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR out));
-
- unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR out));
-
- unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR out));
-
- unsigned int _bfd_filhsz;
- unsigned int _bfd_aoutsz;
- unsigned int _bfd_scnhsz;
- unsigned int _bfd_symesz;
- unsigned int _bfd_auxesz;
- unsigned int _bfd_relsz;
- unsigned int _bfd_linesz;
- boolean _bfd_coff_long_filenames;
- void (*_bfd_coff_swap_filehdr_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- void (*_bfd_coff_swap_reloc_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- boolean (*_bfd_coff_bad_format_hook) PARAMS ((
- bfd *abfd,
- PTR internal_filehdr));
- boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
- bfd *abfd,
- PTR internal_filehdr));
- PTR (*_bfd_coff_mkobject_hook) PARAMS ((
- bfd *abfd,
- PTR internal_filehdr,
- PTR internal_aouthdr));
- flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
- bfd *abfd,
- PTR internal_scnhdr,
- const char *name));
- void (*_bfd_set_alignment_hook) PARAMS ((
- bfd *abfd,
- asection *sec,
- PTR internal_scnhdr));
- boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
- bfd *abfd));
- boolean (*_bfd_coff_symname_in_debug) PARAMS ((
- bfd *abfd,
- struct internal_syment *sym));
- boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
- bfd *abfd,
- combined_entry_type *table_base,
- combined_entry_type *symbol,
- unsigned int indaux,
- combined_entry_type *aux));
- boolean (*_bfd_coff_print_aux) PARAMS ((
- bfd *abfd,
- FILE *file,
- combined_entry_type *table_base,
- combined_entry_type *symbol,
- combined_entry_type *aux,
- unsigned int indaux));
- void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
- bfd *abfd,
- struct bfd_link_info *link_info,
- struct bfd_link_order *link_order,
- arelent *reloc,
- bfd_byte *data,
- unsigned int *src_ptr,
- unsigned int *dst_ptr));
- int (*_bfd_coff_reloc16_estimate) PARAMS ((
- bfd *abfd,
- asection *input_section,
- arelent *r,
- unsigned int shrink,
- struct bfd_link_info *link_info));
- boolean (*_bfd_coff_sym_is_global) PARAMS ((
- bfd *abfd,
- struct internal_syment *));
- void (*_bfd_coff_compute_section_file_positions) PARAMS ((
- bfd *abfd));
- boolean (*_bfd_coff_start_final_link) PARAMS ((
- bfd *output_bfd,
- struct bfd_link_info *info));
- boolean (*_bfd_coff_relocate_section) PARAMS ((
- bfd *output_bfd,
- struct bfd_link_info *info,
- bfd *input_bfd,
- asection *input_section,
- bfd_byte *contents,
- struct internal_reloc *relocs,
- struct internal_syment *syms,
- asection **sections));
- reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
- bfd *abfd,
- asection *sec,
- struct internal_reloc *rel,
- struct coff_link_hash_entry *h,
- struct internal_syment *sym,
- bfd_vma *addendp));
- boolean (*_bfd_coff_adjust_symndx) PARAMS ((
- bfd *obfd,
- struct bfd_link_info *info,
- bfd *ibfd,
- asection *sec,
- struct internal_reloc *reloc,
- boolean *adjustedp));
- boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
- struct bfd_link_info *info,
- bfd *abfd,
- const char *name,
- flagword flags,
- asection *section,
- bfd_vma value,
- const char *string,
- boolean copy,
- boolean collect,
- struct bfd_link_hash_entry **hashp));
-
-} bfd_coff_backend_data;
-
-#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
-
-#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
- ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
-
-#define bfd_coff_swap_sym_in(a,e,i) \
- ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
-
-#define bfd_coff_swap_lineno_in(a,e,i) \
- ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
-
-#define bfd_coff_swap_reloc_out(abfd, i, o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
-
-#define bfd_coff_swap_lineno_out(abfd, i, o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
-
-#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
- ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
-
-#define bfd_coff_swap_sym_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
-
-#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
-
-#define bfd_coff_swap_filehdr_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
-
-#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
-
-#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
-#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
-#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
-#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
-#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
-#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
-#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
-#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
-#define bfd_coff_swap_filehdr_in(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
-
-#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
-
-#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
-
-#define bfd_coff_swap_reloc_in(abfd, i, o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
-
-#define bfd_coff_bad_format_hook(abfd, filehdr) \
- ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
-
-#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
- ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
-#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
- ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
-
-#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
- ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
-
-#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
- ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
-
-#define bfd_coff_slurp_symbol_table(abfd)\
- ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
-
-#define bfd_coff_symname_in_debug(abfd, sym)\
- ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
-
-#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
- ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
- (abfd, file, base, symbol, aux, indaux))
-
-#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
- ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
- (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
-
-#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
- ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
- (abfd, section, reloc, shrink, link_info))
-
-#define bfd_coff_sym_is_global(abfd, sym)\
- ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\
- (abfd, sym))
-
-#define bfd_coff_compute_section_file_positions(abfd)\
- ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
- (abfd))
-
-#define bfd_coff_start_final_link(obfd, info)\
- ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
- (obfd, info))
-#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
- ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
- (obfd, info, ibfd, o, con, rel, isyms, secs))
-#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
- ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
- (abfd, sec, rel, h, sym, addendp))
-#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
- ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
- (obfd, info, ibfd, sec, rel, adjustedp))
-#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
- ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
- (info, abfd, name, flags, section, value, string, cp, coll, hashp))
-
diff --git a/contrib/gdb/bfd/libecoff.h b/contrib/gdb/bfd/libecoff.h
deleted file mode 100644
index 169610d00509..000000000000
--- a/contrib/gdb/bfd/libecoff.h
+++ /dev/null
@@ -1,352 +0,0 @@
-/* BFD ECOFF object file private structure.
- Copyright (C) 1993, 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. */
-
-#include "bfdlink.h"
-
-#ifndef ECOFF_H
-#include "coff/ecoff.h"
-#endif
-
-/* This is the backend information kept for ECOFF files. This
- structure is constant for a particular backend. The first element
- is the COFF backend data structure, so that ECOFF targets can use
- the generic COFF code. */
-
-#define ecoff_backend(abfd) \
- ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)
-
-struct ecoff_backend_data
-{
- /* COFF backend information. This must be the first field. */
- bfd_coff_backend_data coff;
- /* Supported architecture. */
- enum bfd_architecture arch;
- /* Initial portion of armap string. */
- const char *armap_start;
- /* The page boundary used to align sections in a demand-paged
- executable file. E.g., 0x1000. */
- bfd_vma round;
- /* 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. */
- boolean rdata_in_text;
- /* Bitsize of constructor entries. */
- unsigned int constructor_bitsize;
- /* Reloc to use for constructor entries. */
- reloc_howto_type *constructor_reloc;
- /* How to swap debugging information. */
- struct ecoff_debug_swap debug_swap;
- /* External reloc size. */
- bfd_size_type external_reloc_size;
- /* Reloc swapping functions. */
- void (*swap_reloc_in) PARAMS ((bfd *, PTR, struct internal_reloc *));
- void (*swap_reloc_out) PARAMS ((bfd *, const struct internal_reloc *, PTR));
- /* Backend reloc tweaking. */
- void (*adjust_reloc_in) PARAMS ((bfd *, const struct internal_reloc *,
- arelent *));
- void (*adjust_reloc_out) PARAMS ((bfd *, const arelent *,
- struct internal_reloc *));
- /* Relocate section contents while linking. */
- boolean (*relocate_section) PARAMS ((bfd *output_bfd, struct bfd_link_info *,
- bfd *input_bfd, asection *input_section,
- bfd_byte *contents,
- PTR external_relocs));
- /* Do final adjustments to filehdr and aouthdr. */
- boolean (*adjust_headers) PARAMS ((bfd *, struct internal_filehdr *,
- struct internal_aouthdr *));
- /* Read an element from an archive at a given file position. This
- is needed because OSF/1 3.2 uses a weird archive format. */
- bfd *(*get_elt_at_filepos) PARAMS ((bfd *, file_ptr));
-};
-
-/* This is the target specific information kept for ECOFF files. */
-
-#define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
-
-typedef struct ecoff_tdata
-{
- /* The reloc file position, set by
- ecoff_compute_section_file_positions. */
- file_ptr reloc_filepos;
-
- /* The symbol table file position, set by _bfd_ecoff_mkobject_hook. */
- file_ptr sym_filepos;
-
- /* The start and end of the text segment. Only valid for an
- existing file, not for one we are creating. */
- unsigned long text_start;
- unsigned long text_end;
-
- /* The cached gp value. This is used when relocating. */
- bfd_vma gp;
-
- /* The maximum size of objects to optimize using gp. This is
- typically set by the -G option to the compiler, assembler or
- linker. */
- unsigned int gp_size;
-
- /* The register masks. When linking, all the masks found in the
- input files are combined into the masks of the output file.
- These are not all used for all targets, but that's OK, because
- the relevant ones are the only ones swapped in and out. */
- unsigned long gprmask;
- unsigned long fprmask;
- unsigned long cprmask[4];
-
- /* The ECOFF symbolic debugging information. */
- struct ecoff_debug_info debug_info;
-
- /* The unswapped ECOFF symbolic information. */
- PTR raw_syments;
-
- /* The canonical BFD symbols. */
- struct ecoff_symbol_struct *canonical_symbols;
-
- /* A mapping from external symbol numbers to entries in the linker
- hash table, used when linking. */
- struct ecoff_link_hash_entry **sym_hashes;
-
- /* A mapping from reloc symbol indices to sections, used when
- linking. */
- asection **symndx_to_section;
-
- /* True if this BFD was written by the backend linker. */
- boolean linker;
-
- /* True if a warning that multiple global pointer values are
- needed in the output binary was issued already. */
- boolean issued_multiple_gp_warning;
-
- /* Used by find_nearest_line entry point. The structure could be
- included directly in this one, but there's no point to wasting
- the memory just for the infrequently called find_nearest_line. */
- struct ecoff_find_line *find_line_info;
-
-} ecoff_data_type;
-
-/* Each canonical asymbol really looks like this. */
-
-typedef struct ecoff_symbol_struct
-{
- /* The actual symbol which the rest of BFD works with */
- asymbol symbol;
-
- /* The fdr for this symbol. */
- FDR *fdr;
-
- /* true if this is a local symbol rather than an external one. */
- boolean local;
-
- /* A pointer to the unswapped hidden information for this symbol.
- This is either a struct sym_ext or a struct ext_ext, depending on
- the value of the local field above. */
- PTR native;
-} ecoff_symbol_type;
-
-/* We take the address of the first element of a asymbol to ensure that the
- macro is only ever applied to an asymbol. */
-#define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
-
-/* We need to save the index of an external symbol when we write it
- out so that can set the symbol index correctly when we write out
- the relocs. */
-#define ecoff_get_sym_index(symbol) ((symbol)->udata.i)
-#define ecoff_set_sym_index(symbol, idx) ((symbol)->udata.i = (idx))
-
-/* When generating MIPS embedded PIC code, the linker relaxes the code
- to turn PC relative branches into longer code sequences when the PC
- relative branch is out of range. This involves reading the relocs
- in bfd_relax_section as well as in bfd_final_link, and requires the
- code to keep track of which relocs have been expanded. A pointer
- to this structure is put in the used_by_bfd pointer of a section to
- keep track of this information. The user_by_bfd pointer will be
- NULL if the information was not needed. */
-
-struct ecoff_section_tdata
-{
- /* The unswapped relocs for this section. These are stored in
- memory so the input file does not have to be read twice. */
- PTR external_relocs;
-
- /* The contents of the section. These bytes may or may not be saved
- in memory, but if it is this is a pointer to them. */
- bfd_byte *contents;
-
- /* Offset adjustments for PC relative branches. A number other than
- 1 is an addend for a PC relative branch, or a switch table entry
- which is the difference of two .text locations; this addend
- arises because the branch or difference crosses one or more
- branches which were expanded into a larger code sequence. A 1
- means that this branch was itself expanded into a larger code
- sequence. 1 is not a possible offset, since all offsets must be
- multiples of the instruction size, which is 4; also, the only
- relocs with non-zero offsets will be PC relative branches or
- switch table entries within the same object file. If this field
- is NULL, no branches were expanded and no offsets are required.
- Otherwise there are as many entries as there are relocs in the
- section, and the entry for any reloc that is not PC relative is
- zero. */
- long *offsets;
-
- /* When producing an executable (i.e., final, non-relocatable link)
- on the Alpha, we may need to use multiple global pointer values
- to span the entire .lita section. In essence, we allow each
- input .lita section to have its own gp value. To support this,
- we need to keep track of the gp values that we picked for each
- input .lita section . */
- bfd_vma gp;
-};
-
-/* An accessor macro for the ecoff_section_tdata structure. */
-#define ecoff_section_data(abfd, sec) \
- ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
-
-/* ECOFF linker hash table entries. */
-
-struct ecoff_link_hash_entry
-{
- struct bfd_link_hash_entry root;
- /* Symbol index in output file. */
- long indx;
- /* BFD that ext field value came from. */
- bfd *abfd;
- /* ECOFF external symbol information. */
- EXTR esym;
- /* Nonzero if this symbol has been written out. */
- char written;
- /* Nonzero if this symbol was referred to as small undefined. */
- char small;
-};
-
-/* ECOFF linker hash table. */
-
-struct ecoff_link_hash_table
-{
- struct bfd_link_hash_table root;
-};
-
-/* Make an ECOFF object. */
-extern boolean _bfd_ecoff_mkobject PARAMS ((bfd *));
-
-/* Read in the ECOFF symbolic debugging information. */
-extern boolean _bfd_ecoff_slurp_symbolic_info
- PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
-
-/* Generic ECOFF BFD backend vectors. */
-
-extern boolean _bfd_ecoff_write_object_contents PARAMS ((bfd *abfd));
-extern const bfd_target *_bfd_ecoff_archive_p PARAMS ((bfd *abfd));
-
-#define _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
-#define _bfd_ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-extern boolean _bfd_ecoff_new_section_hook
- PARAMS ((bfd *, asection *));
-extern boolean _bfd_ecoff_get_section_contents
- PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
-
-#define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section
-
-extern boolean _bfd_ecoff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-#define _bfd_ecoff_bfd_copy_private_section_data \
- _bfd_generic_bfd_copy_private_section_data
-
-#define _bfd_ecoff_bfd_copy_private_symbol_data \
- _bfd_generic_bfd_copy_private_symbol_data
-
-#define _bfd_ecoff_bfd_print_private_bfd_data \
- _bfd_generic_bfd_print_private_bfd_data
-
-#define _bfd_ecoff_bfd_merge_private_bfd_data \
- _bfd_generic_bfd_merge_private_bfd_data
-
-#define _bfd_ecoff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
-extern boolean _bfd_ecoff_slurp_armap PARAMS ((bfd *abfd));
-#define _bfd_ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
-#define _bfd_ecoff_construct_extended_name_table \
- _bfd_archive_bsd_construct_extended_name_table
-#define _bfd_ecoff_truncate_arname bfd_dont_truncate_arname
-extern boolean _bfd_ecoff_write_armap
- PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
-#define _bfd_ecoff_read_ar_hdr _bfd_generic_read_ar_hdr
-#define _bfd_ecoff_openr_next_archived_file \
- bfd_generic_openr_next_archived_file
-#define _bfd_ecoff_get_elt_at_index _bfd_generic_get_elt_at_index
-#define _bfd_ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#define _bfd_ecoff_update_armap_timestamp bfd_true
-
-extern long _bfd_ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
-extern long _bfd_ecoff_get_symtab PARAMS ((bfd *abfd, asymbol **alocation));
-extern asymbol *_bfd_ecoff_make_empty_symbol PARAMS ((bfd *abfd));
-extern void _bfd_ecoff_print_symbol
- PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type));
-extern void _bfd_ecoff_get_symbol_info
- PARAMS ((bfd *, asymbol *, symbol_info *));
-extern boolean _bfd_ecoff_bfd_is_local_label
- PARAMS ((bfd *, asymbol *));
-#define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno
-extern boolean _bfd_ecoff_find_nearest_line
- PARAMS ((bfd *, asection *, asymbol **, bfd_vma offset,
- const char **filename_ptr, const char **fnname_ptr,
- unsigned int *retline_ptr));
-#define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols
-#define _bfd_ecoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define _bfd_ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
-extern long _bfd_ecoff_canonicalize_reloc
- PARAMS ((bfd *, asection *, arelent **, asymbol **symbols));
-/* ecoff_bfd_reloc_type_lookup defined by backend. */
-
-extern boolean _bfd_ecoff_set_arch_mach
- PARAMS ((bfd *, enum bfd_architecture, unsigned long machine));
-extern boolean _bfd_ecoff_set_section_contents
- PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
-
-extern int _bfd_ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
-/* ecoff_bfd_get_relocated_section_contents defined by backend. */
-/* ecoff_bfd_relax_section defined by backend. */
-extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create
- PARAMS ((bfd *));
-extern boolean _bfd_ecoff_bfd_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_ecoff_bfd_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Hook functions for the generic COFF section reading code. */
-
-extern PTR _bfd_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
-#define _bfd_ecoff_set_alignment_hook \
- ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
-extern boolean _bfd_ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
-extern flagword _bfd_ecoff_styp_to_sec_flags
- PARAMS ((bfd *abfd, PTR hdr, const char *name));
-extern boolean _bfd_ecoff_slurp_symbol_table PARAMS ((bfd *abfd));
-
-/* 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 *));
diff --git a/contrib/gdb/bfd/libhppa.h b/contrib/gdb/bfd/libhppa.h
deleted file mode 100644
index fa97b68821fd..000000000000
--- 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 c3729cbf5177..000000000000
--- 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 12d2e4e0cf8a..000000000000
--- 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 2d1581376565..000000000000
--- 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/linker.c b/contrib/gdb/bfd/linker.c
deleted file mode 100644
index 4decc88cafae..000000000000
--- a/contrib/gdb/bfd/linker.c
+++ /dev/null
@@ -1,2781 +0,0 @@
-/* linker.c -- BFD linker routines
- Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
- Written by Steve Chamberlain and 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"
-#include "bfdlink.h"
-#include "genlink.h"
-
-/*
-SECTION
- Linker Functions
-
-@cindex Linker
- The linker uses three special entry points in the BFD target
- vector. It is not necessary to write special routines for
- these entry points when creating a new BFD back end, since
- generic versions are provided. However, writing them can
- speed up linking and make it use significantly less runtime
- memory.
-
- The first routine creates a hash table used by the other
- routines. The second routine adds the symbols from an object
- file to the hash table. The third routine takes all the
- object files and links them together to create the output
- file. These routines are designed so that the linker proper
- does not need to know anything about the symbols in the object
- files that it is linking. The linker merely arranges the
- sections as directed by the linker script and lets BFD handle
- the details of symbols and relocs.
-
- The second routine and third routines are passed a pointer to
- a <<struct bfd_link_info>> structure (defined in
- <<bfdlink.h>>) which holds information relevant to the link,
- including the linker hash table (which was created by the
- first routine) and a set of callback functions to the linker
- proper.
-
- The generic linker routines are in <<linker.c>>, and use the
- header file <<genlink.h>>. As of this writing, the only back
- ends which have implemented versions of these routines are
- a.out (in <<aoutx.h>>) and ECOFF (in <<ecoff.c>>). The a.out
- routines are used as examples throughout this section.
-
-@menu
-@* Creating a Linker Hash Table::
-@* Adding Symbols to the Hash Table::
-@* Performing the Final Link::
-@end menu
-
-INODE
-Creating a Linker Hash Table, Adding Symbols to the Hash Table, Linker Functions, Linker Functions
-SUBSECTION
- Creating a linker hash table
-
-@cindex _bfd_link_hash_table_create in target vector
-@cindex target vector (_bfd_link_hash_table_create)
- The linker routines must create a hash table, which must be
- derived from <<struct bfd_link_hash_table>> described in
- <<bfdlink.c>>. @xref{Hash Tables} for information on how to
- create a derived hash table. This entry point is called using
- the target vector of the linker output file.
-
- The <<_bfd_link_hash_table_create>> entry point must allocate
- and initialize an instance of the desired hash table. If the
- back end does not require any additional information to be
- stored with the entries in the hash table, the entry point may
- simply create a <<struct bfd_link_hash_table>>. Most likely,
- however, some additional information will be needed.
-
- For example, with each entry in the hash table the a.out
- linker keeps the index the symbol has in the final output file
- (this index number is used so that when doing a relocateable
- link the symbol index used in the output file can be quickly
- filled in when copying over a reloc). The a.out linker code
- defines the required structures and functions for a hash table
- derived from <<struct bfd_link_hash_table>>. The a.out linker
- hash table is created by the function
- <<NAME(aout,link_hash_table_create)>>; it simply allocates
- space for the hash table, initializes it, and returns a
- pointer to it.
-
- When writing the linker routines for a new back end, you will
- generally not know exactly which fields will be required until
- you have finished. You should simply create a new hash table
- which defines no additional fields, and then simply add fields
- as they become necessary.
-
-INODE
-Adding Symbols to the Hash Table, Performing the Final Link, Creating a Linker Hash Table, Linker Functions
-SUBSECTION
- Adding symbols to the hash table
-
-@cindex _bfd_link_add_symbols in target vector
-@cindex target vector (_bfd_link_add_symbols)
- The linker proper will call the <<_bfd_link_add_symbols>>
- entry point for each object file or archive which is to be
- linked (typically these are the files named on the command
- line, but some may also come from the linker script). The
- entry point is responsible for examining the file. For an
- object file, BFD must add any relevant symbol information to
- the hash table. For an archive, BFD must determine which
- elements of the archive should be used and adding them to the
- link.
-
- The a.out version of this entry point is
- <<NAME(aout,link_add_symbols)>>.
-
-@menu
-@* Differing file formats::
-@* Adding symbols from an object file::
-@* Adding symbols from an archive::
-@end menu
-
-INODE
-Differing file formats, Adding symbols from an object file, Adding Symbols to the Hash Table, Adding Symbols to the Hash Table
-SUBSUBSECTION
- Differing file formats
-
- Normally all the files involved in a link will be of the same
- format, but it is also possible to link together different
- format object files, and the back end must support that. The
- <<_bfd_link_add_symbols>> entry point is called via the target
- vector of the file to be added. This has an important
- consequence: the function may not assume that the hash table
- is the type created by the corresponding
- <<_bfd_link_hash_table_create>> vector. All the
- <<_bfd_link_add_symbols>> function can assume about the hash
- table is that it is derived from <<struct
- bfd_link_hash_table>>.
-
- Sometimes the <<_bfd_link_add_symbols>> function must store
- some information in the hash table entry to be used by the
- <<_bfd_final_link>> function. In such a case the <<creator>>
- field of the hash table must be checked to make sure that the
- hash table was created by an object file of the same format.
-
- The <<_bfd_final_link>> routine must be prepared to handle a
- hash entry without any extra information added by the
- <<_bfd_link_add_symbols>> function. A hash entry without
- extra information will also occur when the linker script
- directs the linker to create a symbol. Note that, regardless
- of how a hash table entry is added, all the fields will be
- initialized to some sort of null value by the hash table entry
- initialization function.
-
- See <<ecoff_link_add_externals>> for an example of how to
- check the <<creator>> field before saving information (in this
- case, the ECOFF external symbol debugging information) in a
- hash table entry.
-
-INODE
-Adding symbols from an object file, Adding symbols from an archive, Differing file formats, Adding Symbols to the Hash Table
-SUBSUBSECTION
- Adding symbols from an object file
-
- When the <<_bfd_link_add_symbols>> routine is passed an object
- file, it must add all externally visible symbols in that
- object file to the hash table. The actual work of adding the
- symbol to the hash table is normally handled by the function
- <<_bfd_generic_link_add_one_symbol>>. The
- <<_bfd_link_add_symbols>> routine is responsible for reading
- all the symbols from the object file and passing the correct
- information to <<_bfd_generic_link_add_one_symbol>>.
-
- The <<_bfd_link_add_symbols>> routine should not use
- <<bfd_canonicalize_symtab>> to read the symbols. The point of
- providing this routine is to avoid the overhead of converting
- the symbols into generic <<asymbol>> structures.
-
-@findex _bfd_generic_link_add_one_symbol
- <<_bfd_generic_link_add_one_symbol>> handles the details of
- combining common symbols, warning about multiple definitions,
- and so forth. It takes arguments which describe the symbol to
- add, notably symbol flags, a section, and an offset. The
- symbol flags include such things as <<BSF_WEAK>> or
- <<BSF_INDIRECT>>. The section is a section in the object
- file, or something like <<bfd_und_section_ptr>> for an undefined
- symbol or <<bfd_com_section_ptr>> for a common symbol.
-
- If the <<_bfd_final_link>> routine is also going to need to
- read the symbol information, the <<_bfd_link_add_symbols>>
- routine should save it somewhere attached to the object file
- BFD. However, the information should only be saved if the
- <<keep_memory>> field of the <<info>> argument is true, so
- that the <<-no-keep-memory>> linker switch is effective.
-
- The a.out function which adds symbols from an object file is
- <<aout_link_add_object_symbols>>, and most of the interesting
- work is in <<aout_link_add_symbols>>. The latter saves
- pointers to the hash tables entries created by
- <<_bfd_generic_link_add_one_symbol>> indexed by symbol number,
- so that the <<_bfd_final_link>> routine does not have to call
- the hash table lookup routine to locate the entry.
-
-INODE
-Adding symbols from an archive, , Adding symbols from an object file, Adding Symbols to the Hash Table
-SUBSUBSECTION
- Adding symbols from an archive
-
- When the <<_bfd_link_add_symbols>> routine is passed an
- archive, it must look through the symbols defined by the
- archive and decide which elements of the archive should be
- included in the link. For each such element it must call the
- <<add_archive_element>> linker callback, and it must add the
- symbols from the object file to the linker hash table.
-
-@findex _bfd_generic_link_add_archive_symbols
- In most cases the work of looking through the symbols in the
- archive should be done by the
- <<_bfd_generic_link_add_archive_symbols>> function. This
- function builds a hash table from the archive symbol table and
- looks through the list of undefined symbols to see which
- elements should be included.
- <<_bfd_generic_link_add_archive_symbols>> is passed a function
- to call to make the final decision about adding an archive
- element to the link and to do the actual work of adding the
- symbols to the linker hash table.
-
- The function passed to
- <<_bfd_generic_link_add_archive_symbols>> must read the
- symbols of the archive element and decide whether the archive
- element should be included in the link. If the element is to
- be included, the <<add_archive_element>> linker callback
- routine must be called with the element as an argument, and
- the elements symbols must be added to the linker hash table
- just as though the element had itself been passed to the
- <<_bfd_link_add_symbols>> function.
-
- When the a.out <<_bfd_link_add_symbols>> function receives an
- archive, it calls <<_bfd_generic_link_add_archive_symbols>>
- passing <<aout_link_check_archive_element>> as the function
- argument. <<aout_link_check_archive_element>> calls
- <<aout_link_check_ar_symbols>>. If the latter decides to add
- the element (an element is only added if it provides a real,
- non-common, definition for a previously undefined or common
- symbol) it calls the <<add_archive_element>> callback and then
- <<aout_link_check_archive_element>> calls
- <<aout_link_add_symbols>> to actually add the symbols to the
- linker hash table.
-
- The ECOFF back end is unusual in that it does not normally
- call <<_bfd_generic_link_add_archive_symbols>>, because ECOFF
- archives already contain a hash table of symbols. The ECOFF
- back end searches the archive itself to avoid the overhead of
- creating a new hash table.
-
-INODE
-Performing the Final Link, , Adding Symbols to the Hash Table, Linker Functions
-SUBSECTION
- Performing the final link
-
-@cindex _bfd_link_final_link in target vector
-@cindex target vector (_bfd_final_link)
- When all the input files have been processed, the linker calls
- the <<_bfd_final_link>> entry point of the output BFD. This
- routine is responsible for producing the final output file,
- which has several aspects. It must relocate the contents of
- the input sections and copy the data into the output sections.
- It must build an output symbol table including any local
- symbols from the input files and the global symbols from the
- hash table. When producing relocateable output, it must
- modify the input relocs and write them into the output file.
- There may also be object format dependent work to be done.
-
- The linker will also call the <<write_object_contents>> entry
- point when the BFD is closed. The two entry points must work
- together in order to produce the correct output file.
-
- The details of how this works are inevitably dependent upon
- the specific object file format. The a.out
- <<_bfd_final_link>> routine is <<NAME(aout,final_link)>>.
-
-@menu
-@* Information provided by the linker::
-@* Relocating the section contents::
-@* Writing the symbol table::
-@end menu
-
-INODE
-Information provided by the linker, Relocating the section contents, Performing the Final Link, Performing the Final Link
-SUBSUBSECTION
- Information provided by the linker
-
- Before the linker calls the <<_bfd_final_link>> entry point,
- it sets up some data structures for the function to use.
-
- The <<input_bfds>> field of the <<bfd_link_info>> structure
- will point to a list of all the input files included in the
- link. These files are linked through the <<link_next>> field
- of the <<bfd>> structure.
-
- Each section in the output file will have a list of
- <<link_order>> structures attached to the <<link_order_head>>
- field (the <<link_order>> structure is defined in
- <<bfdlink.h>>). These structures describe how to create the
- contents of the output section in terms of the contents of
- various input sections, fill constants, and, eventually, other
- types of information. They also describe relocs that must be
- created by the BFD backend, but do not correspond to any input
- file; this is used to support -Ur, which builds constructors
- while generating a relocateable object file.
-
-INODE
-Relocating the section contents, Writing the symbol table, Information provided by the linker, Performing the Final Link
-SUBSUBSECTION
- Relocating the section contents
-
- The <<_bfd_final_link>> function should look through the
- <<link_order>> structures attached to each section of the
- output file. Each <<link_order>> structure should either be
- handled specially, or it should be passed to the function
- <<_bfd_default_link_order>> which will do the right thing
- (<<_bfd_default_link_order>> is defined in <<linker.c>>).
-
- For efficiency, a <<link_order>> of type
- <<bfd_indirect_link_order>> whose associated section belongs
- to a BFD of the same format as the output BFD must be handled
- specially. This type of <<link_order>> describes part of an
- output section in terms of a section belonging to one of the
- input files. The <<_bfd_final_link>> function should read the
- contents of the section and any associated relocs, apply the
- relocs to the section contents, and write out the modified
- section contents. If performing a relocateable link, the
- relocs themselves must also be modified and written out.
-
-@findex _bfd_relocate_contents
-@findex _bfd_final_link_relocate
- The functions <<_bfd_relocate_contents>> and
- <<_bfd_final_link_relocate>> provide some general support for
- performing the actual relocations, notably overflow checking.
- Their arguments include information about the symbol the
- relocation is against and a <<reloc_howto_type>> argument
- which describes the relocation to perform. These functions
- are defined in <<reloc.c>>.
-
- The a.out function which handles reading, relocating, and
- writing section contents is <<aout_link_input_section>>. The
- actual relocation is done in <<aout_link_input_section_std>>
- and <<aout_link_input_section_ext>>.
-
-INODE
-Writing the symbol table, , Relocating the section contents, Performing the Final Link
-SUBSUBSECTION
- Writing the symbol table
-
- The <<_bfd_final_link>> function must gather all the symbols
- in the input files and write them out. It must also write out
- all the symbols in the global hash table. This must be
- controlled by the <<strip>> and <<discard>> fields of the
- <<bfd_link_info>> structure.
-
- The local symbols of the input files will not have been
- entered into the linker hash table. The <<_bfd_final_link>>
- routine must consider each input file and include the symbols
- in the output file. It may be convenient to do this when
- looking through the <<link_order>> structures, or it may be
- done by stepping through the <<input_bfds>> list.
-
- The <<_bfd_final_link>> routine must also traverse the global
- hash table to gather all the externally visible symbols. It
- is possible that most of the externally visible symbols may be
- written out when considering the symbols of each input file,
- but it is still necessary to traverse the hash table since the
- linker script may have defined some symbols that are not in
- any of the input files.
-
- The <<strip>> field of the <<bfd_link_info>> structure
- controls which symbols are written out. The possible values
- are listed in <<bfdlink.h>>. If the value is <<strip_some>>,
- then the <<keep_hash>> field of the <<bfd_link_info>>
- structure is a hash table of symbols to keep; each symbol
- should be looked up in this hash table, and only symbols which
- are present should be included in the output file.
-
- If the <<strip>> field of the <<bfd_link_info>> structure
- permits local symbols to be written out, the <<discard>> field
- is used to further controls which local symbols are included
- in the output file. If the value is <<discard_l>>, then all
- local symbols which begin with a certain prefix are discarded;
- this prefix is described by the <<lprefix>> and
- <<lprefix_len>> fields of the <<bfd_link_info>> structure.
-
- The a.out backend handles symbols by calling
- <<aout_link_write_symbols>> on each input BFD and then
- traversing the global hash table with the function
- <<aout_link_write_other_symbol>>. It builds a string table
- while writing out the symbols, which is written to the output
- file at the end of <<NAME(aout,final_link)>>.
-*/
-
-static struct bfd_hash_entry *generic_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
- const char *));
-static boolean generic_link_read_symbols
- PARAMS ((bfd *));
-static boolean generic_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *, boolean collect));
-static boolean generic_link_add_object_symbols
- PARAMS ((bfd *, struct bfd_link_info *, boolean collect));
-static boolean generic_link_check_archive_element_no_collect
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
-static boolean generic_link_check_archive_element_collect
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
-static boolean generic_link_check_archive_element
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded, boolean collect));
-static boolean generic_link_add_symbol_list
- PARAMS ((bfd *, struct bfd_link_info *, bfd_size_type count, asymbol **,
- boolean collect));
-static bfd *hash_entry_bfd PARAMS ((struct bfd_link_hash_entry *));
-static void set_symbol_from_hash
- PARAMS ((asymbol *, struct bfd_link_hash_entry *));
-static boolean generic_add_output_symbol
- PARAMS ((bfd *, size_t *psymalloc, asymbol *));
-static boolean default_fill_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-static boolean default_indirect_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *, boolean));
-
-/* The link hash table structure is defined in bfdlink.h. It provides
- a base hash table which the backend specific hash tables are built
- upon. */
-
-/* Routine to create an entry in the link hash table. */
-
-struct bfd_hash_entry *
-_bfd_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct bfd_link_hash_entry *ret = (struct bfd_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct bfd_link_hash_entry *) NULL)
- ret = ((struct bfd_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry)));
- if (ret == (struct bfd_link_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct bfd_link_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- ret->type = bfd_link_hash_new;
- ret->next = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize a link hash table. The BFD argument is the one
- responsible for creating this table. */
-
-boolean
-_bfd_link_hash_table_init (table, abfd, newfunc)
- struct bfd_link_hash_table *table;
- bfd *abfd;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- table->creator = abfd->xvec;
- table->undefs = NULL;
- table->undefs_tail = NULL;
- return bfd_hash_table_init (&table->table, newfunc);
-}
-
-/* Look up a symbol in a link hash table. If follow is true, we
- follow bfd_link_hash_indirect and bfd_link_hash_warning links to
- the real symbol. */
-
-struct bfd_link_hash_entry *
-bfd_link_hash_lookup (table, string, create, copy, follow)
- struct bfd_link_hash_table *table;
- const char *string;
- boolean create;
- boolean copy;
- boolean follow;
-{
- struct bfd_link_hash_entry *ret;
-
- ret = ((struct bfd_link_hash_entry *)
- bfd_hash_lookup (&table->table, string, create, copy));
-
- if (follow && ret != (struct bfd_link_hash_entry *) NULL)
- {
- while (ret->type == bfd_link_hash_indirect
- || ret->type == bfd_link_hash_warning)
- ret = ret->u.i.link;
- }
-
- return ret;
-}
-
-/* Look up a symbol in the main linker hash table if the symbol might
- be wrapped. This should only be used for references to an
- undefined symbol, not for definitions of a symbol. */
-
-struct bfd_link_hash_entry *
-bfd_wrapped_link_hash_lookup (abfd, info, string, create, copy, follow)
- bfd *abfd;
- struct bfd_link_info *info;
- const char *string;
- boolean create;
- boolean copy;
- boolean follow;
-{
- if (info->wrap_hash != NULL)
- {
- const char *l;
-
- l = string;
- if (*l == bfd_get_symbol_leading_char (abfd))
- ++l;
-
-#undef WRAP
-#define WRAP "__wrap_"
-
- if (bfd_hash_lookup (info->wrap_hash, l, false, false) != NULL)
- {
- char *n;
- struct bfd_link_hash_entry *h;
-
- /* This symbol is being wrapped. We want to replace all
- references to SYM with references to __wrap_SYM. */
-
- n = (char *) bfd_malloc (strlen (l) + sizeof WRAP + 1);
- if (n == NULL)
- return NULL;
-
- /* Note that symbol_leading_char may be '\0'. */
- n[0] = bfd_get_symbol_leading_char (abfd);
- n[1] = '\0';
- strcat (n, WRAP);
- strcat (n, l);
- h = bfd_link_hash_lookup (info->hash, n, create, true, follow);
- free (n);
- return h;
- }
-
-#undef WRAP
-
-#undef REAL
-#define REAL "__real_"
-
- if (*l == '_'
- && strncmp (l, REAL, sizeof REAL - 1) == 0
- && bfd_hash_lookup (info->wrap_hash, l + sizeof REAL - 1,
- false, false) != NULL)
- {
- char *n;
- struct bfd_link_hash_entry *h;
-
- /* This is a reference to __real_SYM, where SYM is being
- wrapped. We want to replace all references to __real_SYM
- with references to SYM. */
-
- n = (char *) bfd_malloc (strlen (l + sizeof REAL - 1) + 2);
- if (n == NULL)
- return NULL;
-
- /* Note that symbol_leading_char may be '\0'. */
- n[0] = bfd_get_symbol_leading_char (abfd);
- n[1] = '\0';
- strcat (n, l + sizeof REAL - 1);
- h = bfd_link_hash_lookup (info->hash, n, create, true, follow);
- free (n);
- return h;
- }
-
-#undef REAL
- }
-
- return bfd_link_hash_lookup (info->hash, string, create, copy, follow);
-}
-
-/* Traverse a generic link hash table. The only reason this is not a
- macro is to do better type checking. This code presumes that an
- argument passed as a struct bfd_hash_entry * may be caught as a
- struct bfd_link_hash_entry * with no explicit cast required on the
- call. */
-
-void
-bfd_link_hash_traverse (table, func, info)
- struct bfd_link_hash_table *table;
- boolean (*func) PARAMS ((struct bfd_link_hash_entry *, PTR));
- PTR info;
-{
- bfd_hash_traverse (&table->table,
- ((boolean (*) PARAMS ((struct bfd_hash_entry *, PTR)))
- func),
- info);
-}
-
-/* Add a symbol to the linker hash table undefs list. */
-
-INLINE void
-bfd_link_add_undef (table, h)
- struct bfd_link_hash_table *table;
- struct bfd_link_hash_entry *h;
-{
- BFD_ASSERT (h->next == NULL);
- if (table->undefs_tail != (struct bfd_link_hash_entry *) NULL)
- table->undefs_tail->next = h;
- if (table->undefs == (struct bfd_link_hash_entry *) NULL)
- table->undefs = h;
- table->undefs_tail = h;
-}
-
-/* Routine to create an entry in an generic link hash table. */
-
-static struct bfd_hash_entry *
-generic_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct generic_link_hash_entry *ret =
- (struct generic_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct generic_link_hash_entry *) NULL)
- ret = ((struct generic_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct generic_link_hash_entry)));
- if (ret == (struct generic_link_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct generic_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
-
- if (ret)
- {
- /* Set local fields. */
- ret->written = false;
- ret->sym = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create an generic link hash table. */
-
-struct bfd_link_hash_table *
-_bfd_generic_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct generic_link_hash_table *ret;
-
- ret = ((struct generic_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct generic_link_hash_table)));
- if (ret == NULL)
- return (struct bfd_link_hash_table *) NULL;
- if (! _bfd_link_hash_table_init (&ret->root, abfd,
- generic_link_hash_newfunc))
- {
- free (ret);
- return (struct bfd_link_hash_table *) NULL;
- }
- return &ret->root;
-}
-
-/* Grab the symbols for an object file when doing a generic link. We
- store the symbols in the outsymbols field. We need to keep them
- around for the entire link to ensure that we only read them once.
- If we read them multiple times, we might wind up with relocs and
- the hash table pointing to different instances of the symbol
- structure. */
-
-static boolean
-generic_link_read_symbols (abfd)
- bfd *abfd;
-{
- if (abfd->outsymbols == (asymbol **) NULL)
- {
- long symsize;
- long symcount;
-
- symsize = bfd_get_symtab_upper_bound (abfd);
- if (symsize < 0)
- return false;
- abfd->outsymbols = (asymbol **) bfd_alloc (abfd, symsize);
- if (abfd->outsymbols == NULL && symsize != 0)
- return false;
- symcount = bfd_canonicalize_symtab (abfd, abfd->outsymbols);
- if (symcount < 0)
- return false;
- abfd->symcount = symcount;
- }
-
- return true;
-}
-
-/* Generic function to add symbols to from an object file to the
- global hash table. This version does not automatically collect
- constructors by name. */
-
-boolean
-_bfd_generic_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- return generic_link_add_symbols (abfd, info, false);
-}
-
-/* Generic function to add symbols from an object file to the global
- hash table. This version automatically collects constructors by
- name, as the collect2 program does. It should be used for any
- target which does not provide some other mechanism for setting up
- constructors and destructors; these are approximately those targets
- for which gcc uses collect2 and do not support stabs. */
-
-boolean
-_bfd_generic_link_add_symbols_collect (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- return generic_link_add_symbols (abfd, info, true);
-}
-
-/* Add symbols from an object file to the global hash table. */
-
-static boolean
-generic_link_add_symbols (abfd, info, collect)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean collect;
-{
- boolean ret;
-
- switch (bfd_get_format (abfd))
- {
- case bfd_object:
- ret = generic_link_add_object_symbols (abfd, info, collect);
- break;
- case bfd_archive:
- ret = (_bfd_generic_link_add_archive_symbols
- (abfd, info,
- (collect
- ? generic_link_check_archive_element_collect
- : generic_link_check_archive_element_no_collect)));
- break;
- default:
- bfd_set_error (bfd_error_wrong_format);
- ret = false;
- }
-
- return ret;
-}
-
-/* Add symbols from an object file to the global hash table. */
-
-static boolean
-generic_link_add_object_symbols (abfd, info, collect)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean collect;
-{
- if (! generic_link_read_symbols (abfd))
- return false;
- return generic_link_add_symbol_list (abfd, info,
- _bfd_generic_link_get_symcount (abfd),
- _bfd_generic_link_get_symbols (abfd),
- collect);
-}
-
-/* We build a hash table of all symbols defined in an archive. */
-
-/* An archive symbol may be defined by multiple archive elements.
- This linked list is used to hold the elements. */
-
-struct archive_list
-{
- struct archive_list *next;
- int indx;
-};
-
-/* An entry in an archive hash table. */
-
-struct archive_hash_entry
-{
- struct bfd_hash_entry root;
- /* Where the symbol is defined. */
- struct archive_list *defs;
-};
-
-/* An archive hash table itself. */
-
-struct archive_hash_table
-{
- struct bfd_hash_table table;
-};
-
-static struct bfd_hash_entry *archive_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static boolean archive_hash_table_init
- PARAMS ((struct archive_hash_table *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-/* Create a new entry for an archive hash table. */
-
-static struct bfd_hash_entry *
-archive_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct archive_hash_entry *ret = (struct archive_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct archive_hash_entry *) NULL)
- ret = ((struct archive_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct archive_hash_entry)));
- if (ret == (struct archive_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct archive_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- ret->defs = (struct archive_list *) NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize an archive hash table. */
-
-static boolean
-archive_hash_table_init (table, newfunc)
- struct archive_hash_table *table;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- return bfd_hash_table_init (&table->table, newfunc);
-}
-
-/* Look up an entry in an archive hash table. */
-
-#define archive_hash_lookup(t, string, create, copy) \
- ((struct archive_hash_entry *) \
- bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
-
-/* Allocate space in an archive hash table. */
-
-#define archive_hash_allocate(t, size) bfd_hash_allocate (&(t)->table, (size))
-
-/* Free an archive hash table. */
-
-#define archive_hash_table_free(t) bfd_hash_table_free (&(t)->table)
-
-/* Generic function to add symbols from an archive file to the global
- hash file. This function presumes that the archive symbol table
- has already been read in (this is normally done by the
- bfd_check_format entry point). It looks through the undefined and
- common symbols and searches the archive symbol table for them. If
- it finds an entry, it includes the associated object file in the
- link.
-
- The old linker looked through the archive symbol table for
- undefined symbols. We do it the other way around, looking through
- undefined symbols for symbols defined in the archive. The
- advantage of the newer scheme is that we only have to look through
- the list of undefined symbols once, whereas the old method had to
- re-search the symbol table each time a new object file was added.
-
- The CHECKFN argument is used to see if an object file should be
- included. CHECKFN should set *PNEEDED to true if the object file
- should be included, and must also call the bfd_link_info
- add_archive_element callback function and handle adding the symbols
- to the global hash table. CHECKFN should only return false if some
- sort of error occurs.
-
- For some formats, such as a.out, it is possible to look through an
- object file but not actually include it in the link. The
- archive_pass field in a BFD is used to avoid checking the symbols
- of an object files too many times. When an object is included in
- the link, archive_pass is set to -1. If an object is scanned but
- not included, archive_pass is set to the pass number. The pass
- number is incremented each time a new object file is included. The
- pass number is used because when a new object file is included it
- may create new undefined symbols which cause a previously examined
- object file to be included. */
-
-boolean
-_bfd_generic_link_add_archive_symbols (abfd, info, checkfn)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean (*checkfn) PARAMS ((bfd *, struct bfd_link_info *,
- boolean *pneeded));
-{
- carsym *arsyms;
- carsym *arsym_end;
- register carsym *arsym;
- int pass;
- struct archive_hash_table arsym_hash;
- int indx;
- struct bfd_link_hash_entry **pundef;
-
- 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;
- }
-
- arsyms = bfd_ardata (abfd)->symdefs;
- arsym_end = arsyms + bfd_ardata (abfd)->symdef_count;
-
- /* In order to quickly determine whether an symbol is defined in
- this archive, we build a hash table of the symbols. */
- if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc))
- return false;
- for (arsym = arsyms, indx = 0; arsym < arsym_end; arsym++, indx++)
- {
- struct archive_hash_entry *arh;
- struct archive_list *l, **pp;
-
- arh = archive_hash_lookup (&arsym_hash, arsym->name, true, false);
- if (arh == (struct archive_hash_entry *) NULL)
- goto error_return;
- l = ((struct archive_list *)
- archive_hash_allocate (&arsym_hash, sizeof (struct archive_list)));
- if (l == NULL)
- goto error_return;
- l->indx = indx;
- for (pp = &arh->defs;
- *pp != (struct archive_list *) NULL;
- pp = &(*pp)->next)
- ;
- *pp = l;
- l->next = NULL;
- }
-
- /* The archive_pass field in the archive itself is used to
- initialize PASS, sine we may search the same archive multiple
- times. */
- pass = abfd->archive_pass + 1;
-
- /* New undefined symbols are added to the end of the list, so we
- only need to look through it once. */
- pundef = &info->hash->undefs;
- while (*pundef != (struct bfd_link_hash_entry *) NULL)
- {
- struct bfd_link_hash_entry *h;
- struct archive_hash_entry *arh;
- struct archive_list *l;
-
- h = *pundef;
-
- /* When a symbol is defined, it is not necessarily removed from
- the list. */
- if (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common)
- {
- /* Remove this entry from the list, for general cleanliness
- and because we are going to look through the list again
- if we search any more libraries. We can't remove the
- entry if it is the tail, because that would lose any
- entries we add to the list later on (it would also cause
- us to lose track of whether the symbol has been
- referenced). */
- if (*pundef != info->hash->undefs_tail)
- *pundef = (*pundef)->next;
- else
- pundef = &(*pundef)->next;
- continue;
- }
-
- /* Look for this symbol in the archive symbol map. */
- arh = archive_hash_lookup (&arsym_hash, h->root.string, false, false);
- if (arh == (struct archive_hash_entry *) NULL)
- {
- pundef = &(*pundef)->next;
- continue;
- }
-
- /* Look at all the objects which define this symbol. */
- for (l = arh->defs; l != (struct archive_list *) NULL; l = l->next)
- {
- bfd *element;
- boolean needed;
-
- /* If the symbol has gotten defined along the way, quit. */
- if (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common)
- break;
-
- element = bfd_get_elt_at_index (abfd, l->indx);
- if (element == (bfd *) NULL)
- goto error_return;
-
- /* If we've already included this element, or if we've
- already checked it on this pass, continue. */
- if (element->archive_pass == -1
- || element->archive_pass == pass)
- continue;
-
- /* If we can't figure this element out, just ignore it. */
- if (! bfd_check_format (element, bfd_object))
- {
- element->archive_pass = -1;
- continue;
- }
-
- /* CHECKFN will see if this element should be included, and
- go ahead and include it if appropriate. */
- if (! (*checkfn) (element, info, &needed))
- goto error_return;
-
- if (! needed)
- element->archive_pass = pass;
- else
- {
- element->archive_pass = -1;
-
- /* Increment the pass count to show that we may need to
- recheck object files which were already checked. */
- ++pass;
- }
- }
-
- pundef = &(*pundef)->next;
- }
-
- archive_hash_table_free (&arsym_hash);
-
- /* Save PASS in case we are called again. */
- abfd->archive_pass = pass;
-
- return true;
-
- error_return:
- archive_hash_table_free (&arsym_hash);
- return false;
-}
-
-/* See if we should include an archive element. This version is used
- when we do not want to automatically collect constructors based on
- the symbol name, presumably because we have some other mechanism
- for finding them. */
-
-static boolean
-generic_link_check_archive_element_no_collect (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- return generic_link_check_archive_element (abfd, info, pneeded, false);
-}
-
-/* See if we should include an archive element. This version is used
- when we want to automatically collect constructors based on the
- symbol name, as collect2 does. */
-
-static boolean
-generic_link_check_archive_element_collect (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- return generic_link_check_archive_element (abfd, info, pneeded, true);
-}
-
-/* See if we should include an archive element. Optionally collect
- constructors. */
-
-static boolean
-generic_link_check_archive_element (abfd, info, pneeded, collect)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
- boolean collect;
-{
- asymbol **pp, **ppend;
-
- *pneeded = false;
-
- if (! generic_link_read_symbols (abfd))
- return false;
-
- pp = _bfd_generic_link_get_symbols (abfd);
- ppend = pp + _bfd_generic_link_get_symcount (abfd);
- for (; pp < ppend; pp++)
- {
- asymbol *p;
- struct bfd_link_hash_entry *h;
-
- p = *pp;
-
- /* We are only interested in globally visible symbols. */
- if (! bfd_is_com_section (p->section)
- && (p->flags & (BSF_GLOBAL | BSF_INDIRECT | BSF_WEAK)) == 0)
- continue;
-
- /* We are only interested if we know something about this
- symbol, and it is undefined or common. An undefined weak
- symbol (type bfd_link_hash_undefweak) is not considered to be
- a reference when pulling files out of an archive. See the
- SVR4 ABI, p. 4-27. */
- h = bfd_link_hash_lookup (info->hash, bfd_asymbol_name (p), false,
- false, true);
- if (h == (struct bfd_link_hash_entry *) NULL
- || (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common))
- continue;
-
- /* P is a symbol we are looking for. */
-
- if (! bfd_is_com_section (p->section))
- {
- bfd_size_type symcount;
- asymbol **symbols;
-
- /* This object file defines this symbol, so pull it in. */
- if (! (*info->callbacks->add_archive_element) (info, abfd,
- bfd_asymbol_name (p)))
- return false;
- symcount = _bfd_generic_link_get_symcount (abfd);
- symbols = _bfd_generic_link_get_symbols (abfd);
- if (! generic_link_add_symbol_list (abfd, info, symcount,
- symbols, collect))
- return false;
- *pneeded = true;
- return true;
- }
-
- /* P is a common symbol. */
-
- if (h->type == bfd_link_hash_undefined)
- {
- bfd *symbfd;
- bfd_vma size;
- unsigned int power;
-
- symbfd = h->u.undef.abfd;
- if (symbfd == (bfd *) NULL)
- {
- /* This symbol was created as undefined from outside
- BFD. We assume that we should link in the object
- file. This is for the -u option in the linker. */
- if (! (*info->callbacks->add_archive_element)
- (info, abfd, bfd_asymbol_name (p)))
- return false;
- *pneeded = true;
- return true;
- }
-
- /* Turn the symbol into a common symbol but do not link in
- the object file. This is how a.out works. Object
- formats that require different semantics must implement
- this function differently. This symbol is already on the
- undefs list. We add the section to a common section
- attached to symbfd to ensure that it is in a BFD which
- will be linked in. */
- h->type = bfd_link_hash_common;
- h->u.c.p =
- ((struct bfd_link_hash_common_entry *)
- bfd_hash_allocate (&info->hash->table,
- sizeof (struct bfd_link_hash_common_entry)));
- if (h->u.c.p == NULL)
- return false;
-
- size = bfd_asymbol_value (p);
- h->u.c.size = size;
-
- power = bfd_log2 (size);
- if (power > 4)
- power = 4;
- h->u.c.p->alignment_power = power;
-
- if (p->section == bfd_com_section_ptr)
- h->u.c.p->section = bfd_make_section_old_way (symbfd, "COMMON");
- else
- h->u.c.p->section = bfd_make_section_old_way (symbfd,
- p->section->name);
- h->u.c.p->section->flags = SEC_ALLOC;
- }
- else
- {
- /* Adjust the size of the common symbol if necessary. This
- is how a.out works. Object formats that require
- different semantics must implement this function
- differently. */
- if (bfd_asymbol_value (p) > h->u.c.size)
- h->u.c.size = bfd_asymbol_value (p);
- }
- }
-
- /* This archive element is not needed. */
- return true;
-}
-
-/* Add the symbols from an object file to the global hash table. ABFD
- is the object file. INFO is the linker information. SYMBOL_COUNT
- is the number of symbols. SYMBOLS is the list of symbols. COLLECT
- is true if constructors should be automatically collected by name
- as is done by collect2. */
-
-static boolean
-generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
- bfd *abfd;
- struct bfd_link_info *info;
- bfd_size_type symbol_count;
- asymbol **symbols;
- boolean collect;
-{
- asymbol **pp, **ppend;
-
- pp = symbols;
- ppend = symbols + symbol_count;
- for (; pp < ppend; pp++)
- {
- asymbol *p;
-
- p = *pp;
-
- if ((p->flags & (BSF_INDIRECT
- | BSF_WARNING
- | BSF_GLOBAL
- | BSF_CONSTRUCTOR
- | BSF_WEAK)) != 0
- || bfd_is_und_section (bfd_get_section (p))
- || bfd_is_com_section (bfd_get_section (p))
- || bfd_is_ind_section (bfd_get_section (p)))
- {
- const char *name;
- const char *string;
- struct generic_link_hash_entry *h;
-
- name = bfd_asymbol_name (p);
- if (((p->flags & BSF_INDIRECT) != 0
- || bfd_is_ind_section (p->section))
- && pp + 1 < ppend)
- {
- pp++;
- string = bfd_asymbol_name (*pp);
- }
- else if ((p->flags & BSF_WARNING) != 0
- && pp + 1 < ppend)
- {
- /* The name of P is actually the warning string, and the
- next symbol is the one to warn about. */
- string = name;
- pp++;
- name = bfd_asymbol_name (*pp);
- }
- else
- string = NULL;
-
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, name, p->flags, bfd_get_section (p),
- p->value, string, false, collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
-
- /* If this is a constructor symbol, and the linker didn't do
- anything with it, then we want to just pass the symbol
- through to the output file. This will happen when
- linking with -r. */
- if ((p->flags & BSF_CONSTRUCTOR) != 0
- && (h == NULL || h->root.type == bfd_link_hash_new))
- {
- p->udata.p = NULL;
- continue;
- }
-
- /* Save the BFD symbol so that we don't lose any backend
- specific information that may be attached to it. We only
- want this one if it gives more information than the
- existing one; we don't want to replace a defined symbol
- with an undefined one. This routine may be called with a
- hash table other than the generic hash table, so we only
- do this if we are certain that the hash table is a
- generic one. */
- if (info->hash->creator == abfd->xvec)
- {
- if (h->sym == (asymbol *) NULL
- || (! bfd_is_und_section (bfd_get_section (p))
- && (! bfd_is_com_section (bfd_get_section (p))
- || bfd_is_und_section (bfd_get_section (h->sym)))))
- {
- h->sym = p;
- /* BSF_OLD_COMMON is a hack to support COFF reloc
- reading, and it should go away when the COFF
- linker is switched to the new version. */
- if (bfd_is_com_section (bfd_get_section (p)))
- p->flags |= BSF_OLD_COMMON;
- }
-
- /* Store a back pointer from the symbol to the hash
- table entry for the benefit of relaxation code until
- it gets rewritten to not use asymbol structures.
- Setting this is also used to check whether these
- symbols were set up by the generic linker. */
- p->udata.p = (PTR) h;
- }
- }
- }
-
- return true;
-}
-
-/* We use a state table to deal with adding symbols from an object
- file. The first index into the state table describes the symbol
- from the object file. The second index into the state table is the
- type of the symbol in the hash table. */
-
-/* The symbol from the object file is turned into one of these row
- values. */
-
-enum link_row
-{
- UNDEF_ROW, /* Undefined. */
- UNDEFW_ROW, /* Weak undefined. */
- DEF_ROW, /* Defined. */
- DEFW_ROW, /* Weak defined. */
- COMMON_ROW, /* Common. */
- INDR_ROW, /* Indirect. */
- WARN_ROW, /* Warning. */
- SET_ROW /* Member of set. */
-};
-
-/* apparently needed for Hitachi 3050R(HI-UX/WE2)? */
-#undef FAIL
-
-/* The actions to take in the state table. */
-
-enum link_action
-{
- FAIL, /* Abort. */
- UND, /* Mark symbol undefined. */
- WEAK, /* Mark symbol weak undefined. */
- DEF, /* Mark symbol defined. */
- DEFW, /* Mark symbol weak defined. */
- COM, /* Mark symbol common. */
- REF, /* Mark defined symbol referenced. */
- CREF, /* Possibly warn about common reference to defined symbol. */
- CDEF, /* Define existing common symbol. */
- NOACT, /* No action. */
- BIG, /* Mark symbol common using largest size. */
- MDEF, /* Multiple definition error. */
- MIND, /* Multiple indirect symbols. */
- IND, /* Make indirect symbol. */
- CIND, /* Make indirect symbol from existing common symbol. */
- SET, /* Add value to set. */
- MWARN, /* Make warning symbol. */
- WARN, /* Issue warning. */
- CWARN, /* Warn if referenced, else MWARN. */
- CYCLE, /* Repeat with symbol pointed to. */
- REFC, /* Mark indirect symbol referenced and then CYCLE. */
- WARNC /* Issue warning and then CYCLE. */
-};
-
-/* The state table itself. The first index is a link_row and the
- second index is a bfd_link_hash_type. */
-
-static const enum link_action link_action[8][8] =
-{
- /* current\prev new undef undefw def defw com indr warn */
- /* UNDEF_ROW */ {UND, NOACT, UND, REF, REF, NOACT, REFC, WARNC },
- /* UNDEFW_ROW */ {WEAK, NOACT, NOACT, REF, REF, NOACT, REFC, WARNC },
- /* DEF_ROW */ {DEF, DEF, DEF, MDEF, DEF, CDEF, MDEF, CYCLE },
- /* DEFW_ROW */ {DEFW, DEFW, DEFW, NOACT, NOACT, NOACT, NOACT, CYCLE },
- /* COMMON_ROW */ {COM, COM, COM, CREF, CREF, BIG, CREF, WARNC },
- /* INDR_ROW */ {IND, IND, IND, MDEF, IND, CIND, MIND, CYCLE },
- /* WARN_ROW */ {MWARN, WARN, WARN, CWARN, CWARN, WARN, CWARN, CYCLE },
- /* SET_ROW */ {SET, SET, SET, SET, SET, SET, CYCLE, CYCLE }
-};
-
-/* Most of the entries in the LINK_ACTION table are straightforward,
- but a few are somewhat subtle.
-
- A reference to an indirect symbol (UNDEF_ROW/indr or
- UNDEFW_ROW/indr) is counted as a reference both to the indirect
- symbol and to the symbol the indirect symbol points to.
-
- A reference to a warning symbol (UNDEF_ROW/warn or UNDEFW_ROW/warn)
- causes the warning to be issued.
-
- A common definition of an indirect symbol (COMMON_ROW/indr) is
- treated as a multiple definition error. Likewise for an indirect
- definition of a common symbol (INDR_ROW/com).
-
- An indirect definition of a warning (INDR_ROW/warn) does not cause
- the warning to be issued.
-
- If a warning is created for an indirect symbol (WARN_ROW/indr) no
- warning is created for the symbol the indirect symbol points to.
-
- Adding an entry to a set does not count as a reference to a set,
- and no warning is issued (SET_ROW/warn). */
-
-/* Return the BFD in which a hash entry has been defined, if known. */
-
-static bfd *
-hash_entry_bfd (h)
- struct bfd_link_hash_entry *h;
-{
- while (h->type == bfd_link_hash_warning)
- h = h->u.i.link;
- switch (h->type)
- {
- default:
- return NULL;
- case bfd_link_hash_undefined:
- case bfd_link_hash_undefweak:
- return h->u.undef.abfd;
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- return h->u.def.section->owner;
- case bfd_link_hash_common:
- return h->u.c.p->section->owner;
- }
- /*NOTREACHED*/
-}
-
-/* Add a symbol to the global hash table.
- ABFD is the BFD the symbol comes from.
- NAME is the name of the symbol.
- FLAGS is the BSF_* bits associated with the symbol.
- SECTION is the section in which the symbol is defined; this may be
- bfd_und_section_ptr or bfd_com_section_ptr.
- VALUE is the value of the symbol, relative to the section.
- STRING is used for either an indirect symbol, in which case it is
- the name of the symbol to indirect to, or a warning symbol, in
- which case it is the warning string.
- COPY is true if NAME or STRING must be copied into locally
- allocated memory if they need to be saved.
- COLLECT is true if we should automatically collect gcc constructor
- or destructor names as collect2 does.
- HASHP, if not NULL, is a place to store the created hash table
- entry; if *HASHP is not NULL, the caller has already looked up
- the hash table entry, and stored it in *HASHP. */
-
-boolean
-_bfd_generic_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;
-{
- enum link_row row;
- struct bfd_link_hash_entry *h;
- boolean cycle;
-
- if (bfd_is_ind_section (section)
- || (flags & BSF_INDIRECT) != 0)
- row = INDR_ROW;
- else if ((flags & BSF_WARNING) != 0)
- row = WARN_ROW;
- else if ((flags & BSF_CONSTRUCTOR) != 0)
- row = SET_ROW;
- else if (bfd_is_und_section (section))
- {
- if ((flags & BSF_WEAK) != 0)
- row = UNDEFW_ROW;
- else
- row = UNDEF_ROW;
- }
- else if ((flags & BSF_WEAK) != 0)
- row = DEFW_ROW;
- else if (bfd_is_com_section (section))
- row = COMMON_ROW;
- else
- row = DEF_ROW;
-
- if (hashp != NULL && *hashp != NULL)
- h = *hashp;
- else
- {
- if (row == UNDEF_ROW || row == UNDEFW_ROW)
- h = bfd_wrapped_link_hash_lookup (abfd, info, name, true, copy, false);
- 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;
-
- do
- {
- enum link_action action;
-
- cycle = false;
- action = link_action[(int) row][(int) h->type];
- switch (action)
- {
- case FAIL:
- abort ();
-
- case NOACT:
- /* Do nothing. */
- break;
-
- case UND:
- /* Make a new undefined symbol. */
- h->type = bfd_link_hash_undefined;
- h->u.undef.abfd = abfd;
- bfd_link_add_undef (info->hash, h);
- break;
-
- case WEAK:
- /* Make a new weak undefined symbol. */
- h->type = bfd_link_hash_undefweak;
- h->u.undef.abfd = abfd;
- break;
-
- case CDEF:
- /* We have found a definition for a symbol which was
- previously common. */
- BFD_ASSERT (h->type == bfd_link_hash_common);
- if (! ((*info->callbacks->multiple_common)
- (info, name,
- h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
- abfd, bfd_link_hash_defined, (bfd_vma) 0)))
- return false;
- /* Fall through. */
- case DEF:
- case DEFW:
- {
- enum bfd_link_hash_type oldtype;
-
- /* Define a symbol. */
- oldtype = h->type;
- if (action == DEFW)
- h->type = bfd_link_hash_defweak;
- else
- h->type = bfd_link_hash_defined;
- h->u.def.section = section;
- h->u.def.value = value;
-
- /* If we have been asked to, we act like collect2 and
- identify all functions that might be global
- constructors and destructors and pass them up in a
- callback. We only do this for certain object file
- types, since many object file types can handle this
- automatically. */
- if (collect && name[0] == '_')
- {
- const char *s;
-
- /* A constructor or destructor name starts like this:
- _+GLOBAL_[_.$][ID][_.$] where the first [_.$] and
- the second are the same character (we accept any
- character there, in case a new object file format
- comes along with even worse naming restrictions). */
-
-#define CONS_PREFIX "GLOBAL_"
-#define CONS_PREFIX_LEN (sizeof CONS_PREFIX - 1)
-
- s = name + 1;
- while (*s == '_')
- ++s;
- if (s[0] == 'G'
- && strncmp (s, CONS_PREFIX, CONS_PREFIX_LEN - 1) == 0)
- {
- char c;
-
- c = s[CONS_PREFIX_LEN + 1];
- if ((c == 'I' || c == 'D')
- && s[CONS_PREFIX_LEN] == s[CONS_PREFIX_LEN + 2])
- {
- /* If this is a definition of a symbol which
- was previously weakly defined, we are in
- trouble. We have already added a
- constructor entry for the weak defined
- symbol, and now we are trying to add one
- for the new symbol. Fortunately, this case
- should never arise in practice. */
- if (oldtype == bfd_link_hash_defweak)
- abort ();
-
- if (! ((*info->callbacks->constructor)
- (info,
- c == 'I' ? true : false,
- name, abfd, section, value)))
- return false;
- }
- }
- }
- }
-
- break;
-
- case COM:
- /* We have found a common definition for a symbol. */
- if (h->type == bfd_link_hash_new)
- bfd_link_add_undef (info->hash, h);
- h->type = bfd_link_hash_common;
- h->u.c.p =
- ((struct bfd_link_hash_common_entry *)
- bfd_hash_allocate (&info->hash->table,
- sizeof (struct bfd_link_hash_common_entry)));
- if (h->u.c.p == NULL)
- return false;
-
- h->u.c.size = value;
-
- /* Select a default alignment based on the size. This may
- be overridden by the caller. */
- {
- unsigned int power;
-
- power = bfd_log2 (value);
- if (power > 4)
- power = 4;
- h->u.c.p->alignment_power = power;
- }
-
- /* The section of a common symbol is only used if the common
- symbol is actually allocated. It basically provides a
- hook for the linker script to decide which output section
- the common symbols should be put in. In most cases, the
- section of a common symbol will be bfd_com_section_ptr,
- the code here will choose a common symbol section named
- "COMMON", and the linker script will contain *(COMMON) in
- the appropriate place. A few targets use separate common
- sections for small symbols, and they require special
- handling. */
- if (section == bfd_com_section_ptr)
- {
- h->u.c.p->section = bfd_make_section_old_way (abfd, "COMMON");
- h->u.c.p->section->flags = SEC_ALLOC;
- }
- else if (section->owner != abfd)
- {
- h->u.c.p->section = bfd_make_section_old_way (abfd,
- section->name);
- h->u.c.p->section->flags = SEC_ALLOC;
- }
- else
- h->u.c.p->section = section;
- break;
-
- case REF:
- /* A reference to a defined symbol. */
- if (h->next == NULL && info->hash->undefs_tail != h)
- h->next = h;
- break;
-
- case BIG:
- /* We have found a common definition for a symbol which
- already had a common definition. Use the maximum of the
- two sizes. */
- BFD_ASSERT (h->type == bfd_link_hash_common);
- if (! ((*info->callbacks->multiple_common)
- (info, name,
- h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
- abfd, bfd_link_hash_common, value)))
- return false;
- if (value > h->u.c.size)
- {
- unsigned int power;
-
- h->u.c.size = value;
-
- /* Select a default alignment based on the size. This may
- be overridden by the caller. */
- power = bfd_log2 (value);
- if (power > 4)
- power = 4;
- h->u.c.p->alignment_power = power;
- }
- break;
-
- case CREF:
- {
- bfd *obfd;
-
- /* We have found a common definition for a symbol which
- was already defined. FIXME: It would nice if we could
- report the BFD which defined an indirect symbol, but we
- don't have anywhere to store the information. */
- if (h->type == bfd_link_hash_defined
- || h->type == bfd_link_hash_defweak)
- obfd = h->u.def.section->owner;
- else
- obfd = NULL;
- if (! ((*info->callbacks->multiple_common)
- (info, name, obfd, h->type, (bfd_vma) 0,
- abfd, bfd_link_hash_common, value)))
- return false;
- }
- break;
-
- case MIND:
- /* Multiple indirect symbols. This is OK if they both point
- to the same symbol. */
- if (strcmp (h->u.i.link->root.string, string) == 0)
- break;
- /* Fall through. */
- case MDEF:
- /* Handle a multiple definition. */
- {
- asection *msec;
- bfd_vma mval;
-
- switch (h->type)
- {
- case bfd_link_hash_defined:
- msec = h->u.def.section;
- mval = h->u.def.value;
- break;
- case bfd_link_hash_indirect:
- msec = bfd_ind_section_ptr;
- mval = 0;
- break;
- default:
- abort ();
- }
-
- /* Ignore a redefinition of an absolute symbol to the same
- value; it's harmless. */
- if (h->type == bfd_link_hash_defined
- && bfd_is_abs_section (msec)
- && bfd_is_abs_section (section)
- && value == mval)
- break;
-
- if (! ((*info->callbacks->multiple_definition)
- (info, name, msec->owner, msec, mval, abfd, section,
- value)))
- return false;
- }
- break;
-
- case CIND:
- /* Create an indirect symbol from an existing common symbol. */
- BFD_ASSERT (h->type == bfd_link_hash_common);
- if (! ((*info->callbacks->multiple_common)
- (info, name,
- h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
- abfd, bfd_link_hash_indirect, (bfd_vma) 0)))
- return false;
- /* Fall through. */
- case IND:
- /* Create an indirect symbol. */
- {
- struct bfd_link_hash_entry *inh;
-
- /* STRING is the name of the symbol we want to indirect
- to. */
- inh = bfd_wrapped_link_hash_lookup (abfd, info, string, true,
- copy, false);
- if (inh == (struct bfd_link_hash_entry *) NULL)
- return false;
- if (inh->type == bfd_link_hash_new)
- {
- inh->type = bfd_link_hash_undefined;
- inh->u.undef.abfd = abfd;
- bfd_link_add_undef (info->hash, inh);
- }
-
- /* If the indirect symbol has been referenced, we need to
- push the reference down to the symbol we are
- referencing. */
- if (h->type != bfd_link_hash_new)
- {
- row = UNDEF_ROW;
- cycle = true;
- }
-
- h->type = bfd_link_hash_indirect;
- h->u.i.link = inh;
- }
- break;
-
- case SET:
- /* Add an entry to a set. */
- if (! (*info->callbacks->add_to_set) (info, h, BFD_RELOC_CTOR,
- abfd, section, value))
- return false;
- break;
-
- case WARNC:
- /* Issue a warning and cycle. */
- if (h->u.i.warning != NULL)
- {
- if (! (*info->callbacks->warning) (info, h->u.i.warning, name,
- abfd, (asection *) NULL,
- (bfd_vma) 0))
- return false;
- /* Only issue a warning once. */
- h->u.i.warning = NULL;
- }
- /* Fall through. */
- case CYCLE:
- /* Try again with the referenced symbol. */
- h = h->u.i.link;
- cycle = true;
- break;
-
- case REFC:
- /* A reference to an indirect symbol. */
- if (h->next == NULL && info->hash->undefs_tail != h)
- h->next = h;
- h = h->u.i.link;
- cycle = true;
- break;
-
- case WARN:
- /* Issue a warning. */
- if (! (*info->callbacks->warning) (info, string, name,
- hash_entry_bfd (h),
- (asection *) NULL, (bfd_vma) 0))
- return false;
- break;
-
- case CWARN:
- /* Warn if this symbol has been referenced already,
- otherwise add a warning. A symbol has been referenced if
- the next field is not NULL, or it is the tail of the
- undefined symbol list. The REF case above helps to
- ensure this. */
- if (h->next != NULL || info->hash->undefs_tail == h)
- {
- if (! (*info->callbacks->warning) (info, string, name,
- hash_entry_bfd (h),
- (asection *) NULL,
- (bfd_vma) 0))
- return false;
- break;
- }
- /* Fall through. */
- case MWARN:
- /* Make a warning symbol. */
- {
- struct bfd_link_hash_entry *sub;
-
- /* STRING is the warning to give. */
- sub = ((struct bfd_link_hash_entry *)
- ((*info->hash->table.newfunc)
- ((struct bfd_hash_entry *) NULL, &info->hash->table,
- h->root.string)));
- if (sub == NULL)
- return false;
- *sub = *h;
- sub->type = bfd_link_hash_warning;
- sub->u.i.link = h;
- if (! copy)
- sub->u.i.warning = string;
- else
- {
- char *w;
-
- w = bfd_hash_allocate (&info->hash->table,
- strlen (string) + 1);
- if (w == NULL)
- return false;
- strcpy (w, string);
- sub->u.i.warning = w;
- }
-
- bfd_hash_replace (&info->hash->table,
- (struct bfd_hash_entry *) h,
- (struct bfd_hash_entry *) sub);
- if (hashp != NULL)
- *hashp = sub;
- }
- break;
- }
- }
- while (cycle);
-
- return true;
-}
-
-/* Generic final link routine. */
-
-boolean
-_bfd_generic_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- bfd *sub;
- asection *o;
- struct bfd_link_order *p;
- size_t outsymalloc;
- struct generic_write_global_symbol_info wginfo;
-
- abfd->outsymbols = (asymbol **) NULL;
- abfd->symcount = 0;
- outsymalloc = 0;
-
- /* Build the output symbol table. */
- for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
- if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc))
- return false;
-
- /* Accumulate the global symbols. */
- wginfo.info = info;
- wginfo.output_bfd = abfd;
- wginfo.psymalloc = &outsymalloc;
- _bfd_generic_link_hash_traverse (_bfd_generic_hash_table (info),
- _bfd_generic_link_write_global_symbol,
- (PTR) &wginfo);
-
- if (info->relocateable)
- {
- /* Allocate space for the output relocs for each section. */
- for (o = abfd->sections;
- o != (asection *) NULL;
- o = o->next)
- {
- o->reloc_count = 0;
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) 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 *input_section;
- bfd *input_bfd;
- long relsize;
- arelent **relocs;
- asymbol **symbols;
- long reloc_count;
-
- input_section = p->u.indirect.section;
- input_bfd = input_section->owner;
- relsize = bfd_get_reloc_upper_bound (input_bfd,
- input_section);
- if (relsize < 0)
- return false;
- relocs = (arelent **) bfd_malloc ((size_t) relsize);
- if (!relocs && relsize != 0)
- return false;
- symbols = _bfd_generic_link_get_symbols (input_bfd);
- reloc_count = bfd_canonicalize_reloc (input_bfd,
- input_section,
- relocs,
- symbols);
- if (reloc_count < 0)
- return false;
- BFD_ASSERT ((unsigned long) reloc_count
- == input_section->reloc_count);
- o->reloc_count += reloc_count;
- free (relocs);
- }
- }
- if (o->reloc_count > 0)
- {
- o->orelocation = ((arelent **)
- bfd_alloc (abfd,
- (o->reloc_count
- * sizeof (arelent *))));
- if (!o->orelocation)
- return false;
- o->flags |= SEC_RELOC;
- /* Reset the count so that it can be used as an index
- when putting in the output relocs. */
- o->reloc_count = 0;
- }
- }
- }
-
- /* Handle all the link order information for the sections. */
- for (o = abfd->sections;
- o != (asection *) NULL;
- o = o->next)
- {
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- switch (p->type)
- {
- case bfd_section_reloc_link_order:
- case bfd_symbol_reloc_link_order:
- if (! _bfd_generic_reloc_link_order (abfd, info, o, p))
- return false;
- break;
- case bfd_indirect_link_order:
- if (! default_indirect_link_order (abfd, info, o, p, true))
- return false;
- break;
- default:
- if (! _bfd_default_link_order (abfd, info, o, p))
- return false;
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Add an output symbol to the output BFD. */
-
-static boolean
-generic_add_output_symbol (output_bfd, psymalloc, sym)
- bfd *output_bfd;
- size_t *psymalloc;
- asymbol *sym;
-{
- if (output_bfd->symcount >= *psymalloc)
- {
- asymbol **newsyms;
-
- if (*psymalloc == 0)
- *psymalloc = 124;
- else
- *psymalloc *= 2;
- newsyms = (asymbol **) bfd_realloc (output_bfd->outsymbols,
- *psymalloc * sizeof (asymbol *));
- if (newsyms == (asymbol **) NULL)
- return false;
- output_bfd->outsymbols = newsyms;
- }
-
- output_bfd->outsymbols[output_bfd->symcount] = sym;
- ++output_bfd->symcount;
-
- return true;
-}
-
-/* Handle the symbols for an input BFD. */
-
-boolean
-_bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
- bfd *output_bfd;
- bfd *input_bfd;
- struct bfd_link_info *info;
- size_t *psymalloc;
-{
- asymbol **sym_ptr;
- asymbol **sym_end;
-
- if (! generic_link_read_symbols (input_bfd))
- return false;
-
- /* Create a filename symbol if we are supposed to. */
- if (info->create_object_symbols_section != (asection *) NULL)
- {
- asection *sec;
-
- for (sec = input_bfd->sections;
- sec != (asection *) NULL;
- sec = sec->next)
- {
- if (sec->output_section == info->create_object_symbols_section)
- {
- asymbol *newsym;
-
- newsym = bfd_make_empty_symbol (input_bfd);
- if (!newsym)
- return false;
- newsym->name = input_bfd->filename;
- newsym->value = 0;
- newsym->flags = BSF_LOCAL | BSF_FILE;
- newsym->section = sec;
-
- if (! generic_add_output_symbol (output_bfd, psymalloc,
- newsym))
- return false;
-
- break;
- }
- }
- }
-
- /* Adjust the values of the globally visible symbols, and write out
- local symbols. */
- sym_ptr = _bfd_generic_link_get_symbols (input_bfd);
- sym_end = sym_ptr + _bfd_generic_link_get_symcount (input_bfd);
- for (; sym_ptr < sym_end; sym_ptr++)
- {
- asymbol *sym;
- struct generic_link_hash_entry *h;
- boolean output;
-
- h = (struct generic_link_hash_entry *) NULL;
- sym = *sym_ptr;
- if ((sym->flags & (BSF_INDIRECT
- | BSF_WARNING
- | BSF_GLOBAL
- | BSF_CONSTRUCTOR
- | BSF_WEAK)) != 0
- || bfd_is_und_section (bfd_get_section (sym))
- || bfd_is_com_section (bfd_get_section (sym))
- || bfd_is_ind_section (bfd_get_section (sym)))
- {
- if (sym->udata.p != NULL)
- h = (struct generic_link_hash_entry *) sym->udata.p;
- else if ((sym->flags & BSF_CONSTRUCTOR) != 0)
- {
- /* This case normally means that the main linker code
- deliberately ignored this constructor symbol. We
- should just pass it through. This will screw up if
- the constructor symbol is from a different,
- non-generic, object file format, but the case will
- only arise when linking with -r, which will probably
- fail anyhow, since there will be no way to represent
- the relocs in the output format being used. */
- h = NULL;
- }
- else if (bfd_is_und_section (bfd_get_section (sym)))
- h = ((struct generic_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (output_bfd, info,
- bfd_asymbol_name (sym),
- false, false, true));
- else
- h = _bfd_generic_link_hash_lookup (_bfd_generic_hash_table (info),
- bfd_asymbol_name (sym),
- false, false, true);
-
- if (h != (struct generic_link_hash_entry *) NULL)
- {
- /* Force all references to this symbol to point to
- the same area in memory. It is possible that
- this routine will be called with a hash table
- other than a generic hash table, so we double
- check that. */
- if (info->hash->creator == input_bfd->xvec)
- {
- if (h->sym != (asymbol *) NULL)
- *sym_ptr = sym = h->sym;
- }
-
- switch (h->root.type)
- {
- default:
- case bfd_link_hash_new:
- abort ();
- case bfd_link_hash_undefined:
- break;
- case bfd_link_hash_undefweak:
- sym->flags |= BSF_WEAK;
- break;
- case bfd_link_hash_indirect:
- h = (struct generic_link_hash_entry *) h->root.u.i.link;
- /* fall through */
- case bfd_link_hash_defined:
- sym->flags |= BSF_GLOBAL;
- sym->flags &=~ BSF_CONSTRUCTOR;
- sym->value = h->root.u.def.value;
- sym->section = h->root.u.def.section;
- break;
- case bfd_link_hash_defweak:
- sym->flags |= BSF_WEAK;
- sym->flags &=~ BSF_CONSTRUCTOR;
- sym->value = h->root.u.def.value;
- sym->section = h->root.u.def.section;
- break;
- case bfd_link_hash_common:
- sym->value = h->root.u.c.size;
- sym->flags |= BSF_GLOBAL;
- if (! bfd_is_com_section (sym->section))
- {
- BFD_ASSERT (bfd_is_und_section (sym->section));
- sym->section = bfd_com_section_ptr;
- }
- /* We do not set the section of the symbol to
- h->root.u.c.p->section. That value was saved so
- that we would know where to allocate the symbol
- if it was defined. In this case the type is
- still bfd_link_hash_common, so we did not define
- it, so we do not want to use that section. */
- break;
- }
- }
- }
-
- /* This switch is straight from the old code in
- write_file_locals in ldsym.c. */
- if (info->strip == strip_some
- && (bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym),
- false, false)
- == (struct bfd_hash_entry *) NULL))
- output = false;
- else if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
- {
- /* If this symbol is marked as occurring now, rather
- than at the end, output it now. This is used for
- COFF C_EXT FCN symbols. FIXME: There must be a
- better way. */
- if (bfd_asymbol_bfd (sym) == input_bfd
- && (sym->flags & BSF_NOT_AT_END) != 0)
- output = true;
- else
- output = false;
- }
- else if (bfd_is_ind_section (sym->section))
- output = false;
- else if ((sym->flags & BSF_DEBUGGING) != 0)
- {
- if (info->strip == strip_none)
- output = true;
- else
- output = false;
- }
- else if (bfd_is_und_section (sym->section)
- || bfd_is_com_section (sym->section))
- output = false;
- else if ((sym->flags & BSF_LOCAL) != 0)
- {
- if ((sym->flags & BSF_WARNING) != 0)
- output = false;
- else
- {
- switch (info->discard)
- {
- default:
- case discard_all:
- output = false;
- break;
- case discard_l:
- if (bfd_asymbol_name (sym)[0] == info->lprefix[0]
- && (info->lprefix_len == 1
- || strncmp (bfd_asymbol_name (sym), info->lprefix,
- info->lprefix_len) == 0))
- output = false;
- else
- output = true;
- break;
- case discard_none:
- output = true;
- break;
- }
- }
- }
- else if ((sym->flags & BSF_CONSTRUCTOR))
- {
- if (info->strip != strip_all)
- output = true;
- else
- output = false;
- }
- else
- abort ();
-
- if (output)
- {
- if (! generic_add_output_symbol (output_bfd, psymalloc, sym))
- return false;
- if (h != (struct generic_link_hash_entry *) NULL)
- h->written = true;
- }
- }
-
- return true;
-}
-
-/* Set the section and value of a generic BFD symbol based on a linker
- hash table entry. */
-
-static void
-set_symbol_from_hash (sym, h)
- asymbol *sym;
- struct bfd_link_hash_entry *h;
-{
- switch (h->type)
- {
- default:
- abort ();
- break;
- case bfd_link_hash_new:
- /* This can happen when a constructor symbol is seen but we are
- not building constructors. */
- if (sym->section != NULL)
- {
- BFD_ASSERT ((sym->flags & BSF_CONSTRUCTOR) != 0);
- }
- else
- {
- sym->flags |= BSF_CONSTRUCTOR;
- sym->section = bfd_abs_section_ptr;
- sym->value = 0;
- }
- break;
- case bfd_link_hash_undefined:
- sym->section = bfd_und_section_ptr;
- sym->value = 0;
- break;
- case bfd_link_hash_undefweak:
- sym->section = bfd_und_section_ptr;
- sym->value = 0;
- sym->flags |= BSF_WEAK;
- break;
- case bfd_link_hash_defined:
- sym->section = h->u.def.section;
- sym->value = h->u.def.value;
- break;
- case bfd_link_hash_defweak:
- sym->flags |= BSF_WEAK;
- sym->section = h->u.def.section;
- sym->value = h->u.def.value;
- break;
- case bfd_link_hash_common:
- sym->value = h->u.c.size;
- if (sym->section == NULL)
- sym->section = bfd_com_section_ptr;
- else if (! bfd_is_com_section (sym->section))
- {
- BFD_ASSERT (bfd_is_und_section (sym->section));
- sym->section = bfd_com_section_ptr;
- }
- /* Do not set the section; see _bfd_generic_link_output_symbols. */
- break;
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- /* FIXME: What should we do here? */
- break;
- }
-}
-
-/* Write out a global symbol, if it hasn't already been written out.
- This is called for each symbol in the hash table. */
-
-boolean
-_bfd_generic_link_write_global_symbol (h, data)
- struct generic_link_hash_entry *h;
- PTR data;
-{
- struct generic_write_global_symbol_info *wginfo =
- (struct generic_write_global_symbol_info *) data;
- asymbol *sym;
-
- if (h->written)
- return true;
-
- h->written = true;
-
- if (wginfo->info->strip == strip_all
- || (wginfo->info->strip == strip_some
- && bfd_hash_lookup (wginfo->info->keep_hash, h->root.root.string,
- false, false) == NULL))
- return true;
-
- if (h->sym != (asymbol *) NULL)
- sym = h->sym;
- else
- {
- sym = bfd_make_empty_symbol (wginfo->output_bfd);
- if (!sym)
- return false;
- sym->name = h->root.root.string;
- sym->flags = 0;
- }
-
- set_symbol_from_hash (sym, &h->root);
-
- sym->flags |= BSF_GLOBAL;
-
- if (! generic_add_output_symbol (wginfo->output_bfd, wginfo->psymalloc,
- sym))
- {
- /* FIXME: No way to return failure. */
- abort ();
- }
-
- return true;
-}
-
-/* Create a relocation. */
-
-boolean
-_bfd_generic_reloc_link_order (abfd, info, sec, link_order)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- struct bfd_link_order *link_order;
-{
- arelent *r;
-
- if (! info->relocateable)
- abort ();
- if (sec->orelocation == (arelent **) NULL)
- abort ();
-
- r = (arelent *) bfd_alloc (abfd, sizeof (arelent));
- if (r == (arelent *) NULL)
- return false;
-
- r->address = link_order->offset;
- r->howto = bfd_reloc_type_lookup (abfd, link_order->u.reloc.p->reloc);
- if (r->howto == 0)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- /* Get the symbol to use for the relocation. */
- if (link_order->type == bfd_section_reloc_link_order)
- r->sym_ptr_ptr = link_order->u.reloc.p->u.section->symbol_ptr_ptr;
- else
- {
- struct generic_link_hash_entry *h;
-
- h = ((struct generic_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (abfd, info,
- link_order->u.reloc.p->u.name,
- false, false, true));
- if (h == (struct generic_link_hash_entry *) NULL
- || ! h->written)
- {
- if (! ((*info->callbacks->unattached_reloc)
- (info, link_order->u.reloc.p->u.name,
- (bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
- return false;
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- r->sym_ptr_ptr = &h->sym;
- }
-
- /* If this is an inplace reloc, write the addend to the object file.
- Otherwise, store it in the reloc addend. */
- if (! r->howto->partial_inplace)
- r->addend = link_order->u.reloc.p->addend;
- else
- {
- bfd_size_type size;
- bfd_reloc_status_type rstat;
- bfd_byte *buf;
- boolean ok;
-
- size = bfd_get_reloc_size (r->howto);
- buf = (bfd_byte *) bfd_zmalloc (size);
- if (buf == (bfd_byte *) NULL)
- return false;
- rstat = _bfd_relocate_contents (r->howto, abfd,
- 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 (! ((*info->callbacks->reloc_overflow)
- (info,
- (link_order->type == bfd_section_reloc_link_order
- ? bfd_section_name (abfd, link_order->u.reloc.p->u.section)
- : link_order->u.reloc.p->u.name),
- r->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 (abfd, sec, (PTR) buf,
- (file_ptr) link_order->offset, size);
- free (buf);
- if (! ok)
- return false;
-
- r->addend = 0;
- }
-
- sec->orelocation[sec->reloc_count] = r;
- ++sec->reloc_count;
-
- return true;
-}
-
-/* Allocate a new link_order for a section. */
-
-struct bfd_link_order *
-bfd_new_link_order (abfd, section)
- bfd *abfd;
- asection *section;
-{
- struct bfd_link_order *new;
-
- new = ((struct bfd_link_order *)
- bfd_alloc_by_size_t (abfd, sizeof (struct bfd_link_order)));
- if (!new)
- return NULL;
-
- new->type = bfd_undefined_link_order;
- new->offset = 0;
- new->size = 0;
- new->next = (struct bfd_link_order *) NULL;
-
- if (section->link_order_tail != (struct bfd_link_order *) NULL)
- section->link_order_tail->next = new;
- else
- section->link_order_head = new;
- section->link_order_tail = new;
-
- return new;
-}
-
-/* Default link order processing routine. Note that we can not handle
- the reloc_link_order types here, since they depend upon the details
- of how the particular backends generates relocs. */
-
-boolean
-_bfd_default_link_order (abfd, info, sec, link_order)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- struct bfd_link_order *link_order;
-{
- switch (link_order->type)
- {
- case bfd_undefined_link_order:
- case bfd_section_reloc_link_order:
- case bfd_symbol_reloc_link_order:
- default:
- abort ();
- case bfd_indirect_link_order:
- return default_indirect_link_order (abfd, info, sec, link_order,
- false);
- case bfd_fill_link_order:
- return default_fill_link_order (abfd, info, sec, link_order);
- case bfd_data_link_order:
- return bfd_set_section_contents (abfd, sec,
- (PTR) link_order->u.data.contents,
- (file_ptr) link_order->offset,
- link_order->size);
- }
-}
-
-/* Default routine to handle a bfd_fill_link_order. */
-
-/*ARGSUSED*/
-static boolean
-default_fill_link_order (abfd, info, sec, link_order)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- struct bfd_link_order *link_order;
-{
- size_t size;
- char *space;
- size_t i;
- int fill;
- boolean result;
-
- BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0);
-
- size = (size_t) link_order->size;
- space = (char *) bfd_malloc (size);
- if (space == NULL && size != 0)
- return false;
-
- fill = link_order->u.fill.value;
- for (i = 0; i < size; i += 2)
- space[i] = fill >> 8;
- for (i = 1; i < size; i += 2)
- space[i] = fill;
- result = bfd_set_section_contents (abfd, sec, space,
- (file_ptr) link_order->offset,
- link_order->size);
- free (space);
- return result;
-}
-
-/* Default routine to handle a bfd_indirect_link_order. */
-
-static boolean
-default_indirect_link_order (output_bfd, info, output_section, link_order,
- generic_linker)
- bfd *output_bfd;
- struct bfd_link_info *info;
- asection *output_section;
- struct bfd_link_order *link_order;
- boolean generic_linker;
-{
- asection *input_section;
- bfd *input_bfd;
- bfd_byte *contents = NULL;
- bfd_byte *new_contents;
-
- BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0);
-
- if (link_order->size == 0)
- return true;
-
- input_section = link_order->u.indirect.section;
- input_bfd = input_section->owner;
-
- BFD_ASSERT (input_section->output_section == output_section);
- BFD_ASSERT (input_section->output_offset == link_order->offset);
- BFD_ASSERT (input_section->_cooked_size == link_order->size);
-
- if (info->relocateable
- && input_section->reloc_count > 0
- && output_section->orelocation == (arelent **) NULL)
- {
- /* Space has not been allocated for the output relocations.
- This can happen when we are called by a specific backend
- because somebody is attempting to link together different
- types of object files. Handling this case correctly is
- difficult, and sometimes impossible. */
- abort ();
- }
-
- if (! generic_linker)
- {
- asymbol **sympp;
- asymbol **symppend;
-
- /* Get the canonical symbols. The generic linker will always
- have retrieved them by this point, but we are being called by
- a specific linker, presumably because we are linking
- different types of object files together. */
- if (! generic_link_read_symbols (input_bfd))
- return false;
-
- /* Since we have been called by a specific linker, rather than
- the generic linker, the values of the symbols will not be
- right. They will be the values as seen in the input file,
- not the values of the final link. We need to fix them up
- before we can relocate the section. */
- sympp = _bfd_generic_link_get_symbols (input_bfd);
- symppend = sympp + _bfd_generic_link_get_symcount (input_bfd);
- for (; sympp < symppend; sympp++)
- {
- asymbol *sym;
- struct bfd_link_hash_entry *h;
-
- sym = *sympp;
-
- if ((sym->flags & (BSF_INDIRECT
- | BSF_WARNING
- | BSF_GLOBAL
- | BSF_CONSTRUCTOR
- | BSF_WEAK)) != 0
- || bfd_is_und_section (bfd_get_section (sym))
- || bfd_is_com_section (bfd_get_section (sym))
- || bfd_is_ind_section (bfd_get_section (sym)))
- {
- /* sym->udata may have been set by
- generic_link_add_symbol_list. */
- if (sym->udata.p != NULL)
- h = (struct bfd_link_hash_entry *) sym->udata.p;
- else if (bfd_is_und_section (bfd_get_section (sym)))
- h = bfd_wrapped_link_hash_lookup (output_bfd, info,
- bfd_asymbol_name (sym),
- false, false, true);
- else
- h = bfd_link_hash_lookup (info->hash,
- bfd_asymbol_name (sym),
- false, false, true);
- if (h != NULL)
- set_symbol_from_hash (sym, h);
- }
- }
- }
-
- /* Get and relocate the section contents. */
- contents = ((bfd_byte *)
- bfd_malloc (bfd_section_size (input_bfd, input_section)));
- if (contents == NULL && bfd_section_size (input_bfd, input_section) != 0)
- goto error_return;
- new_contents = (bfd_get_relocated_section_contents
- (output_bfd, info, link_order, contents, info->relocateable,
- _bfd_generic_link_get_symbols (input_bfd)));
- if (!new_contents)
- goto error_return;
-
- /* Output the section contents. */
- if (! bfd_set_section_contents (output_bfd, output_section,
- (PTR) new_contents,
- link_order->offset, link_order->size))
- goto error_return;
-
- if (contents != NULL)
- free (contents);
- return true;
-
- error_return:
- if (contents != NULL)
- free (contents);
- return false;
-}
-
-/* A little routine to count the number of relocs in a link_order
- list. */
-
-unsigned int
-_bfd_count_link_order_relocs (link_order)
- struct bfd_link_order *link_order;
-{
- register unsigned int c;
- register struct bfd_link_order *l;
-
- c = 0;
- for (l = link_order; l != (struct bfd_link_order *) NULL; l = l->next)
- {
- if (l->type == bfd_section_reloc_link_order
- || l->type == bfd_symbol_reloc_link_order)
- ++c;
- }
-
- return c;
-}
-
-/*
-FUNCTION
- bfd_link_split_section
-
-SYNOPSIS
- boolean bfd_link_split_section(bfd *abfd, asection *sec);
-
-DESCRIPTION
- Return nonzero if @var{sec} should be split during a
- reloceatable or final link.
-
-.#define bfd_link_split_section(abfd, sec) \
-. BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))
-.
-
-*/
-
-
-
-boolean
-_bfd_generic_link_split_section (abfd, sec)
- bfd *abfd;
- asection *sec;
-{
- return false;
-}
diff --git a/contrib/gdb/bfd/lynx-core.c b/contrib/gdb/bfd/lynx-core.c
deleted file mode 100644
index 2358177dbc62..000000000000
--- 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 c1ecb434425b..000000000000
--- 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 062165b399b8..000000000000
--- 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 7acdfbcad21d..000000000000
--- 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 3bff530fbc72..000000000000
--- 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 7a5640873008..000000000000
--- 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 8a22c6af201f..000000000000
--- 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 801f3604338e..000000000000
--- 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 9195d0e64547..000000000000
--- 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 a989ef005ff2..000000000000
--- 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 4e8286797963..000000000000
--- 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 dd73d37e789b..000000000000
--- 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 7ec7a75a87c0..000000000000
--- 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 cdd3fa8b22e6..000000000000
--- 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 89c6baa64ef7..000000000000
--- 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 24c8e5167628..000000000000
--- 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 f16c74d985eb..000000000000
--- 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 ecf2de8f10bf..000000000000
--- 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 5963adbc70bf..000000000000
--- 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 4730e4fd3499..000000000000
--- 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 5dcd96a2b3c6..000000000000
--- 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 7f828b46b60f..000000000000
--- 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 5a9ce7268d00..000000000000
--- 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 3e3f08a9e58d..000000000000
--- 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 c72147288af5..000000000000
--- 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/opncls.c b/contrib/gdb/bfd/opncls.c
deleted file mode 100644
index 54528dbf48f6..000000000000
--- a/contrib/gdb/bfd/opncls.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/* opncls.c -- open and close a BFD.
- 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. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-
-#ifndef S_IXUSR
-#define S_IXUSR 0100 /* Execute by owner. */
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP 0010 /* Execute by group. */
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH 0001 /* Execute by others. */
-#endif
-
-/* fdopen is a loser -- we should use stdio exclusively. Unfortunately
- if we do that we can't use fcntl. */
-
-
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-
-#ifndef HAVE_GETPAGESIZE
-#define getpagesize() 2048
-#endif
-
-long _bfd_chunksize = -1;
-
-/* Return a new BFD. All BFD's are allocated through this routine. */
-
-bfd *
-_bfd_new_bfd ()
-{
- bfd *nbfd;
-
- nbfd = (bfd *)bfd_zmalloc (sizeof (bfd));
- if (!nbfd)
- return 0;
-
- if (_bfd_chunksize <= 0)
- {
- _bfd_chunksize = getpagesize ();
- if (_bfd_chunksize <= 0)
- _bfd_chunksize = 2048;
- /* Leave some slush space, since many malloc implementations
- prepend a header, and may wind up wasting another page
- because of it. */
- _bfd_chunksize -= 32;
- }
-
- if (!obstack_begin(&nbfd->memory, _bfd_chunksize))
- {
- bfd_set_error (bfd_error_no_memory);
- return 0;
- }
-
- nbfd->arch_info = &bfd_default_arch_struct;
-
- nbfd->direction = no_direction;
- nbfd->iostream = NULL;
- nbfd->where = 0;
- nbfd->sections = (asection *)NULL;
- nbfd->format = bfd_unknown;
- nbfd->my_archive = (bfd *)NULL;
- nbfd->origin = 0;
- nbfd->opened_once = false;
- nbfd->output_has_begun = false;
- nbfd->section_count = 0;
- nbfd->usrdata = (PTR)NULL;
- nbfd->cacheable = false;
- nbfd->flags = NO_FLAGS;
- nbfd->mtime_set = false;
-
- return nbfd;
-}
-
-/* Allocate a new BFD as a member of archive OBFD. */
-
-bfd *
-_bfd_new_bfd_contained_in (obfd)
- bfd *obfd;
-{
- bfd *nbfd;
-
- nbfd = _bfd_new_bfd();
- nbfd->xvec = obfd->xvec;
- nbfd->my_archive = obfd;
- nbfd->direction = read_direction;
- nbfd->target_defaulted = obfd->target_defaulted;
- return nbfd;
-}
-
-/*
-SECTION
- Opening and closing BFDs
-
-*/
-
-/*
-FUNCTION
- bfd_openr
-
-SYNOPSIS
- bfd *bfd_openr(CONST char *filename, CONST char *target);
-
-DESCRIPTION
- Open the file @var{filename} (using <<fopen>>) with the target
- @var{target}. Return a pointer to the created BFD.
-
- Calls <<bfd_find_target>>, so @var{target} is interpreted as by
- that function.
-
- If <<NULL>> is returned then an error has occured. Possible errors
- are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> or <<system_call>> error.
-*/
-
-bfd *
-bfd_openr (filename, target)
- CONST char *filename;
- CONST char *target;
-{
- bfd *nbfd;
- const bfd_target *target_vec;
-
- nbfd = _bfd_new_bfd();
- if (nbfd == NULL)
- return NULL;
-
- target_vec = bfd_find_target (target, nbfd);
- if (target_vec == NULL) {
- bfd_set_error (bfd_error_invalid_target);
- return NULL;
- }
-
- nbfd->filename = filename;
- nbfd->direction = read_direction;
-
- if (bfd_open_file (nbfd) == NULL) {
- bfd_set_error (bfd_error_system_call); /* File didn't exist, or some such */
- bfd_release(nbfd,0);
- return NULL;
- }
- return nbfd;
-}
-
-
-/* Don't try to `optimize' this function:
-
- o - We lock using stack space so that interrupting the locking
- won't cause a storage leak.
- o - We open the file stream last, since we don't want to have to
- close it if anything goes wrong. Closing the stream means closing
- the file descriptor too, even though we didn't open it.
- */
-/*
-FUNCTION
- bfd_fdopenr
-
-SYNOPSIS
- bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd);
-
-DESCRIPTION
- <<bfd_fdopenr>> is to <<bfd_fopenr>> much like <<fdopen>> is to <<fopen>>.
- It opens a BFD on a file already described by the @var{fd}
- supplied.
-
- When the file is later <<bfd_close>>d, the file descriptor will be closed.
-
- If the caller desires that this file descriptor be cached by BFD
- (opened as needed, closed as needed to free descriptors for
- other opens), with the supplied @var{fd} used as an initial
- file descriptor (but subject to closure at any time), call
- bfd_set_cacheable(bfd, 1) on the returned BFD. The default is to
- assume no cacheing; the file descriptor will remain open until
- <<bfd_close>>, and will not be affected by BFD operations on other
- files.
-
- Possible errors are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> and <<bfd_error_system_call>>.
-*/
-
-bfd *
-bfd_fdopenr (filename, target, fd)
- CONST char *filename;
- CONST char *target;
- int fd;
-{
- bfd *nbfd;
- const bfd_target *target_vec;
- int fdflags;
-
- bfd_set_error (bfd_error_system_call);
-#if ! defined(HAVE_FCNTL) || ! defined(F_GETFL)
- fdflags = O_RDWR; /* Assume full access */
-#else
- fdflags = fcntl (fd, F_GETFL, NULL);
-#endif
- if (fdflags == -1) return NULL;
-
- nbfd = _bfd_new_bfd();
-
- if (nbfd == NULL)
- return NULL;
-
- target_vec = bfd_find_target (target, nbfd);
- if (target_vec == NULL) {
- bfd_set_error (bfd_error_invalid_target);
- return NULL;
- }
-#if defined(VMS) || defined(__GO32__) || defined (WINGDB)
- nbfd->iostream = (PTR)fopen(filename, FOPEN_RB);
-#else
- /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
- switch (fdflags & (O_ACCMODE)) {
- case O_RDONLY: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RB); break;
- case O_WRONLY: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RUB); break;
- case O_RDWR: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RUB); break;
- default: abort ();
- }
-#endif
- if (nbfd->iostream == NULL) {
- (void) obstack_free (&nbfd->memory, (PTR)0);
- return NULL;
- }
-
- /* OK, put everything where it belongs */
-
- nbfd->filename = filename;
-
- /* As a special case we allow a FD open for read/write to
- be written through, although doing so requires that we end
- the previous clause with a preposition. */
- /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
- switch (fdflags & (O_ACCMODE)) {
- case O_RDONLY: nbfd->direction = read_direction; break;
- case O_WRONLY: nbfd->direction = write_direction; break;
- case O_RDWR: nbfd->direction = both_direction; break;
- default: abort ();
- }
-
- if (! bfd_cache_init (nbfd))
- return NULL;
-
- return nbfd;
-}
-
-/*
-FUNCTION
- bfd_openstreamr
-
-SYNOPSIS
- bfd *bfd_openstreamr();
-
-DESCRIPTION
-
- Open a BFD for read access on an existing stdio stream. When
- the BFD is passed to <<bfd_close>>, the stream will be closed.
-*/
-
-bfd *
-bfd_openstreamr (filename, target, stream)
- const char *filename;
- const char *target;
- FILE *stream;
-{
- bfd *nbfd;
- const bfd_target *target_vec;
-
- nbfd = _bfd_new_bfd ();
- if (nbfd == NULL)
- return NULL;
-
- target_vec = bfd_find_target (target, nbfd);
- if (target_vec == NULL)
- {
- bfd_set_error (bfd_error_invalid_target);
- return NULL;
- }
-
- nbfd->iostream = (PTR) stream;
- nbfd->filename = filename;
- nbfd->direction = read_direction;
-
- if (! bfd_cache_init (nbfd))
- return NULL;
-
- return nbfd;
-}
-
-/** bfd_openw -- open for writing.
- Returns a pointer to a freshly-allocated BFD on success, or NULL.
-
- See comment by bfd_fdopenr before you try to modify this function. */
-
-/*
-FUNCTION
- bfd_openw
-
-SYNOPSIS
- bfd *bfd_openw(CONST char *filename, CONST char *target);
-
-DESCRIPTION
- Create a BFD, associated with file @var{filename}, using the
- file format @var{target}, and return a pointer to it.
-
- Possible errors are <<bfd_error_system_call>>, <<bfd_error_no_memory>>,
- <<bfd_error_invalid_target>>.
-*/
-
-bfd *
-bfd_openw (filename, target)
- CONST char *filename;
- CONST char *target;
-{
- bfd *nbfd;
- const bfd_target *target_vec;
-
- bfd_set_error (bfd_error_system_call);
-
- /* nbfd has to point to head of malloc'ed block so that bfd_close may
- reclaim it correctly. */
-
- nbfd = _bfd_new_bfd();
- if (nbfd == NULL)
- return NULL;
-
- target_vec = bfd_find_target (target, nbfd);
- if (target_vec == NULL) return NULL;
-
- nbfd->filename = filename;
- nbfd->direction = write_direction;
-
- if (bfd_open_file (nbfd) == NULL) {
- bfd_set_error (bfd_error_system_call); /* File not writeable, etc */
- (void) obstack_free (&nbfd->memory, (PTR)0);
- return NULL;
- }
- return nbfd;
-}
-
-/*
-
-FUNCTION
- bfd_close
-
-SYNOPSIS
- boolean bfd_close(bfd *abfd);
-
-DESCRIPTION
-
- Close a BFD. If the BFD was open for writing,
- then pending operations are completed and the file written out
- and closed. If the created file is executable, then
- <<chmod>> is called to mark it as such.
-
- All memory attached to the BFD's obstacks is released.
-
- The file descriptor associated with the BFD is closed (even
- if it was passed in to BFD by <<bfd_fdopenr>>).
-
-RETURNS
- <<true>> is returned if all is ok, otherwise <<false>>.
-*/
-
-
-boolean
-bfd_close (abfd)
- bfd *abfd;
-{
- boolean ret;
-
- if (!bfd_read_p (abfd))
- {
- if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)))
- return false;
- }
-
- if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
- return false;
-
- ret = bfd_cache_close (abfd);
-
- /* If the file was open for writing and is now executable,
- make it so */
- if (ret
- && abfd->direction == write_direction
- && abfd->flags & EXEC_P)
- {
- struct stat buf;
-
- if (stat (abfd->filename, &buf) == 0)
- {
- int mask = umask (0);
- umask (mask);
- chmod (abfd->filename,
- (0777
- & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
- }
- }
-
- (void) obstack_free (&abfd->memory, (PTR)0);
- (void) free (abfd);
-
- return ret;
-}
-
-/*
-FUNCTION
- bfd_close_all_done
-
-SYNOPSIS
- boolean bfd_close_all_done(bfd *);
-
-DESCRIPTION
- Close a BFD. Differs from <<bfd_close>>
- since it does not complete any pending operations. This
- routine would be used if the application had just used BFD for
- swapping and didn't want to use any of the writing code.
-
- If the created file is executable, then <<chmod>> is called
- to mark it as such.
-
- All memory attached to the BFD's obstacks is released.
-
-RETURNS
- <<true>> is returned if all is ok, otherwise <<false>>.
-
-*/
-
-boolean
-bfd_close_all_done (abfd)
- bfd *abfd;
-{
- boolean ret;
-
- ret = bfd_cache_close (abfd);
-
- /* If the file was open for writing and is now executable,
- make it so */
- if (ret
- && abfd->direction == write_direction
- && abfd->flags & EXEC_P)
- {
- struct stat buf;
-
- if (stat (abfd->filename, &buf) == 0)
- {
- int mask = umask (0);
- umask (mask);
- chmod (abfd->filename,
- (0x777
- & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
- }
- }
- (void) obstack_free (&abfd->memory, (PTR)0);
- (void) free(abfd);
- return ret;
-}
-
-
-/*
-FUNCTION
- bfd_alloc_size
-
-SYNOPSIS
- bfd_size_type bfd_alloc_size(bfd *abfd);
-
-DESCRIPTION
- Return the number of bytes in the obstacks connected to @var{abfd}.
-
-*/
-
-bfd_size_type
-bfd_alloc_size (abfd)
- bfd *abfd;
-{
- struct _obstack_chunk *chunk = abfd->memory.chunk;
- size_t size = 0;
- while (chunk) {
- size += chunk->limit - &(chunk->contents[0]);
- chunk = chunk->prev;
- }
- return size;
-}
-
-
-
-/*
-FUNCTION
- bfd_create
-
-SYNOPSIS
- bfd *bfd_create(CONST char *filename, bfd *templ);
-
-DESCRIPTION
- Create a new BFD in the manner of
- <<bfd_openw>>, but without opening a file. The new BFD
- takes the target from the target used by @var{template}. The
- format is always set to <<bfd_object>>.
-
-*/
-
-bfd *
-bfd_create (filename, templ)
- CONST char *filename;
- bfd *templ;
-{
- bfd *nbfd = _bfd_new_bfd();
- if (nbfd == (bfd *)NULL)
- return (bfd *)NULL;
- nbfd->filename = filename;
- if(templ) {
- nbfd->xvec = templ->xvec;
- }
- nbfd->direction = no_direction;
- bfd_set_format(nbfd, bfd_object);
- return nbfd;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_alloc_by_size_t
-
-SYNOPSIS
- PTR bfd_alloc_by_size_t(bfd *abfd, size_t wanted);
-
-DESCRIPTION
- Allocate a block of @var{wanted} bytes of memory in the obstack
- attatched to <<abfd>> and return a pointer to it.
-*/
-
-
-PTR
-bfd_alloc_by_size_t (abfd, size)
- bfd *abfd;
- size_t size;
-{
- PTR ret;
-
- ret = obstack_alloc (&(abfd->memory), size);
- if (ret == NULL)
- bfd_set_error (bfd_error_no_memory);
- return ret;
-}
-
-void
-bfd_alloc_grow (abfd, ptr, size)
- bfd *abfd;
- PTR ptr;
- size_t size;
-{
- (void) obstack_grow(&(abfd->memory), ptr, size);
-}
-
-PTR
-bfd_alloc_finish (abfd)
- bfd *abfd;
-{
- PTR ret;
-
- ret = obstack_finish (&(abfd->memory));
- if (ret == NULL)
- bfd_set_error (bfd_error_no_memory);
- return ret;
-}
-
-PTR
-bfd_alloc (abfd, size)
- bfd *abfd;
- size_t size;
-{
- return bfd_alloc_by_size_t(abfd, (size_t)size);
-}
-
-PTR
-bfd_zalloc (abfd, size)
- bfd *abfd;
- size_t size;
-{
- PTR res;
- res = bfd_alloc(abfd, size);
- if (res)
- memset(res, 0, (size_t)size);
- return res;
-}
diff --git a/contrib/gdb/bfd/osf-core.c b/contrib/gdb/bfd/osf-core.c
deleted file mode 100644
index 6d1df9b37094..000000000000
--- 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 73f4ac49e827..000000000000
--- 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 fa97e2e8413d..000000000000
--- 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 878993e510cc..000000000000
--- 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 67fdda04e6c8..000000000000
--- 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 fd9d398432d0..000000000000
--- 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 8754e7c55e36..000000000000
--- 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 fc8f89fddb6d..000000000000
--- 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 a7a47469e3d0..000000000000
--- 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 e356457e8fbc..000000000000
--- 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/reloc.c b/contrib/gdb/bfd/reloc.c
deleted file mode 100644
index 46ed5c2d9228..000000000000
--- a/contrib/gdb/bfd/reloc.c
+++ /dev/null
@@ -1,2391 +0,0 @@
-/* BFD support for handling relocation entries.
- 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. */
-
-/*
-SECTION
- Relocations
-
- BFD maintains relocations in much the same way it maintains
- symbols: they are left alone until required, then read in
- en-mass and translated into an internal form. A common
- routine <<bfd_perform_relocation>> acts upon the
- canonical form to do the fixup.
-
- Relocations are maintained on a per section basis,
- while symbols are maintained on a per BFD basis.
-
- All that a back end has to do to fit the BFD interface is to create
- a <<struct reloc_cache_entry>> for each relocation
- in a particular section, and fill in the right bits of the structures.
-
-@menu
-@* typedef arelent::
-@* howto manager::
-@end menu
-
-*/
-
-/* DO compile in the reloc_code name table from libbfd.h. */
-#define _BFD_MAKE_TABLE_bfd_reloc_code_real
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-/*
-DOCDD
-INODE
- typedef arelent, howto manager, Relocations, Relocations
-
-SUBSECTION
- typedef arelent
-
- This is the structure of a relocation entry:
-
-CODE_FRAGMENT
-.
-.typedef enum bfd_reloc_status
-.{
-. {* No errors detected *}
-. bfd_reloc_ok,
-.
-. {* The relocation was performed, but there was an overflow. *}
-. bfd_reloc_overflow,
-.
-. {* The address to relocate was not within the section supplied. *}
-. bfd_reloc_outofrange,
-.
-. {* Used by special functions *}
-. bfd_reloc_continue,
-.
-. {* Unsupported relocation size requested. *}
-. bfd_reloc_notsupported,
-.
-. {* Unused *}
-. bfd_reloc_other,
-.
-. {* The symbol to relocate against was undefined. *}
-. bfd_reloc_undefined,
-.
-. {* The relocation was performed, but may not be ok - presently
-. generated only when linking i960 coff files with i960 b.out
-. symbols. If this type is returned, the error_message argument
-. to bfd_perform_relocation will be set. *}
-. bfd_reloc_dangerous
-. }
-. bfd_reloc_status_type;
-.
-.
-.typedef struct reloc_cache_entry
-.{
-. {* A pointer into the canonical table of pointers *}
-. struct symbol_cache_entry **sym_ptr_ptr;
-.
-. {* offset in section *}
-. bfd_size_type address;
-.
-. {* addend for relocation value *}
-. bfd_vma addend;
-.
-. {* Pointer to how to perform the required relocation *}
-. reloc_howto_type *howto;
-.
-.} arelent;
-
-*/
-
-/*
-DESCRIPTION
-
- Here is a description of each of the fields within an <<arelent>>:
-
- o <<sym_ptr_ptr>>
-
- The symbol table pointer points to a pointer to the symbol
- associated with the relocation request. It is
- the pointer into the table returned by the back end's
- <<get_symtab>> action. @xref{Symbols}. The symbol is referenced
- through a pointer to a pointer so that tools like the linker
- can fix up all the symbols of the same name by modifying only
- one pointer. The relocation routine looks in the symbol and
- uses the base of the section the symbol is attached to and the
- value of the symbol as the initial relocation offset. If the
- symbol pointer is zero, then the section provided is looked up.
-
- o <<address>>
-
- The <<address>> field gives the offset in bytes from the base of
- the section data which owns the relocation record to the first
- byte of relocatable information. The actual data relocated
- will be relative to this point; for example, a relocation
- type which modifies the bottom two bytes of a four byte word
- would not touch the first byte pointed to in a big endian
- world.
-
- o <<addend>>
-
- The <<addend>> is a value provided by the back end to be added (!)
- to the relocation offset. Its interpretation is dependent upon
- the howto. For example, on the 68k the code:
-
-
-| char foo[];
-| main()
-| {
-| return foo[0x12345678];
-| }
-
- Could be compiled into:
-
-| linkw fp,#-4
-| moveb @@#12345678,d0
-| extbl d0
-| unlk fp
-| rts
-
-
- This could create a reloc pointing to <<foo>>, but leave the
- offset in the data, something like:
-
-
-|RELOCATION RECORDS FOR [.text]:
-|offset type value
-|00000006 32 _foo
-|
-|00000000 4e56 fffc ; linkw fp,#-4
-|00000004 1039 1234 5678 ; moveb @@#12345678,d0
-|0000000a 49c0 ; extbl d0
-|0000000c 4e5e ; unlk fp
-|0000000e 4e75 ; rts
-
-
- Using coff and an 88k, some instructions don't have enough
- space in them to represent the full address range, and
- pointers have to be loaded in two parts. So you'd get something like:
-
-
-| or.u r13,r0,hi16(_foo+0x12345678)
-| ld.b r2,r13,lo16(_foo+0x12345678)
-| jmp r1
-
-
- This should create two relocs, both pointing to <<_foo>>, and with
- 0x12340000 in their addend field. The data would consist of:
-
-
-|RELOCATION RECORDS FOR [.text]:
-|offset type value
-|00000002 HVRT16 _foo+0x12340000
-|00000006 LVRT16 _foo+0x12340000
-|
-|00000000 5da05678 ; or.u r13,r0,0x5678
-|00000004 1c4d5678 ; ld.b r2,r13,0x5678
-|00000008 f400c001 ; jmp r1
-
-
- The relocation routine digs out the value from the data, adds
- it to the addend to get the original offset, and then adds the
- value of <<_foo>>. Note that all 32 bits have to be kept around
- somewhere, to cope with carry from bit 15 to bit 16.
-
- One further example is the sparc and the a.out format. The
- sparc has a similar problem to the 88k, in that some
- instructions don't have room for an entire offset, but on the
- sparc the parts are created in odd sized lumps. The designers of
- the a.out format chose to not use the data within the section
- for storing part of the offset; all the offset is kept within
- the reloc. Anything in the data should be ignored.
-
-| save %sp,-112,%sp
-| sethi %hi(_foo+0x12345678),%g2
-| ldsb [%g2+%lo(_foo+0x12345678)],%i0
-| ret
-| restore
-
- Both relocs contain a pointer to <<foo>>, and the offsets
- contain junk.
-
-
-|RELOCATION RECORDS FOR [.text]:
-|offset type value
-|00000004 HI22 _foo+0x12345678
-|00000008 LO10 _foo+0x12345678
-|
-|00000000 9de3bf90 ; save %sp,-112,%sp
-|00000004 05000000 ; sethi %hi(_foo+0),%g2
-|00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0
-|0000000c 81c7e008 ; ret
-|00000010 81e80000 ; restore
-
-
- o <<howto>>
-
- The <<howto>> field can be imagined as a
- relocation instruction. It is a pointer to a structure which
- contains information on what to do with all of the other
- information in the reloc record and data section. A back end
- would normally have a relocation instruction set and turn
- relocations into pointers to the correct structure on input -
- but it would be possible to create each howto field on demand.
-
-*/
-
-/*
-SUBSUBSECTION
- <<enum complain_overflow>>
-
- Indicates what sort of overflow checking should be done when
- performing a relocation.
-
-CODE_FRAGMENT
-.
-.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
-.};
-
-*/
-
-/*
-SUBSUBSECTION
- <<reloc_howto_type>>
-
- The <<reloc_howto_type>> is a structure which contains all the
- information that libbfd needs to know to tie up a back end's data.
-
-CODE_FRAGMENT
-.struct symbol_cache_entry; {* Forward declaration *}
-.
-.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;
-.
-.};
-
-*/
-
-/*
-FUNCTION
- The HOWTO Macro
-
-DESCRIPTION
- The HOWTO define is horrible and will go away.
-
-
-.#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
-. {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
-
-DESCRIPTION
- And will be replaced with the totally magic way. But for the
- moment, we are compatible, so do it this way.
-
-
-.#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
-.
-DESCRIPTION
- Helper routine to turn a symbol into a relocation value.
-
-.#define HOWTO_PREPARE(relocation, symbol) \
-. { \
-. if (symbol != (asymbol *)NULL) { \
-. if (bfd_is_com_section (symbol->section)) { \
-. relocation = 0; \
-. } \
-. else { \
-. relocation = symbol->value; \
-. } \
-. } \
-.}
-
-*/
-
-/*
-FUNCTION
- bfd_get_reloc_size
-
-SYNOPSIS
- int bfd_get_reloc_size (reloc_howto_type *);
-
-DESCRIPTION
- For a reloc_howto_type that operates on a fixed number of bytes,
- this returns the number of bytes operated on.
- */
-
-int
-bfd_get_reloc_size (howto)
- reloc_howto_type *howto;
-{
- switch (howto->size)
- {
- case 0: return 1;
- case 1: return 2;
- case 2: return 4;
- case 3: return 0;
- case 4: return 8;
- case -2: return 4;
- default: abort ();
- }
-}
-
-/*
-TYPEDEF
- arelent_chain
-
-DESCRIPTION
-
- How relocs are tied together in an <<asection>>:
-
-.typedef struct relent_chain {
-. arelent relent;
-. struct relent_chain *next;
-.} arelent_chain;
-
-*/
-
-
-
-/*
-FUNCTION
- bfd_perform_relocation
-
-SYNOPSIS
- bfd_reloc_status_type
- bfd_perform_relocation
- (bfd *abfd,
- arelent *reloc_entry,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message);
-
-DESCRIPTION
- If @var{output_bfd} is supplied to this function, the
- generated image will be relocatable; the relocations are
- copied to the output file after they have been changed to
- reflect the new state of the world. There are two ways of
- reflecting the results of partial linkage in an output file:
- by modifying the output data in place, and by modifying the
- relocation record. Some native formats (e.g., basic a.out and
- basic coff) have no way of specifying an addend in the
- relocation type, so the addend has to go in the output data.
- This is no big deal since in these formats the output data
- slot will always be big enough for the addend. Complex reloc
- types with addends were invented to solve just this problem.
- The @var{error_message} argument is set to an error message if
- this return @code{bfd_reloc_dangerous}.
-
-*/
-
-
-bfd_reloc_status_type
-bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- 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;
- asymbol *symbol;
-
- symbol = *(reloc_entry->sym_ptr_ptr);
- if (bfd_is_abs_section (symbol->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 (bfd_is_und_section (symbol->section)
- && (symbol->flags & BSF_WEAK) == 0
- && output_bfd == (bfd *) NULL)
- flag = bfd_reloc_undefined;
-
- /* If there is a function supplied to handle this relocation type,
- call it. It'll return `bfd_reloc_continue' if further processing
- can be done. */
- if (howto->special_function)
- {
- bfd_reloc_status_type cont;
- cont = howto->special_function (abfd, reloc_entry, symbol, data,
- input_section, output_bfd,
- error_message);
- if (cont != bfd_reloc_continue)
- return cont;
- }
-
- /* 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
- && strcmp (abfd->xvec->name, "coff-Intel-little") != 0
- && strcmp (abfd->xvec->name, "coff-Intel-big") != 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
- && flag == bfd_reloc_ok)
- {
- bfd_vma check;
-
- /* Get the value that will be used for the relocation, but
- starting at bit position zero. */
- check = relocation >> 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 > 0
- && (bfd_signed_vma) relocation < 0)
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> howto->rightshift));
- 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 > 0
- && (bfd_signed_vma) relocation < 0)
- {
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> howto->rightshift));
- 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 = bfd_get_8 (abfd, (char *) data + addr);
- DOIT (x);
- bfd_put_8 (abfd, x, (unsigned char *) data + addr);
- }
- break;
-
- case 1:
- if (relocation)
- {
- short x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
- DOIT (x);
- bfd_put_16 (abfd, x, (unsigned char *) data + addr);
- }
- break;
- case 2:
- if (relocation)
- {
- long x = bfd_get_32 (abfd, (bfd_byte *) data + addr);
- DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data + addr);
- }
- break;
- case -2:
- {
- long x = bfd_get_32 (abfd, (bfd_byte *) data + addr);
- relocation = -relocation;
- DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data + addr);
- }
- break;
-
- case -1:
- {
- long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
- relocation = -relocation;
- DOIT (x);
- bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
- }
- break;
-
- case 3:
- /* Do nothing */
- break;
-
- case 4:
-#ifdef BFD64
- if (relocation)
- {
- bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + addr);
- DOIT (x);
- bfd_put_64 (abfd, x, (bfd_byte *) data + addr);
- }
-#else
- abort ();
-#endif
- break;
- default:
- return bfd_reloc_other;
- }
-
- return flag;
-}
-
-/*
-FUNCTION
- bfd_install_relocation
-
-SYNOPSIS
- bfd_reloc_status_type
- bfd_install_relocation
- (bfd *abfd,
- arelent *reloc_entry,
- PTR data, bfd_vma data_start,
- asection *input_section,
- char **error_message);
-
-DESCRIPTION
- This looks remarkably like <<bfd_perform_relocation>>, except it
- does not expect that the section contents have been filled in.
- I.e., it's suitable for use when creating, rather than applying
- a relocation.
-
- For now, this function should be considered reserved for the
- assembler.
-
-*/
-
-
-bfd_reloc_status_type
-bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset,
- input_section, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- PTR data_start;
- bfd_vma data_start_offset;
- asection *input_section;
- char **error_message;
-{
- 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;
- asymbol *symbol;
- bfd_byte *data;
-
- symbol = *(reloc_entry->sym_ptr_ptr);
- if (bfd_is_abs_section (symbol->section))
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* If there is a function supplied to handle this relocation type,
- call it. It'll return `bfd_reloc_continue' if further processing
- can be done. */
- if (howto->special_function)
- {
- bfd_reloc_status_type cont;
- /* XXX - The special_function calls haven't been fixed up to deal
- with creating new relocations and section contents. */
- cont = howto->special_function (abfd, reloc_entry, symbol,
- /* XXX - Non-portable! */
- ((bfd_byte *) data_start
- - data_start_offset),
- input_section, abfd, error_message);
- if (cont != bfd_reloc_continue)
- return cont;
- }
-
- /* 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 (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 && howto->partial_inplace == true)
- relocation -= reloc_entry->address;
- }
-
- 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
- && strcmp (abfd->xvec->name, "coff-Intel-little") != 0
- && strcmp (abfd->xvec->name, "coff-Intel-big") != 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_install_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_install_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;
- }
- }
-
- /* 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. */
- check = relocation >> 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 > 0
- && (bfd_signed_vma) relocation < 0)
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> howto->rightshift));
- 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 > 0
- && (bfd_signed_vma) relocation < 0)
- {
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> howto->rightshift));
- 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))
-
- data = (bfd_byte *) data_start + (addr - data_start_offset);
-
- switch (howto->size)
- {
- case 0:
- {
- char x = bfd_get_8 (abfd, (char *) data);
- DOIT (x);
- bfd_put_8 (abfd, x, (unsigned char *) data);
- }
- break;
-
- case 1:
- if (relocation)
- {
- short x = bfd_get_16 (abfd, (bfd_byte *) data);
- DOIT (x);
- bfd_put_16 (abfd, x, (unsigned char *) data);
- }
- break;
- case 2:
- if (relocation)
- {
- long x = bfd_get_32 (abfd, (bfd_byte *) data);
- DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data);
- }
- break;
- case -2:
- {
- long x = bfd_get_32 (abfd, (bfd_byte *) data);
- relocation = -relocation;
- DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data);
- }
- break;
-
- case 3:
- /* Do nothing */
- break;
-
- case 4:
- if (relocation)
- {
- bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data);
- DOIT (x);
- bfd_put_64 (abfd, x, (bfd_byte *) data);
- }
- break;
- default:
- return bfd_reloc_other;
- }
-
- return flag;
-}
-
-/* This relocation routine is used by some of the backend linkers.
- They do not construct asymbol or arelent structures, so there is no
- reason for them to use bfd_perform_relocation. Also,
- bfd_perform_relocation is so hacked up it is easier to write a new
- function than to try to deal with it.
-
- This routine does a final relocation. It should not be used when
- generating relocateable output.
-
- FIXME: This routine ignores any special_function in the HOWTO,
- since the existing special_function values have been written for
- bfd_perform_relocation.
-
- HOWTO is the reloc howto information.
- INPUT_BFD is the BFD which the reloc applies to.
- INPUT_SECTION is the section which the reloc applies to.
- CONTENTS is the contents of the section.
- ADDRESS is the address of the reloc within INPUT_SECTION.
- VALUE is the value of the symbol the reloc refers to.
- ADDEND is the addend of the reloc. */
-
-bfd_reloc_status_type
-_bfd_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 _bfd_relocate_contents (howto, input_bfd, relocation,
- contents + address);
-}
-
-/* Relocate a given location using a given value and howto. */
-
-bfd_reloc_status_type
-_bfd_relocate_contents (howto, input_bfd, relocation, location)
- reloc_howto_type *howto;
- bfd *input_bfd;
- bfd_vma relocation;
- bfd_byte *location;
-{
- 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:
- x = bfd_get_8 (input_bfd, location);
- break;
- case 2:
- x = bfd_get_16 (input_bfd, location);
- break;
- case 4:
- x = bfd_get_32 (input_bfd, location);
- break;
- case 8:
-#ifdef BFD64
- x = bfd_get_64 (input_bfd, location);
-#else
- abort ();
-#endif
- 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:
- bfd_put_8 (input_bfd, x, location);
- break;
- case 2:
- bfd_put_16 (input_bfd, x, location);
- break;
- case 4:
- bfd_put_32 (input_bfd, x, location);
- break;
- case 8:
-#ifdef BFD64
- bfd_put_64 (input_bfd, x, location);
-#else
- abort ();
-#endif
- break;
- }
-
- return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
-}
-
-/*
-DOCDD
-INODE
- howto manager, , typedef arelent, Relocations
-
-SECTION
- The howto manager
-
- When an application wants to create a relocation, but doesn't
- know what the target machine might call it, it can find out by
- using this bit of code.
-
-*/
-
-/*
-TYPEDEF
- bfd_reloc_code_type
-
-DESCRIPTION
- The insides of a reloc code. The idea is that, eventually, there
- will be one enumerator for every type of relocation we ever do.
- Pass one of these values to <<bfd_reloc_type_lookup>>, and it'll
- return a howto pointer.
-
- This does mean that the application must determine the correct
- enumerator value; you can't get a howto pointer from a random set
- of attributes.
-
-SENUM
- bfd_reloc_code_real
-
-ENUM
- BFD_RELOC_64
-ENUMX
- BFD_RELOC_32
-ENUMX
- BFD_RELOC_26
-ENUMX
- BFD_RELOC_16
-ENUMX
- BFD_RELOC_14
-ENUMX
- BFD_RELOC_8
-ENUMDOC
- Basic absolute relocations of N bits.
-
-ENUM
- BFD_RELOC_64_PCREL
-ENUMX
- BFD_RELOC_32_PCREL
-ENUMX
- BFD_RELOC_24_PCREL
-ENUMX
- BFD_RELOC_16_PCREL
-ENUMX
- BFD_RELOC_12_PCREL
-ENUMX
- BFD_RELOC_8_PCREL
-ENUMDOC
- 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.
-
-ENUM
- BFD_RELOC_32_GOT_PCREL
-ENUMX
- BFD_RELOC_16_GOT_PCREL
-ENUMX
- BFD_RELOC_8_GOT_PCREL
-ENUMX
- BFD_RELOC_32_GOTOFF
-ENUMX
- BFD_RELOC_16_GOTOFF
-ENUMX
- BFD_RELOC_LO16_GOTOFF
-ENUMX
- BFD_RELOC_HI16_GOTOFF
-ENUMX
- BFD_RELOC_HI16_S_GOTOFF
-ENUMX
- BFD_RELOC_8_GOTOFF
-ENUMX
- BFD_RELOC_32_PLT_PCREL
-ENUMX
- BFD_RELOC_24_PLT_PCREL
-ENUMX
- BFD_RELOC_16_PLT_PCREL
-ENUMX
- BFD_RELOC_8_PLT_PCREL
-ENUMX
- BFD_RELOC_32_PLTOFF
-ENUMX
- BFD_RELOC_16_PLTOFF
-ENUMX
- BFD_RELOC_LO16_PLTOFF
-ENUMX
- BFD_RELOC_HI16_PLTOFF
-ENUMX
- BFD_RELOC_HI16_S_PLTOFF
-ENUMX
- BFD_RELOC_8_PLTOFF
-ENUMDOC
- For ELF.
-
-ENUM
- BFD_RELOC_68K_GLOB_DAT
-ENUMX
- BFD_RELOC_68K_JMP_SLOT
-ENUMX
- BFD_RELOC_68K_RELATIVE
-ENUMDOC
- Relocations used by 68K ELF.
-
-ENUM
- BFD_RELOC_32_BASEREL
-ENUMX
- BFD_RELOC_16_BASEREL
-ENUMX
- BFD_RELOC_LO16_BASEREL
-ENUMX
- BFD_RELOC_HI16_BASEREL
-ENUMX
- BFD_RELOC_HI16_S_BASEREL
-ENUMX
- BFD_RELOC_8_BASEREL
-ENUMX
- BFD_RELOC_RVA
-ENUMDOC
- Linkage-table relative.
-
-ENUM
- BFD_RELOC_8_FFnn
-ENUMDOC
- Absolute 8-bit relocation, but used to form an address like 0xFFnn.
-
-ENUM
- BFD_RELOC_32_PCREL_S2
-ENUMX
- BFD_RELOC_16_PCREL_S2
-ENUMX
- BFD_RELOC_23_PCREL_S2
-ENUMDOC
- 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.
-
-ENUM
- BFD_RELOC_HI22
-ENUMX
- BFD_RELOC_LO10
-ENUMDOC
- 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.
-
-ENUM
- BFD_RELOC_GPREL16
-ENUMX
- BFD_RELOC_GPREL32
-ENUMDOC
- 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.
-
-
-ENUM
- BFD_RELOC_I960_CALLJ
-ENUMDOC
- Reloc types used for i960/b.out.
-
-ENUM
- BFD_RELOC_NONE
-ENUMX
- BFD_RELOC_SPARC_WDISP22
-ENUMX
- BFD_RELOC_SPARC22
-ENUMX
- BFD_RELOC_SPARC13
-ENUMX
- BFD_RELOC_SPARC_GOT10
-ENUMX
- BFD_RELOC_SPARC_GOT13
-ENUMX
- BFD_RELOC_SPARC_GOT22
-ENUMX
- BFD_RELOC_SPARC_PC10
-ENUMX
- BFD_RELOC_SPARC_PC22
-ENUMX
- BFD_RELOC_SPARC_WPLT30
-ENUMX
- BFD_RELOC_SPARC_COPY
-ENUMX
- BFD_RELOC_SPARC_GLOB_DAT
-ENUMX
- BFD_RELOC_SPARC_JMP_SLOT
-ENUMX
- BFD_RELOC_SPARC_RELATIVE
-ENUMX
- BFD_RELOC_SPARC_UA32
-ENUMDOC
- SPARC ELF relocations. There is probably some overlap with other
- relocation types already defined.
-
-ENUM
- BFD_RELOC_SPARC_BASE13
-ENUMX
- BFD_RELOC_SPARC_BASE22
-ENUMDOC
- I think these are specific to SPARC a.out (e.g., Sun 4).
-
-ENUMEQ
- BFD_RELOC_SPARC_64
- BFD_RELOC_64
-ENUMX
- BFD_RELOC_SPARC_10
-ENUMX
- BFD_RELOC_SPARC_11
-ENUMX
- BFD_RELOC_SPARC_OLO10
-ENUMX
- BFD_RELOC_SPARC_HH22
-ENUMX
- BFD_RELOC_SPARC_HM10
-ENUMX
- BFD_RELOC_SPARC_LM22
-ENUMX
- BFD_RELOC_SPARC_PC_HH22
-ENUMX
- BFD_RELOC_SPARC_PC_HM10
-ENUMX
- BFD_RELOC_SPARC_PC_LM22
-ENUMX
- BFD_RELOC_SPARC_WDISP16
-ENUMX
- BFD_RELOC_SPARC_WDISP19
-ENUMX
- BFD_RELOC_SPARC_GLOB_JMP
-ENUMX
- BFD_RELOC_SPARC_7
-ENUMX
- BFD_RELOC_SPARC_6
-ENUMX
- BFD_RELOC_SPARC_5
-ENUMDOC
- Some relocations we're using for SPARC V9 -- subject to change.
-
-ENUM
- BFD_RELOC_ALPHA_GPDISP_HI16
-ENUMDOC
- 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).
-ENUM
- BFD_RELOC_ALPHA_GPDISP_LO16
-ENUMDOC
- 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.
-
-ENUM
- BFD_RELOC_ALPHA_LITERAL
-ENUMX
- BFD_RELOC_ALPHA_LITUSE
-ENUMDOC
- 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.
-
-ENUM
- BFD_RELOC_ALPHA_HINT
-ENUMDOC
- 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.
-
-ENUM
- BFD_RELOC_MIPS_JMP
-ENUMDOC
- Bits 27..2 of the relocation address shifted right 2 bits;
- simple reloc otherwise.
-
-ENUM
- BFD_RELOC_HI16
-ENUMDOC
- High 16 bits of 32-bit value; simple reloc.
-ENUM
- BFD_RELOC_HI16_S
-ENUMDOC
- 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.
-ENUM
- BFD_RELOC_LO16
-ENUMDOC
- Low 16 bits.
-ENUM
- BFD_RELOC_PCREL_HI16_S
-ENUMDOC
- Like BFD_RELOC_HI16_S, but PC relative.
-ENUM
- BFD_RELOC_PCREL_LO16
-ENUMDOC
- Like BFD_RELOC_LO16, but PC relative.
-
-ENUMEQ
- BFD_RELOC_MIPS_GPREL
- BFD_RELOC_GPREL16
-ENUMDOC
- Relocation relative to the global pointer.
-
-ENUM
- BFD_RELOC_MIPS_LITERAL
-ENUMDOC
- Relocation against a MIPS literal section.
-
-ENUM
- BFD_RELOC_MIPS_GOT16
-ENUMX
- BFD_RELOC_MIPS_CALL16
-ENUMEQX
- BFD_RELOC_MIPS_GPREL32
- BFD_RELOC_GPREL32
-ENUMX
- BFD_RELOC_MIPS_GOT_HI16
-ENUMX
- BFD_RELOC_MIPS_GOT_LO16
-ENUMX
- BFD_RELOC_MIPS_CALL_HI16
-ENUMX
- BFD_RELOC_MIPS_CALL_LO16
-ENUMDOC
- MIPS ELF relocations.
-
-ENUM
- BFD_RELOC_386_GOT32
-ENUMX
- BFD_RELOC_386_PLT32
-ENUMX
- BFD_RELOC_386_COPY
-ENUMX
- BFD_RELOC_386_GLOB_DAT
-ENUMX
- BFD_RELOC_386_JUMP_SLOT
-ENUMX
- BFD_RELOC_386_RELATIVE
-ENUMX
- BFD_RELOC_386_GOTOFF
-ENUMX
- BFD_RELOC_386_GOTPC
-ENUMDOC
- i386/elf relocations
-
-ENUM
- BFD_RELOC_NS32K_IMM_8
-ENUMX
- BFD_RELOC_NS32K_IMM_16
-ENUMX
- BFD_RELOC_NS32K_IMM_32
-ENUMX
- BFD_RELOC_NS32K_IMM_8_PCREL
-ENUMX
- BFD_RELOC_NS32K_IMM_16_PCREL
-ENUMX
- BFD_RELOC_NS32K_IMM_32_PCREL
-ENUMX
- BFD_RELOC_NS32K_DISP_8
-ENUMX
- BFD_RELOC_NS32K_DISP_16
-ENUMX
- BFD_RELOC_NS32K_DISP_32
-ENUMX
- BFD_RELOC_NS32K_DISP_8_PCREL
-ENUMX
- BFD_RELOC_NS32K_DISP_16_PCREL
-ENUMX
- BFD_RELOC_NS32K_DISP_32_PCREL
-ENUMDOC
- ns32k relocations
-
-ENUM
- BFD_RELOC_PPC_B26
-ENUMX
- BFD_RELOC_PPC_BA26
-ENUMX
- BFD_RELOC_PPC_TOC16
-ENUMX
- BFD_RELOC_PPC_B16
-ENUMX
- BFD_RELOC_PPC_B16_BRTAKEN
-ENUMX
- BFD_RELOC_PPC_B16_BRNTAKEN
-ENUMX
- BFD_RELOC_PPC_BA16
-ENUMX
- BFD_RELOC_PPC_BA16_BRTAKEN
-ENUMX
- BFD_RELOC_PPC_BA16_BRNTAKEN
-ENUMX
- BFD_RELOC_PPC_COPY
-ENUMX
- BFD_RELOC_PPC_GLOB_DAT
-ENUMX
- BFD_RELOC_PPC_JMP_SLOT
-ENUMX
- BFD_RELOC_PPC_RELATIVE
-ENUMX
- BFD_RELOC_PPC_LOCAL24PC
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR32
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR16
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR16_LO
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR16_HI
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR16_HA
-ENUMX
- BFD_RELOC_PPC_EMB_SDAI16
-ENUMX
- BFD_RELOC_PPC_EMB_SDA2I16
-ENUMX
- BFD_RELOC_PPC_EMB_SDA2REL
-ENUMX
- BFD_RELOC_PPC_EMB_SDA21
-ENUMX
- BFD_RELOC_PPC_EMB_MRKREF
-ENUMX
- BFD_RELOC_PPC_EMB_RELSEC16
-ENUMX
- BFD_RELOC_PPC_EMB_RELST_LO
-ENUMX
- BFD_RELOC_PPC_EMB_RELST_HI
-ENUMX
- BFD_RELOC_PPC_EMB_RELST_HA
-ENUMX
- BFD_RELOC_PPC_EMB_BIT_FLD
-ENUMX
- BFD_RELOC_PPC_EMB_RELSDA
-ENUMDOC
- Power(rs6000) and PowerPC relocations.
-
-ENUM
- BFD_RELOC_CTOR
-ENUMDOC
- 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.
-
-ENUM
- BFD_RELOC_ARM_PCREL_BRANCH
-ENUMDOC
- ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
- not stored in the instruction.
-ENUM
- BFD_RELOC_ARM_IMMEDIATE
-ENUMX
- BFD_RELOC_ARM_OFFSET_IMM
-ENUMX
- BFD_RELOC_ARM_SHIFT_IMM
-ENUMX
- BFD_RELOC_ARM_SWI
-ENUMX
- BFD_RELOC_ARM_MULTI
-ENUMX
- BFD_RELOC_ARM_CP_OFF_IMM
-ENUMX
- BFD_RELOC_ARM_ADR_IMM
-ENUMX
- BFD_RELOC_ARM_LDR_IMM
-ENUMX
- BFD_RELOC_ARM_LITERAL
-ENUMX
- BFD_RELOC_ARM_IN_POOL
-ENUMDOC
- These relocs are only used within the ARM assembler. They are not
- (at present) written to any object files.
-
-COMMENT
-ENDSENUM
- BFD_RELOC_UNUSED
-CODE_FRAGMENT
-.
-.typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
-*/
-
-
-/*
-FUNCTION
- bfd_reloc_type_lookup
-
-SYNOPSIS
- reloc_howto_type *
- bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code);
-
-DESCRIPTION
- Return a pointer to a howto structure which, when
- invoked, will perform the relocation @var{code} on data from the
- architecture noted.
-
-*/
-
-
-reloc_howto_type *
-bfd_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- return BFD_SEND (abfd, reloc_type_lookup, (abfd, code));
-}
-
-static reloc_howto_type bfd_howto_32 =
-HOWTO (0, 00, 2, 32, false, 0, complain_overflow_bitfield, 0, "VRT32", false, 0xffffffff, 0xffffffff, true);
-
-
-/*
-INTERNAL_FUNCTION
- bfd_default_reloc_type_lookup
-
-SYNOPSIS
- reloc_howto_type *bfd_default_reloc_type_lookup
- (bfd *abfd, bfd_reloc_code_real_type code);
-
-DESCRIPTION
- Provides a default relocation lookup routine for any architecture.
-
-
-*/
-
-reloc_howto_type *
-bfd_default_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- switch (code)
- {
- case BFD_RELOC_CTOR:
- /* The type of reloc used in a ctor, which will be as wide as the
- address - so either a 64, 32, or 16 bitter. */
- switch (bfd_get_arch_info (abfd)->bits_per_address)
- {
- case 64:
- BFD_FAIL ();
- case 32:
- return &bfd_howto_32;
- case 16:
- BFD_FAIL ();
- default:
- BFD_FAIL ();
- }
- default:
- BFD_FAIL ();
- }
- return (reloc_howto_type *) NULL;
-}
-
-/*
-FUNCTION
- bfd_get_reloc_code_name
-
-SYNOPSIS
- const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code);
-
-DESCRIPTION
- Provides a printable name for the supplied relocation code.
- Useful mainly for printing error messages.
-*/
-
-const char *
-bfd_get_reloc_code_name (code)
- bfd_reloc_code_real_type code;
-{
- if (code > BFD_RELOC_UNUSED)
- return 0;
- return bfd_reloc_code_real_names[(int)code];
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_generic_relax_section
-
-SYNOPSIS
- boolean bfd_generic_relax_section
- (bfd *abfd,
- asection *section,
- struct bfd_link_info *,
- boolean *);
-
-DESCRIPTION
- Provides default handling for relaxing for back ends which
- don't do relaxing -- i.e., does nothing.
-*/
-
-/*ARGSUSED*/
-boolean
-bfd_generic_relax_section (abfd, section, link_info, again)
- bfd *abfd;
- asection *section;
- struct bfd_link_info *link_info;
- boolean *again;
-{
- *again = false;
- return true;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_generic_get_relocated_section_contents
-
-SYNOPSIS
- bfd_byte *
- bfd_generic_get_relocated_section_contents (bfd *abfd,
- struct bfd_link_info *link_info,
- struct bfd_link_order *link_order,
- bfd_byte *data,
- boolean relocateable,
- asymbol **symbols);
-
-DESCRIPTION
- Provides default handling of relocation effort for back ends
- which can't be bothered to do it efficiently.
-
-*/
-
-bfd_byte *
-bfd_generic_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 ((size_t) 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 (parent = reloc_vector; *parent != (arelent *) NULL;
- parent++)
- {
- char *error_message = (char *) NULL;
- bfd_reloc_status_type r =
- bfd_perform_relocation (input_bfd,
- *parent,
- (PTR) data,
- input_section,
- relocateable ? abfd : (bfd *) NULL,
- &error_message);
-
- 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;
-}
diff --git a/contrib/gdb/bfd/reloc16.c b/contrib/gdb/bfd/reloc16.c
deleted file mode 100644
index e88d50fb9035..000000000000
--- 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 21a86d5e1024..000000000000
--- 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 4889f72f6dda..000000000000
--- 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/section.c b/contrib/gdb/bfd/section.c
deleted file mode 100644
index ac9a44912100..000000000000
--- a/contrib/gdb/bfd/section.c
+++ /dev/null
@@ -1,976 +0,0 @@
-/* Object file "section" support for the BFD library.
- 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. */
-
-/*
-SECTION
- Sections
-
- The raw data contained within a BFD is maintained through the
- section abstraction. A single BFD may have any number of
- sections. It keeps hold of them by pointing to the first;
- each one points to the next in the list.
-
- Sections are supported in BFD in <<section.c>>.
-
-@menu
-@* Section Input::
-@* Section Output::
-@* typedef asection::
-@* section prototypes::
-@end menu
-
-INODE
-Section Input, Section Output, Sections, Sections
-SUBSECTION
- Section input
-
- When a BFD is opened for reading, the section structures are
- created and attached to the BFD.
-
- Each section has a name which describes the section in the
- outside world---for example, <<a.out>> would contain at least
- three sections, called <<.text>>, <<.data>> and <<.bss>>.
-
- Names need not be unique; for example a COFF file may have several
- sections named <<.data>>.
-
- Sometimes a BFD will contain more than the ``natural'' number of
- sections. A back end may attach other sections containing
- constructor data, or an application may add a section (using
- <<bfd_make_section>>) to the sections attached to an already open
- BFD. For example, the linker creates an extra section
- <<COMMON>> for each input file's BFD to hold information about
- common storage.
-
- The raw data is not necessarily read in when
- the section descriptor is created. Some targets may leave the
- data in place until a <<bfd_get_section_contents>> call is
- made. Other back ends may read in all the data at once. For
- example, an S-record file has to be read once to determine the
- size of the data. An IEEE-695 file doesn't contain raw data in
- sections, but data and relocation expressions intermixed, so
- the data area has to be parsed to get out the data and
- relocations.
-
-INODE
-Section Output, typedef asection, Section Input, Sections
-
-SUBSECTION
- Section output
-
- To write a new object style BFD, the various sections to be
- written have to be created. They are attached to the BFD in
- the same way as input sections; data is written to the
- sections using <<bfd_set_section_contents>>.
-
- Any program that creates or combines sections (e.g., the assembler
- and linker) must use the <<asection>> fields <<output_section>> and
- <<output_offset>> to indicate the file sections to which each
- section must be written. (If the section is being created from
- scratch, <<output_section>> should probably point to the section
- itself and <<output_offset>> should probably be zero.)
-
- The data to be written comes from input sections attached
- (via <<output_section>> pointers) to
- the output sections. The output section structure can be
- considered a filter for the input section: the output section
- determines the vma of the output data and the name, but the
- input section determines the offset into the output section of
- the data to be written.
-
- E.g., to create a section "O", starting at 0x100, 0x123 long,
- containing two subsections, "A" at offset 0x0 (i.e., at vma
- 0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the <<asection>>
- structures would look like:
-
-| section name "A"
-| output_offset 0x00
-| size 0x20
-| output_section -----------> section name "O"
-| | vma 0x100
-| section name "B" | size 0x123
-| output_offset 0x20 |
-| size 0x103 |
-| output_section --------|
-
-
-SUBSECTION
- Link orders
-
- The data within a section is stored in a @dfn{link_order}.
- These are much like the fixups in <<gas>>. The link_order
- abstraction allows a section to grow and shrink within itself.
-
- A link_order knows how big it is, and which is the next
- link_order and where the raw data for it is; it also points to
- a list of relocations which apply to it.
-
- The link_order is used by the linker to perform relaxing on
- final code. The compiler creates code which is as big as
- necessary to make it work without relaxing, and the user can
- select whether to relax. Sometimes relaxing takes a lot of
- time. The linker runs around the relocations to see if any
- are attached to data which can be shrunk, if so it does it on
- a link_order by link_order basis.
-
-*/
-
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-
-/*
-DOCDD
-INODE
-typedef asection, section prototypes, Section Output, Sections
-SUBSECTION
- typedef asection
-
- Here is the section structure:
-
-CODE_FRAGMENT
-.
-.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))
-*/
-
-/* These symbols are global, not specific to any BFD. Therefore, anything
- that tries to change them is broken, and should be repaired. */
-static const asymbol global_syms[] =
-{
- /* the_bfd, name, value, attr, section [, udata] */
- {0, BFD_COM_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_com_section},
- {0, BFD_UND_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_und_section},
- {0, BFD_ABS_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_abs_section},
- {0, BFD_IND_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_ind_section},
-};
-
-#define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX) \
- const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \
- const asection SEC = \
- { NAME, 0, 0, FLAGS, 0, false, 0, 0, 0, 0, (asection *) &SEC, \
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (boolean) 0, \
- (asymbol *) &global_syms[IDX], (asymbol **) &SYM, }
-
-STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol,
- BFD_COM_SECTION_NAME, 0);
-STD_SECTION (bfd_und_section, 0, bfd_und_symbol, BFD_UND_SECTION_NAME, 1);
-STD_SECTION (bfd_abs_section, 0, bfd_abs_symbol, BFD_ABS_SECTION_NAME, 2);
-STD_SECTION (bfd_ind_section, 0, bfd_ind_symbol, BFD_IND_SECTION_NAME, 3);
-#undef STD_SECTION
-
-/*
-DOCDD
-INODE
-section prototypes, , typedef asection, Sections
-SUBSECTION
- Section prototypes
-
-These are the functions exported by the section handling part of BFD.
-*/
-
-/*
-FUNCTION
- bfd_get_section_by_name
-
-SYNOPSIS
- asection *bfd_get_section_by_name(bfd *abfd, CONST char *name);
-
-DESCRIPTION
- Run through @var{abfd} and return the one of the
- <<asection>>s whose name matches @var{name}, otherwise <<NULL>>.
- @xref{Sections}, for more information.
-
- This should only be used in special cases; the normal way to process
- all sections of a given name is to use <<bfd_map_over_sections>> and
- <<strcmp>> on the name (or better yet, base it on the section flags
- or something else) for each section.
-*/
-
-asection *
-bfd_get_section_by_name (abfd, name)
- bfd *abfd;
- CONST char *name;
-{
- asection *sect;
-
- for (sect = abfd->sections; sect != NULL; sect = sect->next)
- if (!strcmp (sect->name, name))
- return sect;
- return NULL;
-}
-
-
-/*
-FUNCTION
- bfd_make_section_old_way
-
-SYNOPSIS
- asection *bfd_make_section_old_way(bfd *abfd, CONST char *name);
-
-DESCRIPTION
- Create a new empty section called @var{name}
- and attach it to the end of the chain of sections for the
- BFD @var{abfd}. An attempt to create a section with a name which
- is already in use returns its pointer without changing the
- section chain.
-
- It has the funny name since this is the way it used to be
- before it was rewritten....
-
- Possible errors are:
- o <<bfd_error_invalid_operation>> -
- If output has already started for this BFD.
- o <<bfd_error_no_memory>> -
- If obstack alloc fails.
-
-*/
-
-
-asection *
-bfd_make_section_old_way (abfd, name)
- bfd *abfd;
- CONST char *name;
-{
- asection *sec = bfd_get_section_by_name (abfd, name);
- if (sec == (asection *) NULL)
- {
- sec = bfd_make_section (abfd, name);
- }
- return sec;
-}
-
-/*
-FUNCTION
- bfd_make_section_anyway
-
-SYNOPSIS
- asection *bfd_make_section_anyway(bfd *abfd, CONST char *name);
-
-DESCRIPTION
- Create a new empty section called @var{name} and attach it to the end of
- the chain of sections for @var{abfd}. Create a new section even if there
- is already a section with that name.
-
- Return <<NULL>> and set <<bfd_error>> on error; possible errors are:
- o <<bfd_error_invalid_operation>> - If output has already started for @var{abfd}.
- o <<bfd_error_no_memory>> - If obstack alloc fails.
-*/
-
-sec_ptr
-bfd_make_section_anyway (abfd, name)
- bfd *abfd;
- CONST char *name;
-{
- asection *newsect;
- asection **prev = &abfd->sections;
- asection *sect = abfd->sections;
-
- if (abfd->output_has_begun)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
- }
-
- while (sect)
- {
- prev = &sect->next;
- sect = sect->next;
- }
-
- newsect = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (newsect == NULL)
- return NULL;
-
- newsect->name = name;
- newsect->index = abfd->section_count++;
- newsect->flags = SEC_NO_FLAGS;
-
- newsect->userdata = NULL;
- newsect->contents = NULL;
- newsect->next = (asection *) NULL;
- newsect->relocation = (arelent *) NULL;
- newsect->reloc_count = 0;
- newsect->line_filepos = 0;
- newsect->owner = abfd;
-
- /* Create a symbol whos only job is to point to this section. This is
- useful for things like relocs which are relative to the base of a
- section. */
- newsect->symbol = bfd_make_empty_symbol (abfd);
- if (newsect->symbol == NULL)
- return NULL;
- newsect->symbol->name = name;
- newsect->symbol->value = 0;
- newsect->symbol->section = newsect;
- newsect->symbol->flags = BSF_SECTION_SYM;
-
- newsect->symbol_ptr_ptr = &newsect->symbol;
-
- if (BFD_SEND (abfd, _new_section_hook, (abfd, newsect)) != true)
- {
- free (newsect);
- return NULL;
- }
-
- *prev = newsect;
- return newsect;
-}
-
-/*
-FUNCTION
- bfd_make_section
-
-SYNOPSIS
- asection *bfd_make_section(bfd *, CONST char *name);
-
-DESCRIPTION
- Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling
- bfd_set_error ()) without changing the section chain if there is already a
- section named @var{name}. If there is an error, return <<NULL>> and set
- <<bfd_error>>.
-*/
-
-asection *
-bfd_make_section (abfd, name)
- bfd *abfd;
- CONST char *name;
-{
- asection *sect = abfd->sections;
-
- if (strcmp (name, BFD_ABS_SECTION_NAME) == 0)
- {
- return bfd_abs_section_ptr;
- }
- if (strcmp (name, BFD_COM_SECTION_NAME) == 0)
- {
- return bfd_com_section_ptr;
- }
- if (strcmp (name, BFD_UND_SECTION_NAME) == 0)
- {
- return bfd_und_section_ptr;
- }
-
- if (strcmp (name, BFD_IND_SECTION_NAME) == 0)
- {
- return bfd_ind_section_ptr;
- }
-
- while (sect)
- {
- if (!strcmp (sect->name, name))
- return NULL;
- sect = sect->next;
- }
-
- /* The name is not already used; go ahead and make a new section. */
- return bfd_make_section_anyway (abfd, name);
-}
-
-
-/*
-FUNCTION
- bfd_set_section_flags
-
-SYNOPSIS
- boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags);
-
-DESCRIPTION
- Set the attributes of the section @var{sec} in the BFD
- @var{abfd} to the value @var{flags}. Return <<true>> on success,
- <<false>> on error. Possible error returns are:
-
- o <<bfd_error_invalid_operation>> -
- The section cannot have one or more of the attributes
- requested. For example, a .bss section in <<a.out>> may not
- have the <<SEC_HAS_CONTENTS>> field set.
-
-*/
-
-/*ARGSUSED*/
-boolean
-bfd_set_section_flags (abfd, section, flags)
- bfd *abfd;
- sec_ptr section;
- flagword flags;
-{
-#if 0
- /* If you try to copy a text section from an input file (where it
- has the SEC_CODE flag set) to an output file, this loses big if
- the bfd_applicable_section_flags (abfd) doesn't have the SEC_CODE
- set - which it doesn't, at least not for a.out. FIXME */
-
- if ((flags & bfd_applicable_section_flags (abfd)) != flags)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-#endif
-
- section->flags = flags;
- return true;
-}
-
-
-/*
-FUNCTION
- bfd_map_over_sections
-
-SYNOPSIS
- void bfd_map_over_sections(bfd *abfd,
- void (*func)(bfd *abfd,
- asection *sect,
- PTR obj),
- PTR obj);
-
-DESCRIPTION
- Call the provided function @var{func} for each section
- attached to the BFD @var{abfd}, passing @var{obj} as an
- argument. The function will be called as if by
-
-| func(abfd, the_section, obj);
-
- This is the prefered method for iterating over sections; an
- alternative would be to use a loop:
-
-| section *p;
-| for (p = abfd->sections; p != NULL; p = p->next)
-| func(abfd, p, ...)
-
-
-*/
-
-/*VARARGS2*/
-void
-bfd_map_over_sections (abfd, operation, user_storage)
- bfd *abfd;
- void (*operation) PARAMS ((bfd * abfd, asection * sect, PTR obj));
- PTR user_storage;
-{
- asection *sect;
- unsigned int i = 0;
-
- for (sect = abfd->sections; sect != NULL; i++, sect = sect->next)
- (*operation) (abfd, sect, user_storage);
-
- if (i != abfd->section_count) /* Debugging */
- abort ();
-}
-
-
-/*
-FUNCTION
- bfd_set_section_size
-
-SYNOPSIS
- boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val);
-
-DESCRIPTION
- Set @var{sec} to the size @var{val}. If the operation is
- ok, then <<true>> is returned, else <<false>>.
-
- Possible error returns:
- o <<bfd_error_invalid_operation>> -
- Writing has started to the BFD, so setting the size is invalid.
-
-*/
-
-boolean
-bfd_set_section_size (abfd, ptr, val)
- bfd *abfd;
- sec_ptr ptr;
- bfd_size_type val;
-{
- /* Once you've started writing to any section you cannot create or change
- the size of any others. */
-
- if (abfd->output_has_begun)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- ptr->_cooked_size = val;
- ptr->_raw_size = val;
-
- return true;
-}
-
-/*
-FUNCTION
- bfd_set_section_contents
-
-SYNOPSIS
- boolean bfd_set_section_contents
- (bfd *abfd,
- asection *section,
- PTR data,
- file_ptr offset,
- bfd_size_type count);
-
-
-DESCRIPTION
- Sets the contents of the section @var{section} in BFD
- @var{abfd} to the data starting in memory at @var{data}. The
- data is written to the output section starting at offset
- @var{offset} for @var{count} bytes.
-
-
-
- Normally <<true>> is returned, else <<false>>. Possible error
- returns are:
- o <<bfd_error_no_contents>> -
- The output section does not have the <<SEC_HAS_CONTENTS>>
- attribute, so nothing can be written to it.
- o and some more too
-
- This routine is front end to the back end function
- <<_bfd_set_section_contents>>.
-
-
-*/
-
-#define bfd_get_section_size_now(abfd,sec) \
-(sec->reloc_done \
- ? bfd_get_section_size_after_reloc (sec) \
- : bfd_get_section_size_before_reloc (sec))
-
-boolean
-bfd_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- bfd_size_type sz;
-
- if (!(bfd_get_section_flags (abfd, section) & SEC_HAS_CONTENTS))
- {
- bfd_set_error (bfd_error_no_contents);
- return (false);
- }
-
- if (offset < 0)
- {
- bad_val:
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- sz = bfd_get_section_size_now (abfd, section);
- if ((bfd_size_type) offset > sz
- || count > sz
- || offset + count > sz)
- goto bad_val;
-
- switch (abfd->direction)
- {
- case read_direction:
- case no_direction:
- bfd_set_error (bfd_error_invalid_operation);
- return false;
-
- case write_direction:
- break;
-
- case both_direction:
- /* File is opened for update. `output_has_begun' some time ago when
- the file was created. Do not recompute sections sizes or alignments
- in _bfd_set_section_content. */
- abfd->output_has_begun = true;
- break;
- }
-
- if (BFD_SEND (abfd, _bfd_set_section_contents,
- (abfd, section, location, offset, count)))
- {
- abfd->output_has_begun = true;
- return true;
- }
-
- return false;
-}
-
-/*
-FUNCTION
- bfd_get_section_contents
-
-SYNOPSIS
- boolean bfd_get_section_contents
- (bfd *abfd, asection *section, PTR location,
- file_ptr offset, bfd_size_type count);
-
-DESCRIPTION
- Read data from @var{section} in BFD @var{abfd}
- into memory starting at @var{location}. The data is read at an
- offset of @var{offset} from the start of the input section,
- and is read for @var{count} bytes.
-
- If the contents of a constructor with the <<SEC_CONSTRUCTOR>>
- flag set are requested or if the section does not have the
- <<SEC_HAS_CONTENTS>> flag set, then the @var{location} is filled
- with zeroes. If no errors occur, <<true>> is returned, else
- <<false>>.
-
-
-
-*/
-boolean
-bfd_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- bfd_size_type sz;
-
- if (section->flags & SEC_CONSTRUCTOR)
- {
- memset (location, 0, (unsigned) count);
- return true;
- }
-
- if (offset < 0)
- {
- bad_val:
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- /* Even if reloc_done is true, this function reads unrelocated
- contents, so we want the raw size. */
- sz = section->_raw_size;
- if ((bfd_size_type) offset > sz || count > sz || offset + count > sz)
- goto bad_val;
-
- if (count == 0)
- /* Don't bother. */
- return true;
-
- if ((section->flags & SEC_HAS_CONTENTS) == 0)
- {
- memset (location, 0, (unsigned) count);
- return true;
- }
-
- if ((section->flags & SEC_IN_MEMORY) != 0)
- {
- memcpy (location, section->contents + offset, (size_t) count);
- return true;
- }
-
- return BFD_SEND (abfd, _bfd_get_section_contents,
- (abfd, section, location, offset, count));
-}
-
-/*
-FUNCTION
- bfd_copy_private_section_data
-
-SYNOPSIS
- boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
-
-DESCRIPTION
- Copy private section information from @var{isec} in the BFD
- @var{ibfd} to the section @var{osec} in the BFD @var{obfd}.
- Return <<true>> on success, <<false>> on error. Possible error
- returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{osec}.
-
-.#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
-. BFD_SEND (ibfd, _bfd_copy_private_section_data, \
-. (ibfd, isection, obfd, osection))
-*/
diff --git a/contrib/gdb/bfd/som.c b/contrib/gdb/bfd/som.c
deleted file mode 100644
index dd03d99ee199..000000000000
--- 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 6290e88f948c..000000000000
--- 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 0885620283ec..000000000000
--- 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 69240f5d1587..000000000000
--- 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/srec.c b/contrib/gdb/bfd/srec.c
deleted file mode 100644
index 33d28d5eab81..000000000000
--- a/contrib/gdb/bfd/srec.c
+++ /dev/null
@@ -1,1324 +0,0 @@
-/* BFD back-end for s-record objects.
- Copyright 1990, 1991, 1992, 1993, 1994, 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
- S-Record handling
-
-DESCRIPTION
-
- Ordinary S-Records cannot hold anything but addresses and
- data, so that's all that we implement.
-
- The only interesting thing is that S-Records may come out of
- order and there is no header, so an initial scan is required
- to discover the minimum and maximum addresses used to create
- the vma and size of the only section we create. We
- arbitrarily call this section ".text".
-
- When bfd_get_section_contents is called the file is read
- again, and this time the data is placed into a bfd_alloc'd
- area.
-
- Any number of sections may be created for output, we save them
- up and output them when it's time to close the bfd.
-
- An s record looks like:
-
-EXAMPLE
- S<type><length><address><data><checksum>
-
-DESCRIPTION
- Where
- o 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.
- o 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
-
- o address
- is the start address of the data following, or in the case of
- a termination record, the start address of the image
- o data
- is the data.
- o checksum
- is the sum of all the raw byte data in the record, from the length
- upwards, modulo 256 and subtracted from 255.
-
-
-SUBSECTION
- Symbol S-Record handling
-
-DESCRIPTION
- Some ICE equipment understands an addition to the standard
- S-Record format; symbols and their addresses can be sent
- before the data.
-
- The format of this is:
- ($$ <modulename>
- (<space> <symbol> <address>)*)
- $$
-
- so a short symbol table could look like:
-
-EXAMPLE
- $$ flash.x
- $$ flash.c
- _port6 $0
- _delay $4
- _start $14
- _etext $8036
- _edata $8036
- _end $8036
- $$
-
-DESCRIPTION
- We allow symbols to be anywhere in the data stream - the module names
- are always ignored.
-
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libiberty.h"
-#include <ctype.h>
-
-static void srec_init PARAMS ((void));
-static boolean srec_mkobject PARAMS ((bfd *));
-static int srec_get_byte PARAMS ((bfd *, boolean *));
-static void srec_bad_byte PARAMS ((bfd *, unsigned int, int, boolean));
-static boolean srec_scan PARAMS ((bfd *));
-static const bfd_target *srec_object_p PARAMS ((bfd *));
-static const bfd_target *symbolsrec_object_p PARAMS ((bfd *));
-static boolean srec_read_section PARAMS ((bfd *, asection *, bfd_byte *));
-
-static boolean srec_write_record PARAMS ((bfd *, int, bfd_vma,
- const bfd_byte *,
- const bfd_byte *));
-static boolean srec_write_header PARAMS ((bfd *));
-static boolean srec_write_symbols PARAMS ((bfd *));
-
-/* Macros for converting between hex and binary. */
-
-static CONST char digs[] = "0123456789ABCDEF";
-
-#define NIBBLE(x) hex_value(x)
-#define HEX(buffer) ((NIBBLE((buffer)[0])<<4) + NIBBLE((buffer)[1]))
-#define TOHEX(d, x, ch) \
- d[1] = digs[(x) & 0xf]; \
- d[0] = digs[((x)>>4)&0xf]; \
- ch += ((x) & 0xff);
-#define ISHEX(x) hex_p(x)
-
-/* Initialize by filling in the hex conversion array. */
-
-static void
-srec_init ()
-{
- static boolean inited = false;
-
- if (inited == false)
- {
- inited = true;
- hex_init ();
- }
-}
-
-/* The maximum number of bytes on a line is FF */
-#define MAXCHUNK 0xff
-/* The number of bytes we fit onto a line on output */
-#define CHUNK 21
-
-/* When writing an S-record file, the S-records can not be output as
- they are seen. This structure is used to hold them in memory. */
-
-struct srec_data_list_struct
-{
- struct srec_data_list_struct *next;
- bfd_byte *data;
- bfd_vma where;
- bfd_size_type size;
-};
-
-typedef struct srec_data_list_struct srec_data_list_type;
-
-/* When scanning the S-record file, a linked list of srec_symbol
- structures is built to represent the symbol table (if there is
- one). */
-
-struct srec_symbol
-{
- struct srec_symbol *next;
- const char *name;
- bfd_vma val;
-};
-
-/* The S-record tdata information. */
-
-typedef struct srec_data_struct
- {
- srec_data_list_type *head;
- srec_data_list_type *tail;
- unsigned int type;
- struct srec_symbol *symbols;
- struct srec_symbol *symtail;
- asymbol *csymbols;
- }
-tdata_type;
-
-static boolean srec_write_section PARAMS ((bfd *, tdata_type *,
- srec_data_list_type *));
-static boolean srec_write_terminator PARAMS ((bfd *, tdata_type *));
-
-/* Set up the S-record tdata information. */
-
-static boolean
-srec_mkobject (abfd)
- bfd *abfd;
-{
- srec_init ();
-
- if (abfd->tdata.srec_data == NULL)
- {
- tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
- if (tdata == NULL)
- return false;
- abfd->tdata.srec_data = tdata;
- tdata->type = 1;
- tdata->head = NULL;
- tdata->tail = NULL;
- tdata->symbols = NULL;
- tdata->symtail = NULL;
- tdata->csymbols = NULL;
- }
-
- return true;
-}
-
-/* Read a byte from an S record file. Set *ERRORPTR if an error
- occurred. Return EOF on error or end of file. */
-
-static int
-srec_get_byte (abfd, errorptr)
- bfd *abfd;
- boolean *errorptr;
-{
- bfd_byte c;
-
- if (bfd_read (&c, 1, 1, abfd) != 1)
- {
- if (bfd_get_error () != bfd_error_file_truncated)
- *errorptr = true;
- return EOF;
- }
-
- return (int) (c & 0xff);
-}
-
-/* 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 void
-srec_bad_byte (abfd, lineno, c, error)
- bfd *abfd;
- unsigned int lineno;
- int c;
- boolean error;
-{
- if (c == EOF)
- {
- if (! error)
- bfd_set_error (bfd_error_file_truncated);
- }
- else
- {
- char buf[10];
-
- if (! isprint (c))
- sprintf (buf, "\\%03o", (unsigned int) c);
- else
- {
- buf[0] = c;
- buf[1] = '\0';
- }
- (*_bfd_error_handler)
- ("%s:%d: Unexpected character `%s' in S-record file\n",
- bfd_get_filename (abfd), lineno, buf);
- bfd_set_error (bfd_error_bad_value);
- }
-}
-
-/* Add a new symbol found in an S-record file. */
-
-static boolean
-srec_new_symbol (abfd, name, val)
- bfd *abfd;
- const char *name;
- bfd_vma val;
-{
- struct srec_symbol *n;
-
- n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (struct srec_symbol));
- if (n == NULL)
- return false;
-
- n->name = name;
- n->val = val;
-
- if (abfd->tdata.srec_data->symbols == NULL)
- abfd->tdata.srec_data->symbols = n;
- else
- abfd->tdata.srec_data->symtail->next = n;
- abfd->tdata.srec_data->symtail = n;
- n->next = NULL;
-
- ++abfd->symcount;
-
- return true;
-}
-
-/* Read the S record file and turn it into sections. We create a new
- section for each contiguous set of bytes. */
-
-static boolean
-srec_scan (abfd)
- bfd *abfd;
-{
- int c;
- unsigned int lineno = 1;
- boolean error = false;
- bfd_byte *buf = NULL;
- size_t bufsize = 0;
- asection *sec = NULL;
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto error_return;
-
- while ((c = srec_get_byte (abfd, &error)) != EOF)
- {
- /* We only build sections from contiguous S-records, so if this
- is not an S-record, then stop building a section. */
- if (c != 'S' && c != '\r' && c != '\n')
- sec = NULL;
-
- switch (c)
- {
- default:
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
-
- case '\n':
- ++lineno;
- break;
-
- case '\r':
- break;
-
- case '$':
- /* Starting a module name, which we ignore. */
- while ((c = srec_get_byte (abfd, &error)) != '\n'
- && c != EOF)
- ;
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- ++lineno;
-
- break;
-
- case ' ':
- {
- char *symname;
- bfd_vma symval;
-
- /* Starting a symbol definition. */
- while ((c = srec_get_byte (abfd, &error)) != EOF
- && (c == ' ' || c == '\t'))
- ;
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- obstack_1grow (&abfd->memory, c);
- while ((c = srec_get_byte (abfd, &error)) != EOF
- && ! isspace (c))
- obstack_1grow (&abfd->memory, c);
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- symname = obstack_finish (&abfd->memory);
- if (symname == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
-
- while ((c = srec_get_byte (abfd, &error)) != EOF
- && (c == ' ' || c == '\t'))
- ;
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- /* Skip a dollar sign before the hex value. */
- if (c == '$')
- {
- c = srec_get_byte (abfd, &error);
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
- }
-
- symval = 0;
- while (ISHEX (c))
- {
- symval <<= 4;
- symval += NIBBLE (c);
- c = srec_get_byte (abfd, &error);
- }
-
- if (c == EOF || ! isspace (c))
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- if (! srec_new_symbol (abfd, symname, symval))
- goto error_return;
-
- if (c == '\n')
- ++lineno;
-
- }
- break;
-
- case 'S':
- {
- file_ptr pos;
- char hdr[3];
- unsigned int bytes;
- bfd_vma address;
- bfd_byte *data;
-
- /* Starting an S-record. */
-
- pos = bfd_tell (abfd) - 1;
-
- if (bfd_read (hdr, 1, 3, abfd) != 3)
- goto error_return;
-
- if (! ISHEX (hdr[1]) || ! ISHEX (hdr[2]))
- {
- if (! ISHEX (hdr[1]))
- c = hdr[1];
- else
- c = hdr[2];
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- bytes = HEX (hdr + 1);
- if (bytes * 2 > bufsize)
- {
- if (buf != NULL)
- free (buf);
- buf = (bfd_byte *) bfd_malloc (bytes * 2);
- if (buf == NULL)
- goto error_return;
- bufsize = bytes * 2;
- }
-
- if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
- goto error_return;
-
- /* Ignore the checksum byte. */
- --bytes;
-
- address = 0;
- data = buf;
- switch (hdr[0])
- {
- case '0':
- case '5':
- /* Prologue--ignore the file name, but stop building a
- section at this point. */
- sec = NULL;
- break;
-
- case '3':
- address = HEX (data);
- data += 2;
- --bytes;
- /* Fall through. */
- case '2':
- address = (address << 8) | HEX (data);
- data += 2;
- --bytes;
- /* Fall through. */
- case '1':
- address = (address << 8) | HEX (data);
- data += 2;
- address = (address << 8) | HEX (data);
- data += 2;
- bytes -= 2;
-
- if (sec != NULL
- && sec->vma + sec->_raw_size == address)
- {
- /* This data goes at the end of the section we are
- currently building. */
- sec->_raw_size += bytes;
- }
- else
- {
- char secbuf[20];
- char *secname;
-
- sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
- secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
- strcpy (secname, secbuf);
- sec = bfd_make_section (abfd, secname);
- if (sec == NULL)
- goto error_return;
- sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
- sec->vma = address;
- sec->lma = address;
- sec->_raw_size = bytes;
- sec->filepos = pos;
- }
-
- break;
-
- case '7':
- address = HEX (data);
- data += 2;
- /* Fall through. */
- case '8':
- address = (address << 8) | HEX (data);
- data += 2;
- /* Fall through. */
- case '9':
- address = (address << 8) | HEX (data);
- data += 2;
- address = (address << 8) | HEX (data);
- data += 2;
-
- /* This is a termination record. */
- abfd->start_address = address;
-
- if (buf != NULL)
- free (buf);
-
- return true;
- }
- }
- break;
- }
- }
-
- if (error)
- goto error_return;
-
- if (buf != NULL)
- free (buf);
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Check whether an existing file is an S-record file. */
-
-static const bfd_target *
-srec_object_p (abfd)
- bfd *abfd;
-{
- bfd_byte b[4];
-
- srec_init ();
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_read (b, 1, 4, abfd) != 4)
- return NULL;
-
- if (b[0] != 'S' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if (! srec_mkobject (abfd)
- || ! srec_scan (abfd))
- return NULL;
-
- return abfd->xvec;
-}
-
-/* Check whether an existing file is an S-record file with symbols. */
-
-static const bfd_target *
-symbolsrec_object_p (abfd)
- bfd *abfd;
-{
- char b[2];
-
- srec_init ();
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_read (b, 1, 2, abfd) != 2)
- return NULL;
-
- if (b[0] != '$' || b[1] != '$')
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if (! srec_mkobject (abfd)
- || ! srec_scan (abfd))
- return NULL;
-
- return abfd->xvec;
-}
-
-/* Read in the contents of a section in an S-record file. */
-
-static boolean
-srec_read_section (abfd, section, contents)
- bfd *abfd;
- asection *section;
- bfd_byte *contents;
-{
- int c;
- bfd_size_type sofar = 0;
- boolean error = false;
- bfd_byte *buf = NULL;
- size_t bufsize = 0;
-
- if (bfd_seek (abfd, section->filepos, SEEK_SET) != 0)
- goto error_return;
-
- while ((c = srec_get_byte (abfd, &error)) != EOF)
- {
- bfd_byte hdr[3];
- unsigned int bytes;
- bfd_vma address;
- bfd_byte *data;
-
- if (c == '\r' || c == '\n')
- continue;
-
- /* This is called after srec_scan has already been called, so we
- ought to know the exact format. */
- BFD_ASSERT (c == 'S');
-
- if (bfd_read (hdr, 1, 3, abfd) != 3)
- goto error_return;
-
- BFD_ASSERT (ISHEX (hdr[1]) && ISHEX (hdr[2]));
-
- bytes = HEX (hdr + 1);
-
- if (bytes * 2 > bufsize)
- {
- if (buf != NULL)
- free (buf);
- buf = (bfd_byte *) bfd_malloc (bytes * 2);
- if (buf == NULL)
- goto error_return;
- bufsize = bytes * 2;
- }
-
- if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
- goto error_return;
-
- address = 0;
- data = buf;
- switch (hdr[0])
- {
- default:
- BFD_ASSERT (sofar == section->_raw_size);
- if (buf != NULL)
- free (buf);
- return true;
-
- case '3':
- address = HEX (data);
- data += 2;
- --bytes;
- /* Fall through. */
- case '2':
- address = (address << 8) | HEX (data);
- data += 2;
- --bytes;
- /* Fall through. */
- case '1':
- address = (address << 8) | HEX (data);
- data += 2;
- address = (address << 8) | HEX (data);
- data += 2;
- bytes -= 2;
-
- if (address != section->vma + sofar)
- {
- /* We've come to the end of this section. */
- BFD_ASSERT (sofar == section->_raw_size);
- if (buf != NULL)
- free (buf);
- return true;
- }
-
- /* Don't consider checksum. */
- --bytes;
-
- while (bytes-- != 0)
- {
- contents[sofar] = HEX (data);
- data += 2;
- ++sofar;
- }
-
- break;
- }
- }
-
- if (error)
- goto error_return;
-
- BFD_ASSERT (sofar == section->_raw_size);
-
- if (buf != NULL)
- free (buf);
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Get the contents of a section in an S-record file. */
-
-static boolean
-srec_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (section->used_by_bfd == NULL)
- {
- section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
- if (section->used_by_bfd == NULL
- && section->_raw_size != 0)
- return false;
-
- if (! srec_read_section (abfd, section, section->used_by_bfd))
- return false;
- }
-
- memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
- (size_t) count);
-
- return true;
-}
-
-/* we have to save up all the Srecords for a splurge before output */
-
-static boolean
-srec_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;
-{
- tdata_type *tdata = abfd->tdata.srec_data;
- register srec_data_list_type *entry;
-
- entry = ((srec_data_list_type *)
- bfd_alloc (abfd, sizeof (srec_data_list_type)));
- if (entry == NULL)
- return false;
-
- if (bytes_to_do
- && (section->flags & SEC_ALLOC)
- && (section->flags & SEC_LOAD))
- {
- bfd_byte *data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
- if (data == NULL)
- return false;
- memcpy ((PTR) data, location, (size_t) bytes_to_do);
-
- if ((section->lma + offset + bytes_to_do - 1) <= 0xffff)
- {
-
- }
- else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
- && tdata->type < 2)
- {
- tdata->type = 2;
- }
- else
- {
- tdata->type = 3;
- }
-
- entry->data = data;
- entry->where = section->lma + offset;
- entry->size = bytes_to_do;
-
- /* Sort the records by address. Optimize for the common case of
- adding a record to the end of the list. */
- if (tdata->tail != NULL
- && entry->where >= tdata->tail->where)
- {
- tdata->tail->next = entry;
- entry->next = NULL;
- tdata->tail = entry;
- }
- else
- {
- register srec_data_list_type **look;
-
- for (look = &tdata->head;
- *look != NULL && (*look)->where < entry->where;
- look = &(*look)->next)
- ;
- entry->next = *look;
- *look = entry;
- if (entry->next == NULL)
- tdata->tail = entry;
- }
- }
- return true;
-}
-
-/* Write a record of type, of the supplied number of bytes. The
- supplied bytes and length don't have a checksum. That's worked out
- here
-*/
-static boolean
-srec_write_record (abfd, type, address, data, end)
- bfd *abfd;
- int type;
- bfd_vma address;
- const bfd_byte *data;
- const bfd_byte *end;
-{
- char buffer[MAXCHUNK];
- unsigned int check_sum = 0;
- CONST bfd_byte *src = data;
- char *dst = buffer;
- char *length;
- bfd_size_type wrlen;
-
- *dst++ = 'S';
- *dst++ = '0' + type;
-
- length = dst;
- dst += 2; /* leave room for dst*/
-
- switch (type)
- {
- case 3:
- case 7:
- TOHEX (dst, (address >> 24), check_sum);
- dst += 2;
- case 8:
- case 2:
- TOHEX (dst, (address >> 16), check_sum);
- dst += 2;
- case 9:
- case 1:
- case 0:
- TOHEX (dst, (address >> 8), check_sum);
- dst += 2;
- TOHEX (dst, (address), check_sum);
- dst += 2;
- break;
-
- }
- for (src = data; src < end; src++)
- {
- TOHEX (dst, *src, check_sum);
- dst += 2;
- }
-
- /* Fill in the length */
- TOHEX (length, (dst - length) / 2, check_sum);
- check_sum &= 0xff;
- check_sum = 255 - check_sum;
- TOHEX (dst, check_sum, check_sum);
- dst += 2;
-
- *dst++ = '\r';
- *dst++ = '\n';
- wrlen = dst - buffer;
- if (bfd_write ((PTR) buffer, 1, wrlen, abfd) != wrlen)
- return false;
- return true;
-}
-
-
-
-static boolean
-srec_write_header (abfd)
- bfd *abfd;
-{
- bfd_byte buffer[MAXCHUNK];
- bfd_byte *dst = buffer;
- unsigned int i;
-
- /* I'll put an arbitary 40 char limit on header size */
- for (i = 0; i < 40 && abfd->filename[i]; i++)
- {
- *dst++ = abfd->filename[i];
- }
- return srec_write_record (abfd, 0, 0, buffer, dst);
-}
-
-static boolean
-srec_write_section (abfd, tdata, list)
- bfd *abfd;
- tdata_type *tdata;
- srec_data_list_type *list;
-{
- unsigned int bytes_written = 0;
- bfd_byte *location = list->data;
-
- while (bytes_written < list->size)
- {
- bfd_vma address;
-
- unsigned int bytes_this_chunk = list->size - bytes_written;
-
- if (bytes_this_chunk > CHUNK)
- {
- bytes_this_chunk = CHUNK;
- }
-
- address = list->where + bytes_written;
-
- if (! srec_write_record (abfd,
- tdata->type,
- address,
- location,
- location + bytes_this_chunk))
- return false;
-
- bytes_written += bytes_this_chunk;
- location += bytes_this_chunk;
- }
-
- return true;
-}
-
-static boolean
-srec_write_terminator (abfd, tdata)
- bfd *abfd;
- tdata_type *tdata;
-{
- bfd_byte buffer[2];
-
- return srec_write_record (abfd, 10 - tdata->type,
- abfd->start_address, buffer, buffer);
-}
-
-
-
-static boolean
-srec_write_symbols (abfd)
- bfd *abfd;
-{
- char buffer[MAXCHUNK];
- /* Dump out the symbols of a bfd */
- int i;
- int count = bfd_get_symcount (abfd);
-
- if (count)
- {
- size_t len;
- asymbol **table = bfd_get_outsymbols (abfd);
- sprintf (buffer, "$$ %s\r\n", abfd->filename);
-
- len = strlen (buffer);
- if (bfd_write (buffer, len, 1, abfd) != len)
- return false;
-
- for (i = 0; i < count; i++)
- {
- asymbol *s = table[i];
-#if 0
- int len = strlen (s->name);
-
- /* If this symbol has a .[ocs] in it, it's probably a file name
- and we'll output that as the module name */
-
- if (len > 3 && s->name[len - 2] == '.')
- {
- int l;
- sprintf (buffer, "$$ %s\r\n", s->name);
- l = strlen (buffer);
- if (bfd_write (buffer, l, 1, abfd) != l)
- return false;
- }
- else
-#endif
- if (s->flags & (BSF_GLOBAL | BSF_LOCAL)
- && (s->flags & BSF_DEBUGGING) == 0
- && s->name[0] != '.'
- && s->name[0] != 't')
- {
- /* Just dump out non debug symbols */
- bfd_size_type l;
- char buf2[40], *p;
-
- sprintf_vma (buf2,
- s->value + s->section->output_section->lma
- + s->section->output_offset);
- p = buf2;
- while (p[0] == '0' && p[1] != 0)
- p++;
- sprintf (buffer, " %s $%s\r\n", s->name, p);
- l = strlen (buffer);
- if (bfd_write (buffer, l, 1, abfd) != l)
- return false;
- }
- }
- sprintf (buffer, "$$ \r\n");
- len = strlen (buffer);
- if (bfd_write (buffer, len, 1, abfd) != len)
- return false;
- }
-
- return true;
-}
-
-static boolean
-internal_srec_write_object_contents (abfd, symbols)
- bfd *abfd;
- int symbols;
-{
- tdata_type *tdata = abfd->tdata.srec_data;
- srec_data_list_type *list;
-
- if (symbols)
- {
- if (! srec_write_symbols (abfd))
- return false;
- }
-
- if (! srec_write_header (abfd))
- return false;
-
- /* Now wander though all the sections provided and output them */
- list = tdata->head;
-
- while (list != (srec_data_list_type *) NULL)
- {
- if (! srec_write_section (abfd, tdata, list))
- return false;
- list = list->next;
- }
- return srec_write_terminator (abfd, tdata);
-}
-
-static boolean
-srec_write_object_contents (abfd)
- bfd *abfd;
-{
- return internal_srec_write_object_contents (abfd, 0);
-}
-
-static boolean
-symbolsrec_write_object_contents (abfd)
- bfd *abfd;
-{
- return internal_srec_write_object_contents (abfd, 1);
-}
-
-/*ARGSUSED*/
-static int
-srec_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-{
- return 0;
-}
-
-static asymbol *
-srec_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
-srec_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- return (bfd_get_symcount (abfd) + 1) * sizeof (asymbol *);
-}
-
-/* Return the symbol table. */
-
-static long
-srec_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- unsigned int symcount = bfd_get_symcount (abfd);
- asymbol *csymbols;
- unsigned int i;
-
- csymbols = abfd->tdata.srec_data->csymbols;
- if (csymbols == NULL)
- {
- asymbol *c;
- struct srec_symbol *s;
-
- csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
- if (csymbols == NULL && symcount != 0)
- return false;
- abfd->tdata.srec_data->csymbols = csymbols;
-
- for (s = abfd->tdata.srec_data->symbols, c = csymbols;
- s != NULL;
- s = s->next, ++c)
- {
- c->the_bfd = abfd;
- c->name = s->name;
- c->value = s->val;
- c->flags = BSF_GLOBAL;
- c->section = bfd_abs_section_ptr;
- c->udata.p = NULL;
- }
- }
-
- for (i = 0; i < symcount; i++)
- *alocation++ = csymbols++;
- *alocation = NULL;
-
- return symcount;
-}
-
-/*ARGSUSED*/
-void
-srec_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-/*ARGSUSED*/
-void
-srec_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);
-
- }
-}
-
-#define srec_close_and_cleanup _bfd_generic_close_and_cleanup
-#define srec_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define srec_new_section_hook _bfd_generic_new_section_hook
-
-#define srec_bfd_is_local_label bfd_generic_is_local_label
-#define srec_get_lineno _bfd_nosymbols_get_lineno
-#define srec_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define srec_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define srec_read_minisymbols _bfd_generic_read_minisymbols
-#define srec_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define srec_get_reloc_upper_bound \
- ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
-#define srec_canonicalize_reloc \
- ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
-#define srec_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-#define srec_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-#define srec_set_arch_mach bfd_default_set_arch_mach
-
-#define srec_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define srec_bfd_relax_section bfd_generic_relax_section
-#define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define srec_bfd_final_link _bfd_generic_final_link
-#define srec_bfd_link_split_section _bfd_generic_link_split_section
-
-const bfd_target srec_vec =
-{
- "srec", /* name */
- bfd_target_srec_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,
- srec_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- srec_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- srec_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (srec),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (srec),
- BFD_JUMP_TABLE_RELOCS (srec),
- BFD_JUMP_TABLE_WRITE (srec),
- BFD_JUMP_TABLE_LINK (srec),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
-
-
-
-const bfd_target symbolsrec_vec =
-{
- "symbolsrec", /* name */
- bfd_target_srec_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,
- symbolsrec_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- srec_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- symbolsrec_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (srec),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (srec),
- BFD_JUMP_TABLE_RELOCS (srec),
- BFD_JUMP_TABLE_WRITE (srec),
- BFD_JUMP_TABLE_LINK (srec),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/stab-syms.c b/contrib/gdb/bfd/stab-syms.c
deleted file mode 100644
index f4fe6c8ba3cf..000000000000
--- a/contrib/gdb/bfd/stab-syms.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Table of stab names for the BFD library.
- 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. */
-
-#include "bfd.h"
-
-#define ARCH_SIZE 32 /* Value doesn't matter. */
-#include "libaout.h"
-#include "aout/aout64.h"
-
-/* Ignore duplicate stab codes; just return the string for the first
- one. */
-#define __define_stab(NAME, CODE, STRING) __define_name(CODE, STRING)
-#define __define_stab_duplicate(NAME, CODE, STRING)
-
-/* These are not really stab symbols, but it is
- convenient to have them here for the sake of nm.
- For completeness, we could also add N_TEXT etc, but those
- are never needed, since nm treats those specially. */
-#define EXTRA_SYMBOLS \
- __define_name (N_SETA, "SETA")/* Absolute set element symbol */ \
- __define_name (N_SETT, "SETT")/* Text set element symbol */ \
- __define_name (N_SETD, "SETD")/* Data set element symbol */ \
- __define_name (N_SETB, "SETB")/* Bss set element symbol */ \
- __define_name (N_SETV, "SETV")/* Pointer to set vector in data area. */ \
- __define_name (N_INDR, "INDR") \
- __define_name (N_WARNING, "WARNING")
-
-const char *
-bfd_get_stab_name (code)
- int code;
-{
- switch (code)
- {
-#define __define_name(val, str) case val: return str;
-#include "aout/stab.def"
- EXTRA_SYMBOLS
- }
-
- return (const char *) 0;
-}
diff --git a/contrib/gdb/bfd/sunos.c b/contrib/gdb/bfd/sunos.c
deleted file mode 100644
index 77bf319bcd60..000000000000
--- 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/syms.c b/contrib/gdb/bfd/syms.c
deleted file mode 100644
index e3007e4c5f01..000000000000
--- a/contrib/gdb/bfd/syms.c
+++ /dev/null
@@ -1,1084 +0,0 @@
-/* Generic symbol-table support for the BFD library.
- 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. */
-
-/*
-SECTION
- Symbols
-
- BFD tries to maintain as much symbol information as it can when
- it moves information from file to file. BFD passes information
- to applications though the <<asymbol>> structure. When the
- application requests the symbol table, BFD reads the table in
- the native form and translates parts of it into the internal
- format. To maintain more than the information passed to
- applications, some targets keep some information ``behind the
- scenes'' in a structure only the particular back end knows
- about. For example, the coff back end keeps the original
- symbol table structure as well as the canonical structure when
- a BFD is read in. On output, the coff back end can reconstruct
- the output symbol table so that no information is lost, even
- information unique to coff which BFD doesn't know or
- understand. If a coff symbol table were read, but were written
- through an a.out back end, all the coff specific information
- would be lost. The symbol table of a BFD
- is not necessarily read in until a canonicalize request is
- made. Then the BFD back end fills in a table provided by the
- application with pointers to the canonical information. To
- output symbols, the application provides BFD with a table of
- pointers to pointers to <<asymbol>>s. This allows applications
- like the linker to output a symbol as it was read, since the ``behind
- the scenes'' information will be still available.
-@menu
-@* Reading Symbols::
-@* Writing Symbols::
-@* Mini Symbols::
-@* typedef asymbol::
-@* symbol handling functions::
-@end menu
-
-INODE
-Reading Symbols, Writing Symbols, Symbols, Symbols
-SUBSECTION
- Reading symbols
-
- There are two stages to reading a symbol table from a BFD:
- allocating storage, and the actual reading process. This is an
- excerpt from an application which reads the symbol table:
-
-| long storage_needed;
-| asymbol **symbol_table;
-| long number_of_symbols;
-| long i;
-|
-| storage_needed = bfd_get_symtab_upper_bound (abfd);
-|
-| if (storage_needed < 0)
-| FAIL
-|
-| if (storage_needed == 0) {
-| return ;
-| }
-| symbol_table = (asymbol **) xmalloc (storage_needed);
-| ...
-| number_of_symbols =
-| bfd_canonicalize_symtab (abfd, symbol_table);
-|
-| if (number_of_symbols < 0)
-| FAIL
-|
-| for (i = 0; i < number_of_symbols; i++) {
-| process_symbol (symbol_table[i]);
-| }
-
- All storage for the symbols themselves is in an obstack
- connected to the BFD; it is freed when the BFD is closed.
-
-
-INODE
-Writing Symbols, Mini Symbols, Reading Symbols, Symbols
-SUBSECTION
- Writing symbols
-
- Writing of a symbol table is automatic when a BFD open for
- writing is closed. The application attaches a vector of
- pointers to pointers to symbols to the BFD being written, and
- fills in the symbol count. The close and cleanup code reads
- through the table provided and performs all the necessary
- operations. The BFD output code must always be provided with an
- ``owned'' symbol: one which has come from another BFD, or one
- which has been created using <<bfd_make_empty_symbol>>. Here is an
- example showing the creation of a symbol table with only one element:
-
-| #include "bfd.h"
-| main()
-| {
-| bfd *abfd;
-| asymbol *ptrs[2];
-| asymbol *new;
-|
-| abfd = bfd_openw("foo","a.out-sunos-big");
-| bfd_set_format(abfd, bfd_object);
-| new = bfd_make_empty_symbol(abfd);
-| new->name = "dummy_symbol";
-| new->section = bfd_make_section_old_way(abfd, ".text");
-| new->flags = BSF_GLOBAL;
-| new->value = 0x12345;
-|
-| ptrs[0] = new;
-| ptrs[1] = (asymbol *)0;
-|
-| bfd_set_symtab(abfd, ptrs, 1);
-| bfd_close(abfd);
-| }
-|
-| ./makesym
-| nm foo
-| 00012345 A dummy_symbol
-
- Many formats cannot represent arbitary symbol information; for
- instance, the <<a.out>> object format does not allow an
- arbitary number of sections. A symbol pointing to a section
- which is not one of <<.text>>, <<.data>> or <<.bss>> cannot
- be described.
-
-INODE
-Mini Symbols, typedef asymbol, Writing Symbols, Symbols
-SUBSECTION
- Mini Symbols
-
- Mini symbols provide read-only access to the symbol table.
- They use less memory space, but require more time to access.
- They can be useful for tools like nm or objdump, which may
- have to handle symbol tables of extremely large executables.
-
- The <<bfd_read_minisymbols>> function will read the symbols
- into memory in an internal form. It will return a <<void *>>
- pointer to a block of memory, a symbol count, and the size of
- each symbol. The pointer is allocated using <<malloc>>, and
- should be freed by the caller when it is no longer needed.
-
- The function <<bfd_minisymbol_to_symbol>> will take a pointer
- to a minisymbol, and a pointer to a structure returned by
- <<bfd_make_empty_symbol>>, and return a <<asymbol>> structure.
- The return value may or may not be the same as the value from
- <<bfd_make_empty_symbol>> which was passed in.
-
-*/
-
-
-
-/*
-DOCDD
-INODE
-typedef asymbol, symbol handling functions, Mini Symbols, Symbols
-
-*/
-/*
-SUBSECTION
- typedef asymbol
-
- An <<asymbol>> has the form:
-
-*/
-
-/*
-CODE_FRAGMENT
-
-.
-.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;
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "aout/stab_gnu.h"
-
-/*
-DOCDD
-INODE
-symbol handling functions, , typedef asymbol, Symbols
-SUBSECTION
- Symbol handling functions
-*/
-
-/*
-FUNCTION
- bfd_get_symtab_upper_bound
-
-DESCRIPTION
- Return the number of bytes required to store a vector of pointers
- to <<asymbols>> for all the symbols in the BFD @var{abfd},
- including a terminal NULL pointer. If there are no symbols in
- the BFD, then return 0. If an error occurs, return -1.
-
-.#define bfd_get_symtab_upper_bound(abfd) \
-. BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
-
-*/
-
-/*
-FUNCTION
- bfd_is_local_label
-
-SYNOPSIS
- boolean bfd_is_local_label(bfd *abfd, asymbol *sym);
-
-DESCRIPTION
- Return true if the given symbol @var{sym} in the BFD @var{abfd} is
- a compiler generated local label, else return false.
-.#define bfd_is_local_label(abfd, sym) \
-. BFD_SEND (abfd, _bfd_is_local_label,(abfd, sym))
-*/
-
-/*
-FUNCTION
- bfd_canonicalize_symtab
-
-DESCRIPTION
- Read the symbols from the BFD @var{abfd}, and fills in
- the vector @var{location} with pointers to the symbols and
- a trailing NULL.
- Return the actual number of symbol pointers, not
- including the NULL.
-
-
-.#define bfd_canonicalize_symtab(abfd, location) \
-. BFD_SEND (abfd, _bfd_canonicalize_symtab,\
-. (abfd, location))
-
-*/
-
-
-/*
-FUNCTION
- bfd_set_symtab
-
-SYNOPSIS
- boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);
-
-DESCRIPTION
- Arrange that when the output BFD @var{abfd} is closed,
- the table @var{location} of @var{count} pointers to symbols
- will be written.
-*/
-
-boolean
-bfd_set_symtab (abfd, location, symcount)
- bfd *abfd;
- asymbol **location;
- unsigned int symcount;
-{
- if ((abfd->format != bfd_object) || (bfd_read_p (abfd)))
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- bfd_get_outsymbols (abfd) = location;
- bfd_get_symcount (abfd) = symcount;
- return true;
-}
-
-/*
-FUNCTION
- bfd_print_symbol_vandf
-
-SYNOPSIS
- void bfd_print_symbol_vandf(PTR file, asymbol *symbol);
-
-DESCRIPTION
- Print the value and flags of the @var{symbol} supplied to the
- stream @var{file}.
-*/
-void
-bfd_print_symbol_vandf (arg, symbol)
- PTR arg;
- asymbol *symbol;
-{
- FILE *file = (FILE *) arg;
- flagword type = symbol->flags;
- if (symbol->section != (asection *) NULL)
- {
- fprintf_vma (file, symbol->value + symbol->section->vma);
- }
- else
- {
- fprintf_vma (file, symbol->value);
- }
-
- /* This presumes that a symbol can not be both BSF_DEBUGGING and
- BSF_DYNAMIC, nor more than one of BSF_FUNCTION, BSF_FILE, and
- BSF_OBJECT. */
- fprintf (file, " %c%c%c%c%c%c%c",
- ((type & BSF_LOCAL)
- ? (type & BSF_GLOBAL) ? '!' : 'l'
- : (type & BSF_GLOBAL) ? 'g' : ' '),
- (type & BSF_WEAK) ? 'w' : ' ',
- (type & BSF_CONSTRUCTOR) ? 'C' : ' ',
- (type & BSF_WARNING) ? 'W' : ' ',
- (type & BSF_INDIRECT) ? 'I' : ' ',
- (type & BSF_DEBUGGING) ? 'd' : (type & BSF_DYNAMIC) ? 'D' : ' ',
- ((type & BSF_FUNCTION)
- ? 'F'
- : ((type & BSF_FILE)
- ? 'f'
- : ((type & BSF_OBJECT) ? 'O' : ' '))));
-}
-
-
-/*
-FUNCTION
- bfd_make_empty_symbol
-
-DESCRIPTION
- Create a new <<asymbol>> structure for the BFD @var{abfd}
- and return a pointer to it.
-
- This routine is necessary because each back end has private
- information surrounding the <<asymbol>>. Building your own
- <<asymbol>> and pointing to it will not create the private
- information, and will cause problems later on.
-
-.#define bfd_make_empty_symbol(abfd) \
-. BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
-*/
-
-/*
-FUNCTION
- bfd_make_debug_symbol
-
-DESCRIPTION
- Create a new <<asymbol>> structure for the BFD @var{abfd},
- to be used as a debugging symbol. Further details of its use have
- yet to be worked out.
-
-.#define bfd_make_debug_symbol(abfd,ptr,size) \
-. BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
-*/
-
-struct section_to_type
-{
- CONST char *section;
- char type;
-};
-
-/* Map section names to POSIX/BSD single-character symbol types.
- This table is probably incomplete. It is sorted for convenience of
- adding entries. Since it is so short, a linear search is used. */
-static CONST struct section_to_type stt[] =
-{
- {"*DEBUG*", 'N'},
- {".bss", 'b'},
- {"zerovars", 'b'}, /* MRI .bss */
- {".data", 'd'},
- {"vars", 'd'}, /* MRI .data */
- {".rdata", 'r'}, /* Read only data. */
- {".rodata", 'r'}, /* Read only data. */
- {".sbss", 's'}, /* Small BSS (uninitialized data). */
- {".scommon", 'c'}, /* Small common. */
- {".sdata", 'g'}, /* Small initialized data. */
- {".text", 't'},
- {"code", 't'}, /* MRI .text */
- {0, 0}
-};
-
-/* Return the single-character symbol type corresponding to
- section S, or '?' for an unknown COFF section.
-
- Check for any leading string which matches, so .text5 returns
- 't' as well as .text */
-
-static char
-coff_section_type (s)
- char *s;
-{
- CONST struct section_to_type *t;
-
- for (t = &stt[0]; t->section; t++)
- if (!strncmp (s, t->section, strlen (t->section)))
- return t->type;
-
- return '?';
-}
-
-#ifndef islower
-#define islower(c) ((c) >= 'a' && (c) <= 'z')
-#endif
-#ifndef toupper
-#define toupper(c) (islower(c) ? ((c) & ~0x20) : (c))
-#endif
-
-/*
-FUNCTION
- bfd_decode_symclass
-
-DESCRIPTION
- Return a character corresponding to the symbol
- class of @var{symbol}, or '?' for an unknown class.
-
-SYNOPSIS
- int bfd_decode_symclass(asymbol *symbol);
-*/
-int
-bfd_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_WEAK)
- return 'W';
- if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
- return '?';
-
- if (bfd_is_abs_section (symbol->section))
- c = 'a';
- else if (symbol->section)
- c = coff_section_type (symbol->section->name);
- else
- return '?';
- if (symbol->flags & BSF_GLOBAL)
- c = toupper (c);
- return c;
-
- /* We don't have to handle these cases just yet, but we will soon:
- N_SETV: 'v';
- N_SETA: 'l';
- N_SETT: 'x';
- N_SETD: 'z';
- N_SETB: 's';
- N_INDR: 'i';
- */
-}
-
-/*
-FUNCTION
- bfd_symbol_info
-
-DESCRIPTION
- Fill in the basic info about symbol that nm needs.
- Additional info may be added by the back-ends after
- calling this function.
-
-SYNOPSIS
- void bfd_symbol_info(asymbol *symbol, symbol_info *ret);
-*/
-
-void
-bfd_symbol_info (symbol, ret)
- asymbol *symbol;
- symbol_info *ret;
-{
- ret->type = bfd_decode_symclass (symbol);
- if (ret->type != 'U')
- ret->value = symbol->value + symbol->section->vma;
- else
- ret->value = 0;
- ret->name = symbol->name;
-}
-
-void
-bfd_symbol_is_absolute ()
-{
- abort ();
-}
-
-/*
-FUNCTION
- bfd_copy_private_symbol_data
-
-SYNOPSIS
- boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
-
-DESCRIPTION
- Copy private symbol information from @var{isym} in the BFD
- @var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}.
- Return <<true>> on success, <<false>> on error. Possible error
- returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{osec}.
-
-.#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
-. BFD_SEND (ibfd, _bfd_copy_private_symbol_data, \
-. (ibfd, isymbol, obfd, osymbol))
-
-*/
-
-/* The generic version of the function which returns mini symbols.
- This is used when the backend does not provide a more efficient
- version. It just uses BFD asymbol structures as mini symbols. */
-
-long
-_bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep)
- bfd *abfd;
- boolean dynamic;
- PTR *minisymsp;
- unsigned int *sizep;
-{
- long storage;
- asymbol **syms = NULL;
- long symcount;
-
- if (dynamic)
- storage = bfd_get_dynamic_symtab_upper_bound (abfd);
- else
- storage = bfd_get_symtab_upper_bound (abfd);
- if (storage < 0)
- goto error_return;
-
- syms = (asymbol **) bfd_malloc ((size_t) storage);
- if (syms == NULL)
- goto error_return;
-
- if (dynamic)
- symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
- else
- symcount = bfd_canonicalize_symtab (abfd, syms);
- if (symcount < 0)
- goto error_return;
-
- *minisymsp = (PTR) syms;
- *sizep = sizeof (asymbol *);
- return symcount;
-
- error_return:
- if (syms != NULL)
- free (syms);
- return -1;
-}
-
-/* The generic version of the function which converts a minisymbol to
- an asymbol. We don't worry about the sym argument we are passed;
- we just return the asymbol the minisymbol points to. */
-
-/*ARGSUSED*/
-asymbol *
-_bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
- bfd *abfd;
- boolean dynamic;
- const PTR minisym;
- asymbol *sym;
-{
- return *(asymbol **) minisym;
-}
-
-/* Look through stabs debugging information in .stab and .stabstr
- sections to find the source file and line closest to a desired
- location. This is used by COFF and ELF targets. It sets *pfound
- to true if it finds some information. The *pinfo field is used to
- pass cached information in and out of this routine; this first time
- the routine is called for a BFD, *pinfo should be NULL. The value
- placed in *pinfo should be saved with the BFD, and passed back each
- time this function is called. */
-
-/* A pointer to this structure is stored in *pinfo. */
-
-struct stab_find_info
-{
- /* The .stab section. */
- asection *stabsec;
- /* The .stabstr section. */
- asection *strsec;
- /* The contents of the .stab section. */
- bfd_byte *stabs;
- /* The contents of the .stabstr section. */
- bfd_byte *strs;
- /* An malloc buffer to hold the file name. */
- char *filename;
- /* Cached values to restart quickly. */
- bfd_vma cached_offset;
- bfd_byte *cached_stab;
- bfd_byte *cached_str;
- bfd_size_type cached_stroff;
-};
-
-boolean
-_bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
- pfilename, pfnname, pline, pinfo)
- bfd *abfd;
- asymbol **symbols;
- asection *section;
- bfd_vma offset;
- boolean *pfound;
- const char **pfilename;
- const char **pfnname;
- unsigned int *pline;
- PTR *pinfo;
-{
- struct stab_find_info *info;
- bfd_size_type stabsize, strsize;
- bfd_byte *stab, *stabend, *str;
- bfd_size_type stroff;
- bfd_vma fnaddr;
- char *directory_name, *main_file_name, *current_file_name, *line_file_name;
- char *fnname;
- bfd_vma low_func_vma, low_line_vma;
-
- *pfound = false;
- *pfilename = bfd_get_filename (abfd);
- *pfnname = NULL;
- *pline = 0;
-
- info = (struct stab_find_info *) *pinfo;
- if (info != NULL)
- {
- if (info->stabsec == NULL || info->strsec == NULL)
- {
- /* No stabs debugging information. */
- return true;
- }
-
- stabsize = info->stabsec->_raw_size;
- strsize = info->strsec->_raw_size;
- }
- else
- {
- long reloc_size, reloc_count;
- arelent **reloc_vector;
-
- info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info);
- if (info == NULL)
- return false;
-
- /* FIXME: When using the linker --split-by-file or
- --split-by-reloc options, it is possible for the .stab and
- .stabstr sections to be split. We should handle that. */
-
- info->stabsec = bfd_get_section_by_name (abfd, ".stab");
- info->strsec = bfd_get_section_by_name (abfd, ".stabstr");
-
- if (info->stabsec == NULL || info->strsec == NULL)
- {
- /* No stabs debugging information. Set *pinfo so that we
- can return quickly in the info != NULL case above. */
- *pinfo = (PTR) info;
- return true;
- }
-
- stabsize = info->stabsec->_raw_size;
- strsize = info->strsec->_raw_size;
-
- info->stabs = (bfd_byte *) bfd_alloc (abfd, stabsize);
- info->strs = (bfd_byte *) bfd_alloc (abfd, strsize);
- if (info->stabs == NULL || info->strs == NULL)
- return false;
-
- if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,
- stabsize)
- || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,
- strsize))
- return false;
-
- /* If this is a relocateable object file, we have to relocate
- the entries in .stab. This should always be simple 32 bit
- relocations against symbols defined in this object file, so
- this should be no big deal. */
- reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
- if (reloc_size < 0)
- return false;
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
- if (reloc_vector == NULL && reloc_size != 0)
- return false;
- reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
- symbols);
- if (reloc_count < 0)
- {
- if (reloc_vector != NULL)
- free (reloc_vector);
- return false;
- }
- if (reloc_count > 0)
- {
- arelent **pr;
-
- for (pr = reloc_vector; *pr != NULL; pr++)
- {
- arelent *r;
- unsigned long val;
- asymbol *sym;
-
- r = *pr;
- if (r->howto->rightshift != 0
- || r->howto->size != 2
- || r->howto->bitsize != 32
- || r->howto->pc_relative
- || r->howto->bitpos != 0
- || r->howto->dst_mask != 0xffffffff)
- {
- (*_bfd_error_handler)
- ("Unsupported .stab relocation");
- bfd_set_error (bfd_error_invalid_operation);
- if (reloc_vector != NULL)
- free (reloc_vector);
- return false;
- }
-
- val = bfd_get_32 (abfd, info->stabs + r->address);
- val &= r->howto->src_mask;
- sym = *r->sym_ptr_ptr;
- val += sym->value + sym->section->vma + r->addend;
- bfd_put_32 (abfd, val, info->stabs + r->address);
- }
- }
-
- if (reloc_vector != NULL)
- free (reloc_vector);
-
- *pinfo = (PTR) info;
- }
-
- /* We are passed a section relative offset. The offsets in the
- stabs information are absolute. */
- offset += bfd_get_section_vma (abfd, section);
-
- /* Stabs entries use a 12 byte format:
- 4 byte string table index
- 1 byte stab type
- 1 byte stab other field
- 2 byte stab desc field
- 4 byte stab value
- FIXME: This will have to change for a 64 bit object format.
-
- The stabs symbols are divided into compilation units. For the
- first entry in each unit, the type of 0, the value is the length
- of the string table for this unit, and the desc field is the
- number of stabs symbols for this unit. */
-
-#define STRDXOFF (0)
-#define TYPEOFF (4)
-#define OTHEROFF (5)
-#define DESCOFF (6)
-#define VALOFF (8)
-#define STABSIZE (12)
-
- /* It would be nice if we could skip ahead to the stabs symbols for
- the next compilation unit to quickly scan through the compilation
- units. Unfortunately, since each line number gets a separate
- stabs entry, it is entirely plausible that a large source file
- will overflow the 16 bit count of stabs entries. */
- fnaddr = 0;
- directory_name = NULL;
- main_file_name = NULL;
- current_file_name = NULL;
- line_file_name = NULL;
- fnname = NULL;
- low_func_vma = 0;
- low_line_vma = 0;
-
- stabend = info->stabs + stabsize;
-
- if (info->cached_stab == NULL || offset < info->cached_offset)
- {
- stab = info->stabs;
- str = info->strs;
- stroff = 0;
- }
- else
- {
- stab = info->cached_stab;
- str = info->cached_str;
- stroff = info->cached_stroff;
- }
-
- info->cached_offset = offset;
-
- for (; stab < stabend; stab += STABSIZE)
- {
- boolean done;
- bfd_vma val;
- char *name;
-
- done = false;
-
- switch (stab[TYPEOFF])
- {
- case 0:
- /* This is the first entry in a compilation unit. */
- if ((bfd_size_type) ((info->strs + strsize) - str) < stroff)
- {
- done = true;
- break;
- }
- str += stroff;
- stroff = bfd_get_32 (abfd, stab + VALOFF);
- break;
-
- case N_SO:
- /* The main file name. */
-
- val = bfd_get_32 (abfd, stab + VALOFF);
- if (val > offset)
- {
- done = true;
- break;
- }
-
- name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
-
- /* An empty string indicates the end of the compilation
- unit. */
- if (*name == '\0')
- {
- /* If there are functions in different sections, they
- may have addresses larger than val, but we don't want
- to forget the file name. When there are functions in
- different cases, there is supposed to be an N_FUN at
- the end of the function indicating where it ends. */
- if (low_func_vma < val || fnname == NULL)
- main_file_name = NULL;
- break;
- }
-
- /* We know that we have to get to at least this point in the
- stabs entries for this offset. */
- info->cached_stab = stab;
- info->cached_str = str;
- info->cached_stroff = stroff;
-
- current_file_name = name;
-
- /* Look ahead to the next symbol. Two consecutive N_SO
- symbols are a directory and a file name. */
- if (stab + STABSIZE >= stabend
- || *(stab + STABSIZE + TYPEOFF) != N_SO)
- directory_name = NULL;
- else
- {
- stab += STABSIZE;
- directory_name = current_file_name;
- current_file_name = ((char *) str
- + bfd_get_32 (abfd, stab + STRDXOFF));
- }
-
- main_file_name = current_file_name;
-
- break;
-
- case N_SOL:
- /* The name of an include file. */
- current_file_name = ((char *) str
- + bfd_get_32 (abfd, stab + STRDXOFF));
- break;
-
- case N_SLINE:
- case N_DSLINE:
- case N_BSLINE:
- /* A line number. The value is relative to the start of the
- current function. */
- val = fnaddr + bfd_get_32 (abfd, stab + VALOFF);
- if (val >= low_line_vma && val <= offset)
- {
- *pline = bfd_get_16 (abfd, stab + DESCOFF);
- low_line_vma = val;
- line_file_name = current_file_name;
- }
- break;
-
- case N_FUN:
- /* A function name. */
- val = bfd_get_32 (abfd, stab + VALOFF);
- name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
-
- /* An empty string here indicates the end of a function, and
- the value is relative to fnaddr. */
-
- if (*name == '\0')
- {
- val += fnaddr;
- if (val >= low_func_vma && val < offset)
- fnname = NULL;
- }
- else
- {
- if (val >= low_func_vma && val <= offset)
- {
- fnname = name;
- low_func_vma = val;
- }
-
- fnaddr = val;
- }
-
- break;
- }
-
- if (done)
- break;
- }
-
- if (main_file_name == NULL)
- {
- /* No information found. */
- return true;
- }
-
- *pfound = true;
-
- if (*pline != 0)
- main_file_name = line_file_name;
-
- if (main_file_name != NULL)
- {
- if (main_file_name[0] == '/' || directory_name == NULL)
- *pfilename = main_file_name;
- else
- {
- size_t dirlen;
-
- dirlen = strlen (directory_name);
- if (info->filename == NULL
- || strncmp (info->filename, directory_name, dirlen) != 0
- || strcmp (info->filename + dirlen, main_file_name) != 0)
- {
- if (info->filename != NULL)
- free (info->filename);
- info->filename = (char *) bfd_malloc (dirlen +
- strlen (main_file_name)
- + 1);
- if (info->filename == NULL)
- return false;
- strcpy (info->filename, directory_name);
- strcpy (info->filename + dirlen, main_file_name);
- }
-
- *pfilename = info->filename;
- }
- }
-
- if (fnname != NULL)
- {
- char *s;
-
- /* This will typically be something like main:F(0,1), so we want
- to clobber the colon. It's OK to change the name, since the
- string is in our own local storage anyhow. */
-
- s = strchr (fnname, ':');
- if (s != NULL)
- *s = '\0';
-
- *pfnname = fnname;
- }
-
- return true;
-}
diff --git a/contrib/gdb/bfd/sysdep.h b/contrib/gdb/bfd/sysdep.h
deleted file mode 100644
index dd8146a961a8..000000000000
--- a/contrib/gdb/bfd/sysdep.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* sysdep.h -- handle host dependencies for the BFD library
- 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. */
-
-#ifndef BFD_SYSDEP_H
-#define BFD_SYSDEP_H
-
-#include "ansidecl.h"
-
-#include "config.h"
-
-#ifdef HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#else
-extern char *strchr ();
-extern char *strrchr ();
-extern char *strstr ();
-#endif
-#endif
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#if TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef USE_BINARY_FOPEN
-#include "fopen-bin.h"
-#else
-#include "fopen-same.h"
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-#ifndef O_WRONLY
-#define O_WRONLY 1
-#endif
-#ifndef O_RDWR
-#define O_RDWR 2
-#endif
-#ifndef O_ACCMODE
-#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
-
-#ifdef NEED_DECLARATION_MALLOC
-extern PTR malloc ();
-#endif
-
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
-
-#endif /* ! defined (BFD_SYSDEP_H) */
diff --git a/contrib/gdb/bfd/targets.c b/contrib/gdb/bfd/targets.c
deleted file mode 100644
index e1e6468a18ee..000000000000
--- a/contrib/gdb/bfd/targets.c
+++ /dev/null
@@ -1,886 +0,0 @@
-/* Generic target-file-type support for the BFD library.
- 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"
-
-/*
-SECTION
- Targets
-
-DESCRIPTION
- Each port of BFD to a different machine requries the creation
- of a target back end. All the back end provides to the root
- part of BFD is a structure containing pointers to functions
- which perform certain low level operations on files. BFD
- translates the applications's requests through a pointer into
- calls to the back end routines.
-
- When a file is opened with <<bfd_openr>>, its format and
- target are unknown. BFD uses various mechanisms to determine
- how to interpret the file. The operations performed are:
-
- o Create a BFD by calling the internal routine
- <<_bfd_new_bfd>>, then call <<bfd_find_target>> with the
- target string supplied to <<bfd_openr>> and the new BFD pointer.
-
- o If a null target string was provided to <<bfd_find_target>>,
- look up the environment variable <<GNUTARGET>> and use
- that as the target string.
-
- o If the target string is still <<NULL>>, or the target string is
- <<default>>, then use the first item in the target vector
- as the target type, and set <<target_defaulted>> in the BFD to
- cause <<bfd_check_format>> to loop through all the targets.
- @xref{bfd_target}. @xref{Formats}.
-
- o Otherwise, inspect the elements in the target vector
- one by one, until a match on target name is found. When found,
- use it.
-
- o Otherwise return the error <<bfd_error_invalid_target>> to
- <<bfd_openr>>.
-
- o <<bfd_openr>> attempts to open the file using
- <<bfd_open_file>>, and returns the BFD.
-
- Once the BFD has been opened and the target selected, the file
- format may be determined. This is done by calling
- <<bfd_check_format>> on the BFD with a suggested format.
- If <<target_defaulted>> has been set, each possible target
- type is tried to see if it recognizes the specified format.
- <<bfd_check_format>> returns <<true>> when the caller guesses right.
-@menu
-@* bfd_target::
-@end menu
-*/
-
-
-/*
-
-INODE
- bfd_target, , Targets, Targets
-DOCDD
-SUBSECTION
- bfd_target
-
-DESCRIPTION
- This structure contains everything that BFD knows about a
- target. It includes things like its byte order, name, and which
- routines to call to do various operations.
-
- Every BFD points to a target structure with its <<xvec>>
- member.
-
- The macros below are used to dispatch to functions through the
- <<bfd_target>> vector. They are used in a number of macros further
- down in @file{bfd.h}, and are also used when calling various
- routines by hand inside the BFD implementation. The @var{arglist}
- argument must be parenthesized; it contains all the arguments
- to the called function.
-
- They make the documentation (more) unpleasant to read, so if
- someone wants to fix this and not break the above, please do.
-
-.#define BFD_SEND(bfd, message, arglist) \
-. ((*((bfd)->xvec->message)) arglist)
-.
-.#ifdef DEBUG_BFD_SEND
-.#undef BFD_SEND
-.#define BFD_SEND(bfd, message, arglist) \
-. (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
-. ((*((bfd)->xvec->message)) arglist) : \
-. (bfd_assert (__FILE__,__LINE__), NULL))
-.#endif
-
- For operations which index on the BFD format:
-
-.#define BFD_SEND_FMT(bfd, message, arglist) \
-. (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
-.
-.#ifdef DEBUG_BFD_SEND
-.#undef BFD_SEND_FMT
-.#define BFD_SEND_FMT(bfd, message, arglist) \
-. (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
-. (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \
-. (bfd_assert (__FILE__,__LINE__), NULL))
-.#endif
-
- This is the structure which defines the type of BFD this is. The
- <<xvec>> member of the struct <<bfd>> itself points here. Each
- module that implements access to a different target under BFD,
- defines one of these.
-
-
- FIXME, these names should be rationalised with the names of
- the entry points which call them. Too bad we can't have one
- macro to define them both!
-
-.enum bfd_flavour {
-. bfd_target_unknown_flavour,
-. bfd_target_aout_flavour,
-. bfd_target_coff_flavour,
-. bfd_target_ecoff_flavour,
-. bfd_target_elf_flavour,
-. bfd_target_ieee_flavour,
-. bfd_target_nlm_flavour,
-. bfd_target_oasys_flavour,
-. bfd_target_tekhex_flavour,
-. bfd_target_srec_flavour,
-. bfd_target_ihex_flavour,
-. bfd_target_som_flavour,
-. bfd_target_os9k_flavour,
-. bfd_target_versados_flavour,
-. bfd_target_msdos_flavour
-.};
-.
-.enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
-.
-.{* Forward declaration. *}
-.typedef struct bfd_link_info _bfd_link_info;
-.
-.typedef struct bfd_target
-.{
-
-Identifies the kind of target, e.g., SunOS4, Ultrix, etc.
-
-. char *name;
-
-The "flavour" of a back end is a general indication about the contents
-of a file.
-
-. enum bfd_flavour flavour;
-
-The order of bytes within the data area of a file.
-
-. enum bfd_endian byteorder;
-
-The order of bytes within the header parts of a file.
-
-. enum bfd_endian header_byteorder;
-
-A mask of all the flags which an executable may have set -
-from the set <<NO_FLAGS>>, <<HAS_RELOC>>, ...<<D_PAGED>>.
-
-. flagword object_flags;
-
-A mask of all the flags which a section may have set - from
-the set <<SEC_NO_FLAGS>>, <<SEC_ALLOC>>, ...<<SET_NEVER_LOAD>>.
-
-. flagword section_flags;
-
-The character normally found at the front of a symbol
-(if any), perhaps `_'.
-
-. char symbol_leading_char;
-
-The pad character for file names within an archive header.
-
-. char ar_pad_char;
-
-The maximum number of characters in an archive header.
-
-. unsigned short ar_max_namelen;
-
-Entries for byte swapping for data. These are different from the other
-entry points, since they don't take a BFD asthe first argument.
-Certain other handlers could do the same.
-
-. bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
-. void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
-. void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
-. void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
-
-Byte swapping for the headers
-
-. bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
-. void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
-. void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
-. void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
-
-Format dependent routines: these are vectors of entry points
-within the target vector structure, one for each format to check.
-
-Check the format of a file being read. Return a <<bfd_target *>> or zero.
-
-. const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
-
-Set the format of a file being written.
-
-. boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
-
-Write cached information into a file being written, at <<bfd_close>>.
-
-. boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
-
-The general target vector.
-
-.
-. {* Generic entry points. *}
-.#define BFD_JUMP_TABLE_GENERIC(NAME)\
-.CAT(NAME,_close_and_cleanup),\
-.CAT(NAME,_bfd_free_cached_info),\
-.CAT(NAME,_new_section_hook),\
-.CAT(NAME,_get_section_contents),\
-.CAT(NAME,_get_section_contents_in_window)
-.
-. {* Called when the BFD is being closed to do any necessary cleanup. *}
-. boolean (*_close_and_cleanup) PARAMS ((bfd *));
-. {* Ask the BFD to free all cached information. *}
-. boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
-. {* Called when a new section is created. *}
-. boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
-. {* Read the contents of a section. *}
-. boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
-. file_ptr, bfd_size_type));
-. boolean (*_bfd_get_section_contents_in_window)
-. PARAMS ((bfd *, sec_ptr, bfd_window *,
-. file_ptr, bfd_size_type));
-.
-. {* Entry points to copy private data. *}
-.#define BFD_JUMP_TABLE_COPY(NAME)\
-.CAT(NAME,_bfd_copy_private_bfd_data),\
-.CAT(NAME,_bfd_merge_private_bfd_data),\
-.CAT(NAME,_bfd_copy_private_section_data),\
-.CAT(NAME,_bfd_copy_private_symbol_data),\
-.CAT(NAME,_bfd_set_private_flags),\
-.CAT(NAME,_bfd_print_private_bfd_data)\
-. {* Called to copy BFD general private data from one object file
-. to another. *}
-. boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
-. {* Called to merge BFD general private data from one object file
-. to a common output file when linking. *}
-. boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
-. {* Called to copy BFD private section data from one object file
-. to another. *}
-. boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
-. bfd *, sec_ptr));
-. {* Called to copy BFD private symbol data from one symbol
-. to another. *}
-. boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
-. bfd *, asymbol *));
-. {* Called to set private backend flags *}
-. boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
-.
-. {* Called to print private BFD data *}
-. boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
-.
-. {* Core file entry points. *}
-.#define BFD_JUMP_TABLE_CORE(NAME)\
-.CAT(NAME,_core_file_failing_command),\
-.CAT(NAME,_core_file_failing_signal),\
-.CAT(NAME,_core_file_matches_executable_p)
-. char * (*_core_file_failing_command) PARAMS ((bfd *));
-. int (*_core_file_failing_signal) PARAMS ((bfd *));
-. boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
-.
-. {* Archive entry points. *}
-.#define BFD_JUMP_TABLE_ARCHIVE(NAME)\
-.CAT(NAME,_slurp_armap),\
-.CAT(NAME,_slurp_extended_name_table),\
-.CAT(NAME,_construct_extended_name_table),\
-.CAT(NAME,_truncate_arname),\
-.CAT(NAME,_write_armap),\
-.CAT(NAME,_read_ar_hdr),\
-.CAT(NAME,_openr_next_archived_file),\
-.CAT(NAME,_get_elt_at_index),\
-.CAT(NAME,_generic_stat_arch_elt),\
-.CAT(NAME,_update_armap_timestamp)
-. boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
-. boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
-. boolean (*_bfd_construct_extended_name_table)
-. PARAMS ((bfd *, char **, bfd_size_type *, const char **));
-. void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
-. boolean (*write_armap) PARAMS ((bfd *arch,
-. unsigned int elength,
-. struct orl *map,
-. unsigned int orl_count,
-. int stridx));
-. PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
-. bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
-.#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
-. bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex));
-. int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
-. boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *));
-.
-. {* Entry points used for symbols. *}
-.#define BFD_JUMP_TABLE_SYMBOLS(NAME)\
-.CAT(NAME,_get_symtab_upper_bound),\
-.CAT(NAME,_get_symtab),\
-.CAT(NAME,_make_empty_symbol),\
-.CAT(NAME,_print_symbol),\
-.CAT(NAME,_get_symbol_info),\
-.CAT(NAME,_bfd_is_local_label),\
-.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 **));
-.
-
-Data for use by back-end routines, which isn't generic enough to belong
-in this structure.
-
-. PTR backend_data;
-.} bfd_target;
-
-*/
-
-/* All known xvecs (even those that don't compile on all systems).
- Alphabetized for easy reference.
- They are listed a second time below, since
- we can't intermix extern's and initializers. */
-extern const bfd_target a29kcoff_big_vec;
-extern const bfd_target a_out_adobe_vec;
-extern const bfd_target aout_arm_big_vec;
-extern const bfd_target aout_arm_little_vec;
-extern const bfd_target aout_mips_big_vec;
-extern const bfd_target aout_mips_little_vec;
-extern const bfd_target aout0_big_vec;
-extern const bfd_target apollocoff_vec;
-extern const bfd_target armcoff_little_vec;
-extern const bfd_target armcoff_big_vec;
-extern const bfd_target armpe_little_vec;
-extern const bfd_target armpe_big_vec;
-extern const bfd_target armpei_little_vec;
-extern const bfd_target armpei_big_vec;
-extern const bfd_target b_out_vec_big_host;
-extern const bfd_target b_out_vec_little_host;
-extern const bfd_target bfd_elf32_big_generic_vec;
-extern const bfd_target bfd_elf32_bigmips_vec;
-extern const bfd_target bfd_elf32_hppa_vec;
-extern const bfd_target bfd_elf32_i386_vec;
-extern const bfd_target bfd_elf32_i860_vec;
-extern const bfd_target bfd_elf32_little_generic_vec;
-extern const bfd_target bfd_elf32_littlemips_vec;
-extern const bfd_target bfd_elf32_m68k_vec;
-extern const bfd_target bfd_elf32_m88k_vec;
-extern const bfd_target bfd_elf32_powerpc_vec;
-extern const bfd_target bfd_elf32_powerpcle_vec;
-extern const bfd_target bfd_elf32_sparc_vec;
-extern const bfd_target bfd_elf64_big_generic_vec;
-extern const bfd_target bfd_elf64_little_generic_vec;
-extern const bfd_target bfd_elf64_sparc_vec;
-extern const bfd_target demo_64_vec;
-extern const bfd_target ecoff_big_vec;
-extern const bfd_target ecoff_little_vec;
-extern const bfd_target ecoffalpha_little_vec;
-extern const bfd_target h8300coff_vec;
-extern const bfd_target h8500coff_vec;
-extern const bfd_target host_aout_vec;
-extern const bfd_target hp300bsd_vec;
-extern const bfd_target hp300hpux_vec;
-extern const bfd_target som_vec;
-extern const bfd_target i386aout_vec;
-extern const bfd_target i386bsd_vec;
-extern const bfd_target i386dynix_vec;
-extern const bfd_target i386freebsd_vec;
-extern const bfd_target i386os9k_vec;
-extern const bfd_target i386coff_vec;
-extern const bfd_target bfd_powerpc_pe_vec;
-extern const bfd_target bfd_powerpcle_pe_vec;
-extern const bfd_target bfd_powerpc_pei_vec;
-extern const bfd_target bfd_powerpcle_pei_vec;
-extern const bfd_target i386pe_vec;
-extern const bfd_target i386pei_vec;
-extern const bfd_target go32coff_vec;
-extern const bfd_target i386linux_vec;
-extern const bfd_target i386lynx_aout_vec;
-extern const bfd_target i386lynx_coff_vec;
-extern const bfd_target i386mach3_vec;
-extern const bfd_target i386msdos_vec;
-extern const bfd_target i386netbsd_vec;
-extern const bfd_target i860coff_vec;
-extern const bfd_target icoff_big_vec;
-extern const bfd_target icoff_little_vec;
-extern const bfd_target ieee_vec;
-extern const bfd_target m68kaux_coff_vec;
-extern const bfd_target m68kcoff_vec;
-extern const bfd_target m68kcoffun_vec;
-extern const bfd_target m68klinux_vec;
-extern const bfd_target m68klynx_aout_vec;
-extern const bfd_target m68klynx_coff_vec;
-extern const bfd_target m68knetbsd_vec;
-extern const bfd_target m68k4knetbsd_vec;
-extern const bfd_target m88kbcs_vec;
-extern const bfd_target m88kmach3_vec;
-extern const bfd_target newsos3_vec;
-extern const bfd_target nlm32_i386_vec;
-extern const bfd_target nlm32_sparc_vec;
-extern const bfd_target nlm32_alpha_vec;
-extern const bfd_target nlm32_powerpc_vec;
-extern const bfd_target pc532netbsd_vec;
-extern const bfd_target oasys_vec;
-extern const bfd_target pc532machaout_vec;
-extern const bfd_target riscix_vec;
-extern const bfd_target pmac_xcoff_vec;
-extern const bfd_target rs6000coff_vec;
-extern const bfd_target shcoff_vec;
-extern const bfd_target shlcoff_vec;
-extern const bfd_target sparclynx_aout_vec;
-extern const bfd_target sparclynx_coff_vec;
-extern const bfd_target sparcnetbsd_vec;
-extern const bfd_target sparccoff_vec;
-extern const bfd_target sunos_big_vec;
-extern const bfd_target tekhex_vec;
-extern const bfd_target versados_vec;
-extern const bfd_target we32kcoff_vec;
-extern const bfd_target w65_vec;
-extern const bfd_target z8kcoff_vec;
-
-/* srec is always included. */
-extern const bfd_target srec_vec;
-extern const bfd_target symbolsrec_vec;
-
-/* binary is always included. */
-extern const bfd_target binary_vec;
-
-/* ihex is always included. */
-extern const bfd_target ihex_vec;
-
-/* All of the xvecs for core files. */
-extern const bfd_target aix386_core_vec;
-extern const bfd_target cisco_core_vec;
-extern const bfd_target hpux_core_vec;
-extern const bfd_target hppabsd_core_vec;
-extern const bfd_target irix_core_vec;
-extern const bfd_target osf_core_vec;
-extern const bfd_target sco_core_vec;
-extern const bfd_target trad_core_vec;
-extern const bfd_target ptrace_core_vec;
-
-const bfd_target * const bfd_target_vector[] = {
-
-#ifdef SELECT_VECS
-
- SELECT_VECS,
-
-#else /* not SELECT_VECS */
-
-#ifdef DEFAULT_VECTOR
- &DEFAULT_VECTOR,
-#endif
- /* This list is alphabetized to make it easy to compare
- with other vector lists -- the decls above and
- the case statement in configure.in.
- Vectors that don't compile on all systems, or aren't finished,
- should have an entry here with #if 0 around it, to show that
- it wasn't omitted by mistake. */
- &a29kcoff_big_vec,
- &a_out_adobe_vec,
-#if 0 /* No one seems to use this. */
- &aout_mips_big_vec,
-#endif
- &aout_mips_little_vec,
- &b_out_vec_big_host,
- &b_out_vec_little_host,
-
- /* This, and other vectors, may not be used in any *.mt configuration.
- But that does not mean they are unnecessary. If configured with
- --enable-targets=all, objdump or gdb should be able to examine
- the file even if we don't recognize the machine type. */
- &bfd_elf32_big_generic_vec,
- &bfd_elf32_bigmips_vec,
- &bfd_elf32_hppa_vec,
- &bfd_elf32_i386_vec,
- &bfd_elf32_i860_vec,
- &bfd_elf32_little_generic_vec,
- &bfd_elf32_littlemips_vec,
- &bfd_elf32_m68k_vec,
- &bfd_elf32_m88k_vec,
- &bfd_elf32_sparc_vec,
- &bfd_elf32_powerpc_vec,
-#ifdef BFD64 /* No one seems to use this. */
- &bfd_elf64_big_generic_vec,
- &bfd_elf64_little_generic_vec,
-#endif
-#if 0
- &bfd_elf64_sparc_vec,
-#endif
- /* We don't include cisco_core_vec. Although it has a magic number,
- the magic number isn't at the beginning of the file, and thus
- might spuriously match other kinds of files. */
-#ifdef BFD64
- &demo_64_vec, /* Only compiled if host has long-long support */
-#endif
- &ecoff_big_vec,
- &ecoff_little_vec,
-#if 0
- &ecoffalpha_little_vec,
-#endif
- &h8300coff_vec,
- &h8500coff_vec,
-#if 0
- /* Since a.out files lack decent magic numbers, no way to recognize
- which kind of a.out file it is. */
- &host_aout_vec,
-#endif
-#if 0 /* Clashes with sunos_big_vec magic no. */
- &hp300bsd_vec,
-#endif
- &hp300hpux_vec,
-#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF)
- &som_vec,
-#endif
- &i386aout_vec,
- &i386bsd_vec,
- &i386coff_vec,
- &i386freebsd_vec,
- &i860coff_vec,
- &bfd_powerpc_pe_vec,
- &bfd_powerpcle_pe_vec,
- &bfd_powerpc_pei_vec,
- &bfd_powerpcle_pei_vec,
- &go32coff_vec,
-#if 0
- /* Since a.out files lack decent magic numbers, no way to recognize
- which kind of a.out file it is. */
- &i386linux_vec,
-#endif
- &i386lynx_aout_vec,
- &i386lynx_coff_vec,
-#if 0
- /* No distinguishing features for Mach 3 executables. */
- &i386mach3_vec,
-#endif
- &i386msdos_vec,
- &i386netbsd_vec,
- &i386os9k_vec,
- &i386pe_vec,
- &i386pei_vec,
- &armcoff_little_vec,
- &armcoff_big_vec,
- &armpe_little_vec,
- &armpe_big_vec,
- &armpei_little_vec,
- &armpei_big_vec,
- &icoff_big_vec,
- &icoff_little_vec,
- &ieee_vec,
- &m68kcoff_vec,
- &m68kcoffun_vec,
-#if 0
- /* Since a.out files lack decent magic numbers, no way to recognize
- which kind of a.out file it is. */
- &m68klinux_vec,
-#endif
- &m68klynx_aout_vec,
- &m68klynx_coff_vec,
- &m68knetbsd_vec,
- &m88kbcs_vec,
- &m88kmach3_vec,
- &newsos3_vec,
- &nlm32_i386_vec,
- &nlm32_sparc_vec,
-#ifdef BFD64
- &nlm32_alpha_vec,
-#endif
- &pc532netbsd_vec,
-#if 0
- /* We have no oasys tools anymore, so we can't test any of this
- anymore. If you want to test the stuff yourself, go ahead...
- steve@cygnus.com
- Worse, since there is no magic number for archives, there
- can be annoying target mis-matches. */
- &oasys_vec,
-#endif
- &pc532machaout_vec,
-#if 0
- /* We have no way of distinguishing these from other a.out variants */
- &aout_arm_big_vec,
- &aout_arm_little_vec,
- &riscix_vec,
-#endif
-#if 0
- /* This has the same magic number as RS/6000. */
- &pmac_xcoff_vec,
-#endif
- &rs6000coff_vec,
- &shcoff_vec,
- &shlcoff_vec,
- &sparclynx_aout_vec,
- &sparclynx_coff_vec,
- &sparcnetbsd_vec,
- &sunos_big_vec,
- &aout0_big_vec,
- &tekhex_vec,
- &we32kcoff_vec,
- &versados_vec,
- &z8kcoff_vec,
-
-#endif /* not SELECT_VECS */
-
-/* Always support S-records, for convenience. */
- &srec_vec,
- &symbolsrec_vec,
-/* And tekhex */
- &tekhex_vec,
-/* Likewise for binary output. */
- &binary_vec,
-/* Likewise for ihex. */
- &ihex_vec,
-
-/* Add any required traditional-core-file-handler. */
-
-#ifdef AIX386_CORE
- &aix386_core_vec,
-#endif
-#ifdef HPUX_CORE
- &hpux_core_vec,
-#endif
-#ifdef HPPABSD_CORE
- &hppabsd_core_vec,
-#endif
-#ifdef IRIX_CORE
- &irix_core_vec,
-#endif
-#ifdef OSF_CORE
- &osf_core_vec,
-#endif
-#ifdef TRAD_CORE
- &trad_core_vec,
-#endif
-
-#ifdef PTRACE_CORE
- &ptrace_core_vec,
-#endif
-
- NULL /* end of list marker */
-};
-
-/* bfd_default_vector[0] contains either the address of the default vector,
- if there is one, or zero if there isn't. */
-
-const bfd_target * const bfd_default_vector[] = {
-#ifdef DEFAULT_VECTOR
- &DEFAULT_VECTOR,
-#endif
- NULL
-};
-
-/* When there is an ambiguous match, bfd_check_format_matches puts the
- names of the matching targets in an array. This variable is the maximum
- number of entries that the array could possibly need. */
-const size_t _bfd_target_vector_entries = sizeof(bfd_target_vector)/sizeof(*bfd_target_vector);
-
-/*
-FUNCTION
- bfd_find_target
-
-SYNOPSIS
- const bfd_target *bfd_find_target(CONST char *target_name, bfd *abfd);
-
-DESCRIPTION
- Return a pointer to the transfer vector for the object target
- named @var{target_name}. If @var{target_name} is <<NULL>>, choose the
- one in the environment variable <<GNUTARGET>>; if that is null or not
- defined, then choose the first entry in the target list.
- Passing in the string "default" or setting the environment
- variable to "default" will cause the first entry in the target
- list to be returned, and "target_defaulted" will be set in the
- BFD. This causes <<bfd_check_format>> to loop over all the
- targets to find the one that matches the file being read.
-*/
-
-const bfd_target *
-bfd_find_target (target_name, abfd)
- CONST char *target_name;
- bfd *abfd;
-{
- const bfd_target * const *target;
- extern char *getenv ();
- CONST char *targname = (target_name ? target_name :
- (CONST char *) getenv ("GNUTARGET"));
-
- /* This is safe; the vector cannot be null */
- if (targname == NULL || !strcmp (targname, "default")) {
- abfd->target_defaulted = true;
- return abfd->xvec = bfd_target_vector[0];
- }
-
- abfd->target_defaulted = false;
-
- for (target = &bfd_target_vector[0]; *target != NULL; target++) {
- if (!strcmp (targname, (*target)->name))
- return abfd->xvec = *target;
- }
-
- bfd_set_error (bfd_error_invalid_target);
- return NULL;
-}
-
-
-/*
-FUNCTION
- bfd_target_list
-
-SYNOPSIS
- const char **bfd_target_list(void);
-
-DESCRIPTION
- Return a freshly malloced NULL-terminated
- vector of the names of all the valid BFD targets. Do not
- modify the names.
-
-*/
-
-const char **
-bfd_target_list ()
-{
- int vec_length= 0;
-#if defined (HOST_HPPAHPUX) && ! defined (__STDC__)
- /* The native compiler on the HP9000/700 has a bug which causes it
- to loop endlessly when compiling this file. This avoids it. */
- volatile
-#endif
- const bfd_target * const *target;
- CONST char **name_list, **name_ptr;
-
- for (target = &bfd_target_vector[0]; *target != NULL; target++)
- vec_length++;
-
- name_ptr = name_list = (CONST char **)
- bfd_zmalloc ((vec_length + 1) * sizeof (char **));
-
- if (name_list == NULL)
- return NULL;
-
- for (target = &bfd_target_vector[0]; *target != NULL; target++)
- *(name_ptr++) = (*target)->name;
-
- return name_list;
-}
diff --git a/contrib/gdb/bfd/tekhex.c b/contrib/gdb/bfd/tekhex.c
deleted file mode 100644
index bf7957e673ab..000000000000
--- a/contrib/gdb/bfd/tekhex.c
+++ /dev/null
@@ -1,1031 +0,0 @@
-/* BFD backend for Extended Tektronix Hex Format objects.
- Copyright (C) 1992, 1993, 1994, 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
- Tektronix Hex Format handling
-
-DESCRIPTION
-
- Tek Hex records can hold symbols and data, but not
- relocations. Their main application is communication with
- devices like PROM programmers and ICE equipment.
-
- It seems that the sections are descibed as being really big,
- the example I have says that the text section is 0..ffffffff.
- BFD would barf with this, many apps would try to alloc 4GB to
- read in the file.
-
- Tex Hex may contain many sections, but the data which comes in
- has no tag saying which section it belongs to, so we create
- one section for each block of data, called "blknnnn" which we
- stick all the data into.
-
- TekHex may come out of order and there is no header, so an
- initial scan is required to discover the minimum and maximum
- addresses used to create the vma and size of the sections we
- create.
- We read in the data into pages of CHUNK_MASK+1 size and read
- them out from that whenever we need to.
-
- Any number of sections may be created for output, we save them
- up and output them when it's time to close the bfd.
-
-
- A TekHex record looks like:
-EXAMPLE
- %<block length><type><checksum><stuff><cr>
-
-DESCRIPTION
- Where
- o length
- is the number of bytes in the record not including the % sign.
- o type
- is one of:
- 3) symbol record
- 6) data record
- 8) termination record
-
-
-The data can come out of order, and may be discontigous. This is a
-serial protocol, so big files are unlikely, so we keep a list of 8k chunks
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libiberty.h"
-
-typedef struct
- {
- bfd_vma low;
- bfd_vma high;
- } addr_range_type;
-
-typedef struct tekhex_symbol_struct
- {
-
- asymbol symbol;
- struct tekhex_symbol_struct *prev;
-
- } tekhex_symbol_type;
-
-static const char digs[] = "0123456789ABCDEF";
-
-static char sum_block[256];
-
-#define NOT_HEX 20
-#define NIBBLE(x) hex_value(x)
-#define HEX(buffer) ((NIBBLE((buffer)[0])<<4) + NIBBLE((buffer)[1]))
-#define TOHEX(d,x) \
-(d)[1] = digs[(x) & 0xf]; \
-(d)[0] = digs[((x)>>4)&0xf];
-#define ISHEX(x) hex_p(x)
-
-/*
-Here's an example
-%3A6C6480004E56FFFC4E717063B0AEFFFC6D0652AEFFFC60F24E5E4E75
-%1B3709T_SEGMENT1108FFFFFFFF
-%2B3AB9T_SEGMENT7Dgcc_compiled$1087hello$c10
-%373829T_SEGMENT80int$t1$r1$$214741080char$t2$r2$0$12710
-%373769T_SEGMENT80long$int$t3$r1$$1080unsigned$int$t4$10
-%373CA9T_SEGMENT80long$unsigned$in1080short$int$t6$r1$10
-%373049T_SEGMENT80long$long$int$t71080short$unsigned$i10
-%373A29T_SEGMENT80long$long$unsign1080signed$char$t10$10
-%373D69T_SEGMENT80unsigned$char$t11080float$t12$r1$4$010
-%373D19T_SEGMENT80double$t13$r1$8$1080long$double$t14$10
-%2734D9T_SEGMENT8Bvoid$t15$151035_main10
-%2F3CA9T_SEGMENT81$1081$1681$1E81$21487main$F110
-%2832F9T_SEGMENT83i$18FFFFFFFC81$1481$214
-%07 8 10 10
-
-explanation:
-%3A6C6480004E56FFFC4E717063B0AEFFFC6D0652AEFFFC60F24E5E4E75
- ^ ^^ ^ ^-data
- | || +------ 4 char integer 0x8000
- | |+-------- checksum
- | +--------- type 6 (data record)
- +----------- length 3a chars
- <---------------------- 3a (58 chars) ------------------->
-
-%1B3709T_SEGMENT1108FFFFFFFF
- ^ ^^ ^- 8 character integer 0xffffffff
- | |+- 1 character integer 0
- | +-- type 1 symbol (section definition)
- +------------ 9 char symbol T_SEGMENT
-
-%2B3AB9T_SEGMENT7Dgcc_compiled$1087hello$c10
-%373829T_SEGMENT80int$t1$r1$$214741080char$t2$r2$0$12710
-%373769T_SEGMENT80long$int$t3$r1$$1080unsigned$int$t4$10
-%373CA9T_SEGMENT80long$unsigned$in1080short$int$t6$r1$10
-%373049T_SEGMENT80long$long$int$t71080short$unsigned$i10
-%373A29T_SEGMENT80long$long$unsign1080signed$char$t10$10
-%373D69T_SEGMENT80unsigned$char$t11080float$t12$r1$4$010
-%373D19T_SEGMENT80double$t13$r1$8$1080long$double$t14$10
-%2734D9T_SEGMENT8Bvoid$t15$151035_main10
-%2F3CA9T_SEGMENT81$1081$1681$1E81$21487main$F110
-%2832F9T_SEGMENT83i$18FFFFFFFC81$1481$214
-%0781010
-
-Turns into
-sac@thepub$ ./objdump -dx -m m68k f
-
-f: file format tekhex
------x--- 9/55728 -134219416 Sep 29 15:13 1995 f
-architecture: UNKNOWN!, flags 0x00000010:
-HAS_SYMS
-start address 0x00000000
-SECTION 0 [D00000000] : size 00020000 vma 00000000 align 2**0
- ALLOC, LOAD
-SECTION 1 [D00008000] : size 00002001 vma 00008000 align 2**0
-
-SECTION 2 [T_SEGMENT] : size ffffffff vma 00000000 align 2**0
-
-SYMBOL TABLE:
-00000000 g T_SEGMENT gcc_compiled$
-00000000 g T_SEGMENT hello$c
-00000000 g T_SEGMENT int$t1$r1$$21474
-00000000 g T_SEGMENT char$t2$r2$0$127
-00000000 g T_SEGMENT long$int$t3$r1$$
-00000000 g T_SEGMENT unsigned$int$t4$
-00000000 g T_SEGMENT long$unsigned$in
-00000000 g T_SEGMENT short$int$t6$r1$
-00000000 g T_SEGMENT long$long$int$t7
-00000000 g T_SEGMENT short$unsigned$i
-00000000 g T_SEGMENT long$long$unsign
-00000000 g T_SEGMENT signed$char$t10$
-00000000 g T_SEGMENT unsigned$char$t1
-00000000 g T_SEGMENT float$t12$r1$4$0
-00000000 g T_SEGMENT double$t13$r1$8$
-00000000 g T_SEGMENT long$double$t14$
-00000000 g T_SEGMENT void$t15$15
-00000000 g T_SEGMENT _main
-00000000 g T_SEGMENT $
-00000000 g T_SEGMENT $
-00000000 g T_SEGMENT $
-00000010 g T_SEGMENT $
-00000000 g T_SEGMENT main$F1
-fcffffff g T_SEGMENT i$1
-00000000 g T_SEGMENT $
-00000010 g T_SEGMENT $
-
-
-RELOCATION RECORDS FOR [D00000000]: (none)
-
-RELOCATION RECORDS FOR [D00008000]: (none)
-
-RELOCATION RECORDS FOR [T_SEGMENT]: (none)
-
-Disassembly of section D00000000:
-...
-00008000 ($+)7ff0 linkw fp,#-4
-00008004 ($+)7ff4 nop
-00008006 ($+)7ff6 movel #99,d0
-00008008 ($+)7ff8 cmpl fp@(-4),d0
-0000800c ($+)7ffc blts 00008014 ($+)8004
-0000800e ($+)7ffe addql #1,fp@(-4)
-00008012 ($+)8002 bras 00008006 ($+)7ff6
-00008014 ($+)8004 unlk fp
-00008016 ($+)8006 rts
-...
-
-*/
-
-static void
-tekhex_init ()
-{
- unsigned int i;
- static boolean inited = false;
- int val;
-
- if (inited == false)
- {
- inited = true;
- hex_init ();
- val = 0;
- for (i = 0; i < 10; i++)
- {
- sum_block[i + '0'] = val++;
- }
- for (i = 'A'; i <= 'Z'; i++)
- {
- sum_block[i] = val++;
- }
- sum_block['$'] = val++;
- sum_block['%'] = val++;
- sum_block['.'] = val++;
- sum_block['_'] = val++;
- for (i = 'a'; i <= 'z'; i++)
- {
- sum_block[i] = val++;
- }
- }
-}
-
-/* The maximum number of bytes on a line is FF */
-#define MAXCHUNK 0xff
-/* The number of bytes we fit onto a line on output */
-#define CHUNK 21
-
-/* We cannot output our tekhexords as we see them, we have to glue them
- together, this is done in this structure : */
-
-struct tekhex_data_list_struct
-{
- unsigned char *data;
- bfd_vma where;
- bfd_size_type size;
- struct tekhex_data_list_struct *next;
-
-};
-typedef struct tekhex_data_list_struct tekhex_data_list_type;
-
-#define CHUNK_MASK 0x1fff
-
-struct data_struct
- {
- char chunk_data[CHUNK_MASK + 1];
- char chunk_init[CHUNK_MASK + 1];
- bfd_vma vma;
- struct data_struct *next;
- };
-
-typedef struct tekhex_data_struct
-{
- tekhex_data_list_type *head;
- unsigned int type;
- struct tekhex_symbol_struct *symbols;
- struct data_struct *data;
-} tdata_type;
-
-#define enda(x) (x->vma + x->size)
-
-static bfd_vma
-getvalue (srcp)
- char **srcp;
-{
- char *src = *srcp;
- bfd_vma value = 0;
- unsigned int len = hex_value(*src++);
-
- if (len == 0)
- len = 16;
- while (len--)
- {
- value = value << 4 | hex_value(*src++);
- }
- *srcp = src;
- return value;
-}
-
-static unsigned int
-getsym (dstp, srcp)
- char *dstp;
- char **srcp;
-{
- char *src = *srcp;
- unsigned int i;
- unsigned int len = hex_value(*src++);
-
- if (len == 0)
- len = 16;
- for (i = 0; i < len; i++)
- dstp[i] = src[i];
- dstp[i] = 0;
- *srcp = src + i;
- return len;
-}
-
-struct data_struct *
-find_chunk (abfd, vma)
- bfd *abfd;
- bfd_vma vma;
-{
- struct data_struct *d = abfd->tdata.tekhex_data->data;
-
- vma &= ~CHUNK_MASK;
- while (d && (d->vma) != vma)
- {
- d = d->next;
- }
- if (!d)
- {
- char *sname = bfd_alloc (abfd, 12);
-
- /* No chunk for this address, so make one up */
- d = (struct data_struct *)
- bfd_alloc (abfd, sizeof (struct data_struct));
-
- if (!sname || !d)
- return NULL;
-
- memset (d->chunk_init, 0, CHUNK_MASK + 1);
- memset (d->chunk_data, 0, CHUNK_MASK + 1);
- d->next = abfd->tdata.tekhex_data->data;
- d->vma = vma;
- abfd->tdata.tekhex_data->data = d;
- }
- return d;
-}
-
-static void
-insert_byte (abfd, value, addr)
- bfd *abfd;
- int value;
- bfd_vma addr;
-{
- /* Find the chunk that this byte needs and put it in */
- struct data_struct *d = find_chunk (abfd, addr);
-
- d->chunk_data[addr & CHUNK_MASK] = value;
- d->chunk_init[addr & CHUNK_MASK] = 1;
-}
-
-/* The first pass is to find the names of all the sections, and see
- how big the data is */
-static void
-first_phase (abfd, type, src)
- bfd *abfd;
- char type;
- char *src;
-{
- asection *section = bfd_abs_section_ptr;
- int len;
- char sym[17]; /* A symbol can only be 16chars long */
-
- switch (type)
- {
- case '6':
- /* Data record - read it and store it */
- {
- bfd_vma addr = getvalue (&src);
-
- while (*src)
- {
- insert_byte (abfd, HEX (src), addr);
- src += 2;
- addr++;
- }
- }
-
- return;
- case '3':
- /* Symbol record, read the segment */
- len = getsym (sym, &src);
- section = bfd_get_section_by_name (abfd, sym);
- if (section == (asection *) NULL)
- {
- char *n = bfd_alloc (abfd, len + 1);
-
- if (!n)
- abort(); /* FIXME */
- memcpy (n, sym, len + 1);
- section = bfd_make_section (abfd, n);
- }
- while (*src)
- {
- switch (*src)
- {
- case '1': /* section range */
- src++;
- section->vma = getvalue (&src);
- section->_raw_size = getvalue (&src) - section->vma;
- section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
- break;
- case '0':
- case '2':
- case '3':
- case '4':
- case '6':
- case '7':
- case '8':
- /* Symbols, add to section */
- {
- tekhex_symbol_type *new =
- (tekhex_symbol_type *) bfd_alloc (abfd,
- sizeof (tekhex_symbol_type));
- char type = (*src);
-
- if (!new)
- abort(); /* FIXME */
- new->symbol.the_bfd = abfd;
- src++;
- abfd->symcount++;
- abfd->flags |= HAS_SYMS;
- new->prev = abfd->tdata.tekhex_data->symbols;
- abfd->tdata.tekhex_data->symbols = new;
- len = getsym (sym, &src);
- new->symbol.name = bfd_alloc (abfd, len + 1);
- if (!new->symbol.name)
- abort(); /* FIXME */
- memcpy ((char *) (new->symbol.name), sym, len + 1);
- new->symbol.section = section;
- if (type <= '4')
- new->symbol.flags = (BSF_GLOBAL | BSF_EXPORT);
- else
- new->symbol.flags = BSF_LOCAL;
- new->symbol.value = getvalue (&src) - section->vma;
- }
- }
- }
- }
-}
-
-/* Pass over an tekhex, calling one of the above functions on each
- record. */
-
-static void
- pass_over (abfd, func)
- bfd *abfd;
- void (*func) ();
-{
- unsigned int chars_on_line;
- boolean eof = false;
-
- /* To the front of the file */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- abort ();
- while (eof == false)
- {
- char buffer[MAXCHUNK];
- char *src = buffer;
- char type;
-
- /* Find first '%' */
- eof = (boolean) (bfd_read (src, 1, 1, abfd) != 1);
- while (*src != '%' && !eof)
- {
- eof = (boolean) (bfd_read (src, 1, 1, abfd) != 1);
- }
- if (eof)
- break;
- src++;
-
- /* Fetch the type and the length and the checksum */
- if (bfd_read (src, 1, 5, abfd) != 5)
- abort (); /* FIXME */
-
- type = src[2];
-
- if (!ISHEX (src[0]) || !ISHEX (src[1]))
- break;
-
- chars_on_line = HEX (src) - 5; /* Already read five char */
-
- if (bfd_read (src, 1, chars_on_line, abfd) != chars_on_line)
- abort (); /* FIXME */
- src[chars_on_line] = 0; /* put a null at the end */
-
- func (abfd, type, src);
- }
-
-}
-
-long
-tekhex_get_symtab (abfd, table)
- bfd *abfd;
- asymbol **table;
-
-{
- tekhex_symbol_type *p = abfd->tdata.tekhex_data->symbols;
- unsigned int c = bfd_get_symcount (abfd);
-
- table[c] = 0;
- while (p)
- {
- table[--c] = &(p->symbol);
- p = p->prev;
- }
-
- return bfd_get_symcount (abfd);
-}
-
-long
-tekhex_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- return (abfd->symcount + 1) * (sizeof (struct tekhex_asymbol_struct *));
-
-}
-
-static boolean
-tekhex_mkobject (abfd)
- bfd *abfd;
-{
- tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
-
- if (!tdata)
- return false;
- abfd->tdata.tekhex_data = tdata;
- tdata->type = 1;
- tdata->head = (tekhex_data_list_type *) NULL;
- tdata->symbols = (struct tekhex_symbol_struct *) NULL;
- tdata->data = (struct data_struct *) NULL;
- return true;
-}
-
-/*
- Return true if the file looks like it's in TekHex format. Just look
- for a percent sign and some hex digits */
-
-static const bfd_target *
-tekhex_object_p (abfd)
- bfd *abfd;
-{
- char b[4];
-
- tekhex_init ();
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_read (b, 1, 4, abfd) != 4)
- return NULL;
-
- if (b[0] != '%' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
- return (const bfd_target *) NULL;
-
- tekhex_mkobject (abfd);
-
- pass_over (abfd, first_phase);
- return abfd->xvec;
-}
-
-static void
-move_section_contents (abfd, section, locationp, offset, count, get)
- bfd *abfd;
- asection *section;
- PTR locationp;
- file_ptr offset;
- bfd_size_type count;
- boolean get;
-{
- bfd_vma addr;
- char *location = (char *) locationp;
- bfd_vma prev_number = 1; /* Nothing can have this as a high bit*/
- struct data_struct *d = (struct data_struct *) NULL;
-
- for (addr = section->vma; count != 0; count--, addr++)
- {
-
- bfd_vma chunk_number = addr & ~CHUNK_MASK; /* Get high bits of address */
- bfd_vma low_bits = addr & CHUNK_MASK;
-
- if (chunk_number != prev_number)
- {
- /* Different chunk, so move pointer */
- d = find_chunk (abfd, chunk_number);
- }
-
- if (get)
- {
- if (d->chunk_init[low_bits])
- {
- *location = d->chunk_data[low_bits];
- }
- else
- {
- *location = 0;
- }
- }
- else
- {
- d->chunk_data[low_bits] = *location;
- d->chunk_init[low_bits] = (*location != 0);
- }
-
- location++;
-
- }
-
-}
-static boolean
-tekhex_get_section_contents (abfd, section, locationp, offset, count)
- bfd *abfd;
- asection *section;
- PTR locationp;
- file_ptr offset;
- bfd_size_type count;
-{
- if (section->flags & (SEC_LOAD | SEC_ALLOC))
- {
- move_section_contents (abfd, section, locationp, offset, count, true);
- return true;
- }
- else
- return false;
-}
-
-boolean
-tekhex_set_arch_mach (abfd, arch, machine)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- return bfd_default_set_arch_mach (abfd, arch, machine);
-}
-
-/* we have to save up all the Tekhexords for a splurge before output,
- */
-
-static boolean
-tekhex_set_section_contents (abfd, section, locationp, offset, bytes_to_do)
- bfd *abfd;
- sec_ptr section;
- PTR locationp;
- file_ptr offset;
- bfd_size_type bytes_to_do;
-{
-
- if (abfd->output_has_begun == false)
- {
- /* The first time around, allocate enough sections to hold all the chunks */
- asection *s = abfd->sections;
- bfd_vma vma;
-
- for (s = abfd->sections; s; s = s->next)
- {
- if (s->flags & SEC_LOAD)
- {
- for (vma = s->vma & ~CHUNK_MASK;
- vma < s->vma + s->_raw_size;
- vma += CHUNK_MASK)
- find_chunk (abfd, vma);
- }
- }
-
- }
- if (section->flags & (SEC_LOAD | SEC_ALLOC))
- {
- move_section_contents (abfd, section, locationp, offset, bytes_to_do, false);
- return true;
- }
- else
- return false;
-
-}
-
-static void
-writevalue (dst, value)
- char **dst;
- bfd_vma value;
-{
- char *p = *dst;
- int len;
- int shift;
-
- for (len = 8, shift = 28; shift; shift -= 4, len--)
- {
- if ((value >> shift) & 0xf)
- {
- *p++ = len + '0';
- while (len)
- {
- *p++ = digs[(value >> shift) & 0xf];
- shift -= 4;
- len--;
- }
- *dst = p;
- return;
-
- }
- }
- *p++ = '1';
- *p++ = '0';
- *dst = p;
-}
-
-static void
-writesym (dst, sym)
- char **dst;
- CONST char *sym;
-{
- char *p = *dst;
- int len = (sym ? strlen (sym) : 0);
-
- if (len >= 16)
- {
- *p++ = '0';
- len = 16;
- }
-
- else
- {
- if (len == 0)
- {
- *p++ = '1';
- sym = "$";
- len = 1;
- }
- else
- {
- *p++ = digs[len];
- }
- }
-
- while (len--)
- {
- *p++ = *sym++;
- }
- *dst = p;
-}
-
-static void
-out (abfd, type, start, end)
- bfd *abfd;
- char type;
- char *start;
- char *end;
-{
- int sum = 0;
- char *s;
- char front[6];
- bfd_size_type wrlen;
-
- front[0] = '%';
- TOHEX (front + 1, end - start + 5);
- front[3] = type;
-
- for (s = start; s < end; s++)
- {
- sum += sum_block[(unsigned char) *s];
- }
-
- sum += sum_block[(unsigned char) front[1]]; /* length */
- sum += sum_block[(unsigned char) front[2]];
- sum += sum_block[(unsigned char) front[3]]; /* type */
- TOHEX (front + 4, sum);
- if (bfd_write (front, 1, 6, abfd) != 6)
- abort ();
- end[0] = '\n';
- wrlen = end - start + 1;
- if (bfd_write (start, 1, wrlen, abfd) != wrlen)
- abort ();
-}
-
-static boolean
-tekhex_write_object_contents (abfd)
- bfd *abfd;
-{
- int bytes_written;
- char buffer[100];
- asymbol **p;
- asection *s;
- struct data_struct *d;
-
- bytes_written = 0;
-
- /* And the raw data */
- for (d = abfd->tdata.tekhex_data->data;
- d != (struct data_struct *) NULL;
- d = d->next)
- {
- int low;
-
- CONST int span = 32;
- int addr;
-
- /* Write it in blocks of 32 bytes */
-
- for (addr = 0; addr < CHUNK_MASK + 1; addr += span)
- {
- int need = 0;
-
- /* Check to see if necessary */
- for (low = 0; !need && low < span; low++)
- {
- if (d->chunk_init[addr + low])
- need = 1;
- }
- if (need)
- {
- char *dst = buffer;
-
- writevalue (&dst, addr + d->vma);
- for (low = 0; low < span; low++)
- {
- TOHEX (dst, d->chunk_data[addr + low]);
- dst += 2;
- }
- out (abfd, '6', buffer, dst);
- }
- }
- }
- /* write all the section headers for the sections */
- for (s = abfd->sections; s != (asection *) NULL; s = s->next)
- {
- char *dst = buffer;
-
- writesym (&dst, s->name);
- *dst++ = '1';
- writevalue (&dst, s->vma);
- writevalue (&dst, s->vma + s->_raw_size);
- out (abfd, '3', buffer, dst);
- }
-
- /* And the symbols */
- for (p = abfd->outsymbols; *p; p++)
- {
- int section_code = bfd_decode_symclass (*p);
-
- if (section_code != '?')
- { /* do not include debug symbols */
- asymbol *s = *p;
- char *dst = buffer;
-
- writesym (&dst, s->section->name);
-
- switch (section_code)
- {
- case 'A':
- *dst++ = '2';
- break;
- case 'a':
- *dst++ = '6';
- break;
- case 'D':
- case 'B':
- case 'O':
- *dst++ = '4';
- break;
- case 'd':
- case 'b':
- case 'o':
- *dst++ = '8';
- break;
- case 'T':
- *dst++ = '3';
- break;
- case 't':
- *dst++ = '7';
- break;
- case 'C':
- case 'U':
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- writesym (&dst, s->name);
- writevalue (&dst, s->value + s->section->vma);
- out (abfd, '3', buffer, dst);
- }
- }
-
- /* And the terminator */
- if (bfd_write ("%0781010\n", 1, 9, abfd) != 9)
- abort ();
- return true;
-}
-
-static int
- tekhex_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-
-{
- return 0;
-}
-
-static asymbol *
-tekhex_make_empty_symbol (abfd)
- bfd *abfd;
-{
- tekhex_symbol_type *new =
- (tekhex_symbol_type *) bfd_zalloc (abfd, sizeof (struct tekhex_symbol_struct));
-
- if (!new)
- return NULL;
- new->symbol.the_bfd = abfd;
- new->prev = (struct tekhex_symbol_struct *) NULL;
- return &(new->symbol);
-}
-
-static void
-tekhex_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-static void
-tekhex_print_symbol (ignore_abfd, filep, symbol, how)
- bfd *ignore_abfd;
- PTR filep;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) filep;
-
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
- case bfd_print_symbol_more:
- break;
-
- case bfd_print_symbol_all:
- {
- CONST char *section_name = symbol->section->name;
-
- bfd_print_symbol_vandf ((PTR) file, symbol);
-
- fprintf (file, " %-5s %s",
- section_name,
- symbol->name);
- }
- }
-}
-
-#define tekhex_close_and_cleanup _bfd_generic_close_and_cleanup
-#define tekhex_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define tekhex_new_section_hook _bfd_generic_new_section_hook
-
-#define tekhex_bfd_is_local_label bfd_generic_is_local_label
-#define tekhex_get_lineno _bfd_nosymbols_get_lineno
-#define tekhex_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define tekhex_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define tekhex_read_minisymbols _bfd_generic_read_minisymbols
-#define tekhex_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define tekhex_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define tekhex_bfd_relax_section bfd_generic_relax_section
-#define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define tekhex_bfd_final_link _bfd_generic_final_link
-#define tekhex_bfd_link_split_section _bfd_generic_link_split_section
-
-#define tekhex_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-const bfd_target tekhex_vec =
-{
- "tekhex", /* name */
- bfd_target_tekhex_flavour,
- BFD_ENDIAN_UNKNOWN, /* target byte order */
- BFD_ENDIAN_UNKNOWN, /* target headers byte order */
- (EXEC_P | /* object flags */
- HAS_SYMS | HAS_LINENO | HAS_DEBUG | HAS_RELOC | 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,
- tekhex_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- tekhex_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- tekhex_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (tekhex),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (tekhex),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (tekhex),
- BFD_JUMP_TABLE_LINK (tekhex),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/trad-core.c b/contrib/gdb/bfd/trad-core.c
deleted file mode 100644
index 09c74ae481cd..000000000000
--- a/contrib/gdb/bfd/trad-core.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/* BFD back end for traditional Unix core files (U-area and raw sections)
- Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by John Gilmore of Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 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/user.h> /* After a.out.h */
-
-#ifdef TRAD_HEADER
-#include TRAD_HEADER
-#endif
-
- struct trad_core_struct
- {
- asection *data_section;
- asection *stack_section;
- asection *reg_section;
- struct 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 *trad_unix_core_file_p PARAMS ((bfd *abfd));
-char * trad_unix_core_file_failing_command PARAMS ((bfd *abfd));
-int trad_unix_core_file_failing_signal PARAMS ((bfd *abfd));
-boolean trad_unix_core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
-
-/* Handle 4.2-style (and perhaps also sysV-style) core dump file. */
-
-/* ARGSUSED */
-const bfd_target *
-trad_unix_core_file_p (abfd)
- bfd *abfd;
-
-{
- int val;
- struct user u;
- struct trad_core_struct *rawptr;
-
-#ifdef TRAD_CORE_USER_OFFSET
- /* If defined, this macro is the file position of the user struct. */
- if (bfd_seek (abfd, TRAD_CORE_USER_OFFSET, SEEK_SET) != 0)
- return 0;
-#endif
-
- val = bfd_read ((void *)&u, 1, sizeof u, abfd);
- if (val != sizeof u)
- {
- /* Too small to be a core file */
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- /* Sanity check perhaps??? */
- if (u.u_dsize > 0x1000000) /* Remember, it's in pages... */
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
- if (u.u_ssize > 0x1000000)
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- /* Check that the size claimed is no greater than the file size. */
- {
- FILE *stream = bfd_cache_lookup (abfd);
- struct stat statbuf;
- if (stream == NULL)
- return 0;
- if (fstat (fileno (stream), &statbuf) < 0)
- {
- bfd_set_error (bfd_error_system_call);
- return 0;
- }
- if (NBPG * (UPAGES + u.u_dsize
-#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
- - u.u_tsize
-#endif
- + u.u_ssize) > statbuf.st_size)
- {
- bfd_set_error (bfd_error_file_truncated);
- return 0;
- }
-#ifndef TRAD_CORE_ALLOW_ANY_EXTRA_SIZE
- if (NBPG * (UPAGES + u.u_dsize + u.u_ssize)
-#ifdef TRAD_CORE_EXTRA_SIZE_ALLOWED
- /* Some systems write the file too big. */
- + TRAD_CORE_EXTRA_SIZE_ALLOWED
-#endif
- < 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 0;
- }
-#endif
- }
-
- /* 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_zmalloc (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";
-
- 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 = NBPG * u.u_dsize
-#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
- - NBPG * u.u_tsize
-#endif
- ;
- core_stacksec (abfd)->_raw_size = NBPG * u.u_ssize;
- core_regsec (abfd)->_raw_size = NBPG * UPAGES; /* Larger than sizeof struct u */
-
- /* What a hack... we'd like to steal it from the exec file,
- since the upage does not seem to provide it. FIXME. */
-#ifdef HOST_DATA_START_ADDR
- core_datasec (abfd)->vma = HOST_DATA_START_ADDR;
-#else
- core_datasec (abfd)->vma = HOST_TEXT_START_ADDR + (NBPG * u.u_tsize);
-#endif
-
-#ifdef HOST_STACK_START_ADDR
- core_stacksec (abfd)->vma = HOST_STACK_START_ADDR;
-#else
- core_stacksec (abfd)->vma = HOST_STACK_END_ADDR - (NBPG * u.u_ssize);
-#endif
-
- /* This is tricky. As the "register section", we give them the entire
- upage and stack. u.u_ar0 points to where "register 0" is stored.
- There are two tricks with this, though. One is that the rest of the
- registers might be at positive or negative (or both) displacements
- from *u_ar0. The other is that u_ar0 is sometimes an absolute address
- in kernel memory, and on other systems it is an offset from the beginning
- of the `struct user'.
-
- As a practical matter, we don't know where the registers actually are,
- so we have to pass the whole area to GDB. We encode the value of u_ar0
- by setting the .regs section up so that its virtual memory address
- 0 is at the place pointed to by u_ar0 (by setting the vma of the start
- of the section to -u_ar0). GDB uses this info to locate the regs,
- using minor trickery to get around the offset-or-absolute-addr problem. */
- core_regsec (abfd)->vma = 0 - (bfd_vma) u.u_ar0;
-
- core_datasec (abfd)->filepos = NBPG * UPAGES;
- core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize
-#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
- - NBPG * u.u_tsize
-#endif
- ;
- core_regsec (abfd)->filepos = 0; /* Register segment is the upage */
-
- /* Align to word at least */
- core_stacksec (abfd)->alignment_power = 2;
- core_datasec (abfd)->alignment_power = 2;
- core_regsec (abfd)->alignment_power = 2;
-
- abfd->sections = core_stacksec (abfd);
- core_stacksec (abfd)->next = core_datasec (abfd);
- core_datasec (abfd)->next = core_regsec (abfd);
- abfd->section_count = 3;
-
- return abfd->xvec;
-}
-
-char *
-trad_unix_core_file_failing_command (abfd)
- bfd *abfd;
-{
-#ifndef NO_CORE_COMMAND
- char *com = abfd->tdata.trad_core_data->u.u_comm;
- if (*com)
- return com;
- else
-#endif
- return 0;
-}
-
-/* ARGSUSED */
-int
-trad_unix_core_file_failing_signal (ignore_abfd)
- bfd *ignore_abfd;
-{
-#ifdef TRAD_UNIX_CORE_FILE_FAILING_SIGNAL
- return TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(ignore_abfd);
-#else
- return -1; /* FIXME, where is it? */
-#endif
-}
-
-/* ARGSUSED */
-boolean
-trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- return true; /* FIXME, We have no way of telling at this point */
-}
-
-/* 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 trad_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 */
- trad_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 (trad_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 */
-};
diff --git a/contrib/gdb/bfd/versados.c b/contrib/gdb/bfd/versados.c
deleted file mode 100644
index 84ad114e90a2..000000000000
--- 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 16a76cc7ca55..000000000000
--- 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/install.sh b/contrib/gdb/install.sh
deleted file mode 100755
index c92d510dd11b..000000000000
--- a/contrib/gdb/install.sh
+++ /dev/null
@@ -1,236 +0,0 @@
-#!/bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/contrib/gdb/move-if-change b/contrib/gdb/move-if-change
deleted file mode 100755
index ee1b348beebd..000000000000
--- a/contrib/gdb/move-if-change
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 1996 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-if
-test -r $2
-then
-if
-cmp $1 $2 > /dev/null
-then
-echo $2 is unchanged
-rm -f $1
-else
-mv -f $1 $2
-fi
-else
-mv -f $1 $2
-fi