From 039fc55dda294deb4a58d3baefdcbd2a3274d449 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Fri, 12 May 2000 23:15:21 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'binutils-vendor-sourceware_binutils-2_10-branch_anoncvs_20000512'. --- contrib/binutils/bfd/VERSION | 1 - contrib/binutils/bfd/acconfig.h | 34 - contrib/binutils/bfd/coff-sh.c | 2944 ------------------------- contrib/binutils/bfd/cpu-sh.c | 117 - contrib/binutils/bfd/doc/aoutx.texi | 211 -- contrib/binutils/bfd/doc/archive.texi | 95 - contrib/binutils/bfd/doc/archures.texi | 354 --- contrib/binutils/bfd/doc/bfd.texi | 585 ----- contrib/binutils/bfd/doc/bfdt.texi | 597 ----- contrib/binutils/bfd/doc/cache.texi | 95 - contrib/binutils/bfd/doc/coffcode.texi | 639 ------ contrib/binutils/bfd/doc/core.texi | 38 - contrib/binutils/bfd/doc/elf.texi | 22 - contrib/binutils/bfd/doc/elfcode.texi | 0 contrib/binutils/bfd/doc/format.texi | 108 - contrib/binutils/bfd/doc/hash.texi | 245 --- contrib/binutils/bfd/doc/init.texi | 13 - contrib/binutils/bfd/doc/libbfd.texi | 142 -- contrib/binutils/bfd/doc/linker.texi | 365 ---- contrib/binutils/bfd/doc/opncls.texi | 128 -- contrib/binutils/bfd/doc/reloc.texi | 998 --------- contrib/binutils/bfd/doc/section.texi | 650 ------ contrib/binutils/bfd/doc/syms.texi | 408 ---- contrib/binutils/bfd/doc/targets.texi | 478 ---- contrib/binutils/bfd/elf32-sh.c | 1909 ---------------- contrib/binutils/bfd/filemode.c | 194 -- contrib/binutils/bfd/sunos.c | 2918 ------------------------- contrib/binutils/binutils/acconfig.h | 34 - contrib/binutils/binutils/config.texi | 1 - contrib/binutils/binutils/defparse.c | 1056 --------- contrib/binutils/binutils/defparse.h | 27 - contrib/binutils/binutils/rclex.c | 2526 ---------------------- contrib/binutils/binutils/rcparse.c | 2993 -------------------------- contrib/binutils/binutils/rcparse.h | 124 -- contrib/binutils/etc/cfg-paper.texi | 717 ------ contrib/binutils/etc/configure.man | 166 -- contrib/binutils/gas/acconfig.h | 79 - contrib/binutils/gas/conf.in | 127 -- contrib/binutils/gas/config/atof-vax.c | 517 ----- contrib/binutils/gas/config/i386coff.mt | 1 - contrib/binutils/gas/config/sco5.mt | 1 - contrib/binutils/gas/config/tc-sh.c | 2335 -------------------- contrib/binutils/gas/config/tc-sh.h | 141 -- contrib/binutils/gas/config/te-freebsd.h | 8 - contrib/binutils/gas/config/te-multi.h | 22 - contrib/binutils/gas/doc/c-sh.texi | 272 --- contrib/binutils/include/aout/sun4.h | 219 -- contrib/binutils/include/wait.h | 63 - contrib/binutils/install.sh | 247 --- contrib/binutils/ld/acconfig.h | 22 - contrib/binutils/ld/configdoc.texi | 13 - contrib/binutils/ld/emultempl/stringify.sed | 4 - contrib/binutils/libiberty/alloca-botch.h | 5 - contrib/binutils/libiberty/alloca-norm.h | 25 - contrib/binutils/libiberty/config/mh-sysv | 1 - contrib/binutils/libiberty/config/mh-sysv4 | 3 - contrib/binutils/libiberty/config/mt-mingw32 | 27 - contrib/binutils/libiberty/dummy.c | 49 - contrib/binutils/libiberty/functions.def | 70 - contrib/binutils/opcodes/acconfig.h | 6 - 60 files changed, 26189 deletions(-) delete mode 100644 contrib/binutils/bfd/VERSION delete mode 100644 contrib/binutils/bfd/acconfig.h delete mode 100644 contrib/binutils/bfd/coff-sh.c delete mode 100644 contrib/binutils/bfd/cpu-sh.c delete mode 100644 contrib/binutils/bfd/doc/aoutx.texi delete mode 100644 contrib/binutils/bfd/doc/archive.texi delete mode 100644 contrib/binutils/bfd/doc/archures.texi delete mode 100644 contrib/binutils/bfd/doc/bfd.texi delete mode 100644 contrib/binutils/bfd/doc/bfdt.texi delete mode 100644 contrib/binutils/bfd/doc/cache.texi delete mode 100644 contrib/binutils/bfd/doc/coffcode.texi delete mode 100644 contrib/binutils/bfd/doc/core.texi delete mode 100644 contrib/binutils/bfd/doc/elf.texi delete mode 100644 contrib/binutils/bfd/doc/elfcode.texi delete mode 100644 contrib/binutils/bfd/doc/format.texi delete mode 100644 contrib/binutils/bfd/doc/hash.texi delete mode 100644 contrib/binutils/bfd/doc/init.texi delete mode 100644 contrib/binutils/bfd/doc/libbfd.texi delete mode 100644 contrib/binutils/bfd/doc/linker.texi delete mode 100644 contrib/binutils/bfd/doc/opncls.texi delete mode 100644 contrib/binutils/bfd/doc/reloc.texi delete mode 100644 contrib/binutils/bfd/doc/section.texi delete mode 100644 contrib/binutils/bfd/doc/syms.texi delete mode 100644 contrib/binutils/bfd/doc/targets.texi delete mode 100644 contrib/binutils/bfd/elf32-sh.c delete mode 100644 contrib/binutils/bfd/filemode.c delete mode 100644 contrib/binutils/bfd/sunos.c delete mode 100644 contrib/binutils/binutils/acconfig.h delete mode 100644 contrib/binutils/binutils/config.texi delete mode 100644 contrib/binutils/binutils/defparse.c delete mode 100644 contrib/binutils/binutils/defparse.h delete mode 100644 contrib/binutils/binutils/rclex.c delete mode 100644 contrib/binutils/binutils/rcparse.c delete mode 100644 contrib/binutils/binutils/rcparse.h delete mode 100644 contrib/binutils/etc/cfg-paper.texi delete mode 100644 contrib/binutils/etc/configure.man delete mode 100644 contrib/binutils/gas/acconfig.h delete mode 100644 contrib/binutils/gas/conf.in delete mode 100644 contrib/binutils/gas/config/atof-vax.c delete mode 100644 contrib/binutils/gas/config/i386coff.mt delete mode 100644 contrib/binutils/gas/config/sco5.mt delete mode 100644 contrib/binutils/gas/config/tc-sh.c delete mode 100644 contrib/binutils/gas/config/tc-sh.h delete mode 100644 contrib/binutils/gas/config/te-freebsd.h delete mode 100644 contrib/binutils/gas/config/te-multi.h delete mode 100644 contrib/binutils/gas/doc/c-sh.texi delete mode 100644 contrib/binutils/include/aout/sun4.h delete mode 100644 contrib/binutils/include/wait.h delete mode 100755 contrib/binutils/install.sh delete mode 100644 contrib/binutils/ld/acconfig.h delete mode 100644 contrib/binutils/ld/configdoc.texi delete mode 100644 contrib/binutils/ld/emultempl/stringify.sed delete mode 100644 contrib/binutils/libiberty/alloca-botch.h delete mode 100644 contrib/binutils/libiberty/alloca-norm.h delete mode 100644 contrib/binutils/libiberty/config/mh-sysv delete mode 100644 contrib/binutils/libiberty/config/mh-sysv4 delete mode 100644 contrib/binutils/libiberty/config/mt-mingw32 delete mode 100644 contrib/binutils/libiberty/dummy.c delete mode 100644 contrib/binutils/libiberty/functions.def delete mode 100644 contrib/binutils/opcodes/acconfig.h diff --git a/contrib/binutils/bfd/VERSION b/contrib/binutils/bfd/VERSION deleted file mode 100644 index dbe590065479..000000000000 --- a/contrib/binutils/bfd/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.8.1 diff --git a/contrib/binutils/bfd/acconfig.h b/contrib/binutils/bfd/acconfig.h deleted file mode 100644 index 1d5e819ec24e..000000000000 --- a/contrib/binutils/bfd/acconfig.h +++ /dev/null @@ -1,34 +0,0 @@ - -/* Name of package. */ -#undef PACKAGE - -/* Version of package. */ -#undef VERSION - -/* Whether strstr must be declared even if is included. */ -#undef NEED_DECLARATION_STRSTR - -/* Whether malloc must be declared even if is included. */ -#undef NEED_DECLARATION_MALLOC - -/* Whether realloc must be declared even if is included. */ -#undef NEED_DECLARATION_REALLOC - -/* Whether free must be declared even if is included. */ -#undef NEED_DECLARATION_FREE - -/* Whether getenv must be declared even if is included. */ -#undef NEED_DECLARATION_GETENV -@TOP@ - -/* Do we need to use the b modifier when opening binary files? */ -#undef USE_BINARY_FOPEN - -/* Name of host specific header file to include in trad-core.c. */ -#undef TRAD_HEADER - -/* Define only if is available *and* it defines prstatus_t. */ -#undef HAVE_SYS_PROCFS_H - -/* Do we really want to use mmap if it's available? */ -#undef USE_MMAP diff --git a/contrib/binutils/bfd/coff-sh.c b/contrib/binutils/bfd/coff-sh.c deleted file mode 100644 index fd4f2180bce3..000000000000 --- a/contrib/binutils/bfd/coff-sh.c +++ /dev/null @@ -1,2944 +0,0 @@ -/* BFD back-end for Hitachi Super-H COFF binaries. - Copyright 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. - Contributed by Cygnus Support. - Written by Steve Chamberlain, . - Relaxing code written by Ian Lance Taylor, . - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public 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 "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_merge_private_data PARAMS ((bfd *, bfd *)); -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 const struct sh_opcode *sh_insn_info PARAMS ((unsigned int)); -static boolean sh_align_loads - PARAMS ((bfd *, asection *, struct internal_reloc *, bfd_byte *, boolean *)); -static boolean sh_swap_insns - PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma)); -static boolean sh_relocate_section - PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, - struct internal_reloc *, struct internal_syment *, asection **)); -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**4. */ -#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (4) - -/* 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 */ - - HOWTO (R_SH_CODE, /* 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_code", /* name */ - true, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ - - HOWTO (R_SH_DATA, /* 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_data", /* name */ - true, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ - - HOWTO (R_SH_LABEL, /* 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_label", /* name */ - true, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ - - HOWTO (R_SH_SWITCH8, /* type */ - 0, /* rightshift */ - 0, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - sh_reloc, /* special_function */ - "r_switch8", /* name */ - true, /* partial_inplace */ - 0xff, /* src_mask */ - 0xff, /* 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_SWITCH8 \ - || (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; -} - -/* This routine checks for linking big and little endian objects - together. */ - -static boolean -sh_merge_private_data (ibfd, obfd) - bfd *ibfd; - bfd *obfd; -{ - 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; - } - - return true; -} - -#define coff_bfd_merge_private_bfd_data sh_merge_private_data - -/* 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. - - SH relaxing also handles another, unrelated, matter. On the SH, if - a load or store instruction is not aligned on a four byte boundary, - the memory cycle interferes with the 32 bit instruction fetch, - causing a one cycle bubble in the pipeline. Therefore, we try to - align load and store instructions on four byte boundaries if we - can, by swapping them with one of the adjacent instructions. */ - -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; - boolean have_code; - 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; - - have_code = false; - - 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_CODE) - have_code = true; - - 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; - /* Careful to sign extend the 32-bit offset. */ - laddr += ((irel->r_offset & 0xffffffff) ^ 0x80000000) - 0x80000000; - 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. */ - } - - /* Look for load and store instructions that we can align on four - byte boundaries. */ - if (have_code) - { - boolean swapped; - - /* 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; - } - } - - if (! sh_align_loads (abfd, sec, internal_relocs, contents, &swapped)) - goto error_return; - - if (swapped) - { - 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; - } - } - - 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 - { - int i; - -#define NOP_OPCODE (0x0009) - - BFD_ASSERT ((count & 1) == 0); - for (i = 0; i < count; i += 2) - bfd_put_16 (abfd, NOP_OPCODE, contents + toaddr - count + i); - } - - /* Adjust all the relocs. */ - for (irel = coff_section_data (abfd, sec)->relocs; irel < irelend; irel++) - { - bfd_vma nraddr, stop; - bfd_vma start = 0; - int insn = 0; - struct internal_syment sym; - int off, adjust, oinsn; - bfd_signed_vma voff = 0; - 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. Don't delete relocs which - represent addresses, though. */ - 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_CODE - && irel->r_type != R_SH_DATA - && irel->r_type != R_SH_LABEL) - 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_SWITCH8: - 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 if (irel->r_type == R_SH_SWITCH8) - voff = bfd_get_8 (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_SWITCH8: - voff += adjust; - if (voff < 0 || voff >= 0xff) - overflow = true; - bfd_put_8 (abfd, voff, 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 alignto, alignaddr; - - alignto = BFD_ALIGN (toaddr, 1 << irelalign->r_offset); - alignaddr = BFD_ALIGN (irelalign->r_vaddr - sec->vma, - 1 << irelalign->r_offset); - if (alignto != alignaddr) - { - /* Tail recursion. */ - return sh_relax_delete_bytes (abfd, sec, alignaddr, - alignto - alignaddr); - } - } - - return true; -} - -/* This is yet another version of the SH opcode table, used to rapidly - get information about a particular instruction. */ - -/* The opcode map is represented by an array of these structures. The - array is indexed by the high order four bits in the instruction. */ - -struct sh_major_opcode -{ - /* A pointer to the instruction list. This is an array which - contains all the instructions with this major opcode. */ - const struct sh_minor_opcode *minor_opcodes; - /* The number of elements in minor_opcodes. */ - unsigned short count; -}; - -/* This structure holds information for a set of SH opcodes. The - instruction code is anded with the mask value, and the resulting - value is used to search the order opcode list. */ - -struct sh_minor_opcode -{ - /* The sorted opcode list. */ - const struct sh_opcode *opcodes; - /* The number of elements in opcodes. */ - unsigned short count; - /* The mask value to use when searching the opcode list. */ - unsigned short mask; -}; - -/* This structure holds information for an SH instruction. An array - of these structures is sorted in order by opcode. */ - -struct sh_opcode -{ - /* The code for this instruction, after it has been anded with the - mask value in the sh_major_opcode structure. */ - unsigned short opcode; - /* Flags for this instruction. */ - unsigned short flags; -}; - -/* Flag which appear in the sh_opcode structure. */ - -/* This instruction loads a value from memory. */ -#define LOAD (0x1) - -/* This instruction stores a value to memory. */ -#define STORE (0x2) - -/* This instruction is a branch. */ -#define BRANCH (0x4) - -/* This instruction has a delay slot. */ -#define DELAY (0x8) - -/* This instruction uses the value in the register in the field at - mask 0x0f00 of the instruction. */ -#define USES1 (0x10) - -/* This instruction uses the value in the register in the field at - mask 0x00f0 of the instruction. */ -#define USES2 (0x20) - -/* This instruction uses the value in register 0. */ -#define USESR0 (0x40) - -/* This instruction sets the value in the register in the field at - mask 0x0f00 of the instruction. */ -#define SETS1 (0x80) - -/* This instruction sets the value in the register in the field at - mask 0x00f0 of the instruction. */ -#define SETS2 (0x100) - -/* This instruction sets register 0. */ -#define SETSR0 (0x200) - -/* This instruction sets a special register. */ -#define SETSSP (0x400) - -/* This instruction uses a special register. */ -#define USESSP (0x800) - -/* This instruction uses the floating point register in the field at - mask 0x0f00 of the instruction. */ -#define USESF1 (0x1000) - -/* This instruction uses the floating point register in the field at - mask 0x00f0 of the instruction. */ -#define USESF2 (0x2000) - -/* This instruction uses floating point register 0. */ -#define USESF0 (0x4000) - -/* This instruction sets the floating point register in the field at - mask 0x0f00 of the instruction. */ -#define SETSF1 (0x8000) - -static boolean sh_insn_uses_reg - PARAMS ((unsigned int, const struct sh_opcode *, unsigned int)); -static boolean sh_insn_uses_freg - PARAMS ((unsigned int, const struct sh_opcode *, unsigned int)); -static boolean sh_insns_conflict - PARAMS ((unsigned int, const struct sh_opcode *, unsigned int, - const struct sh_opcode *)); -static boolean sh_load_use - PARAMS ((unsigned int, const struct sh_opcode *, unsigned int, - const struct sh_opcode *)); - -/* The opcode maps. */ - -#define MAP(a) a, sizeof a / sizeof a[0] - -static const struct sh_opcode sh_opcode00[] = -{ - { 0x0008, SETSSP }, /* clrt */ - { 0x0009, 0 }, /* nop */ - { 0x000b, BRANCH | DELAY | USESSP }, /* rts */ - { 0x0018, SETSSP }, /* sett */ - { 0x0019, SETSSP }, /* div0u */ - { 0x001b, 0 }, /* sleep */ - { 0x0028, SETSSP }, /* clrmac */ - { 0x002b, BRANCH | DELAY | SETSSP }, /* rte */ - { 0x0038, USESSP | SETSSP }, /* ldtlb */ - { 0x0048, SETSSP }, /* clrs */ - { 0x0058, SETSSP } /* sets */ -}; - -static const struct sh_opcode sh_opcode01[] = -{ - { 0x0002, SETS1 | USESSP }, /* stc sr,rn */ - { 0x0003, BRANCH | DELAY | USES1 | SETSSP }, /* bsrf rn */ - { 0x000a, SETS1 | USESSP }, /* sts mach,rn */ - { 0x0012, SETS1 | USESSP }, /* stc gbr,rn */ - { 0x001a, SETS1 | USESSP }, /* sts macl,rn */ - { 0x0022, SETS1 | USESSP }, /* stc vbr,rn */ - { 0x0023, BRANCH | DELAY | USES1 }, /* braf rn */ - { 0x0029, SETS1 | USESSP }, /* movt rn */ - { 0x002a, SETS1 | USESSP }, /* sts pr,rn */ - { 0x0032, SETS1 | USESSP }, /* stc ssr,rn */ - { 0x0042, SETS1 | USESSP }, /* stc spc,rn */ - { 0x005a, SETS1 | USESSP }, /* sts fpul,rn */ - { 0x006a, SETS1 | USESSP }, /* sts fpscr,rn */ - { 0x0082, SETS1 | USESSP }, /* stc r0_bank,rn */ - { 0x0083, LOAD | USES1 }, /* pref @rn */ - { 0x0092, SETS1 | USESSP }, /* stc r1_bank,rn */ - { 0x00a2, SETS1 | USESSP }, /* stc r2_bank,rn */ - { 0x00b2, SETS1 | USESSP }, /* stc r3_bank,rn */ - { 0x00c2, SETS1 | USESSP }, /* stc r4_bank,rn */ - { 0x00d2, SETS1 | USESSP }, /* stc r5_bank,rn */ - { 0x00e2, SETS1 | USESSP }, /* stc r6_bank,rn */ - { 0x00f2, SETS1 | USESSP } /* stc r7_bank,rn */ -}; - -static const struct sh_opcode sh_opcode02[] = -{ - { 0x0004, STORE | USES1 | USES2 | USESR0 }, /* mov.b rm,@(r0,rn) */ - { 0x0005, STORE | USES1 | USES2 | USESR0 }, /* mov.w rm,@(r0,rn) */ - { 0x0006, STORE | USES1 | USES2 | USESR0 }, /* mov.l rm,@(r0,rn) */ - { 0x0007, SETSSP | USES1 | USES2 }, /* mul.l rm,rn */ - { 0x000c, LOAD | SETS1 | USES2 | USESR0 }, /* mov.b @(r0,rm),rn */ - { 0x000d, LOAD | SETS1 | USES2 | USESR0 }, /* mov.w @(r0,rm),rn */ - { 0x000e, LOAD | SETS1 | USES2 | USESR0 }, /* mov.l @(r0,rm),rn */ - { 0x000f, LOAD|SETS1|SETS2|SETSSP|USES1|USES2|USESSP }, /* mac.l @rm+,@rn+ */ -}; - -static const struct sh_minor_opcode sh_opcode0[] = -{ - { MAP (sh_opcode00), 0xffff }, - { MAP (sh_opcode01), 0xf0ff }, - { MAP (sh_opcode02), 0xf00f } -}; - -static const struct sh_opcode sh_opcode10[] = -{ - { 0x1000, STORE | USES1 | USES2 } /* mov.l rm,@(disp,rn) */ -}; - -static const struct sh_minor_opcode sh_opcode1[] = -{ - { MAP (sh_opcode10), 0xf000 } -}; - -static const struct sh_opcode sh_opcode20[] = -{ - { 0x2000, STORE | USES1 | USES2 }, /* mov.b rm,@rn */ - { 0x2001, STORE | USES1 | USES2 }, /* mov.w rm,@rn */ - { 0x2002, STORE | USES1 | USES2 }, /* mov.l rm,@rn */ - { 0x2004, STORE | SETS1 | USES1 | USES2 }, /* mov.b rm,@-rn */ - { 0x2005, STORE | SETS1 | USES1 | USES2 }, /* mov.w rm,@-rn */ - { 0x2006, STORE | SETS1 | USES1 | USES2 }, /* mov.l rm,@-rn */ - { 0x2007, SETSSP | USES1 | USES2 | USESSP }, /* div0s */ - { 0x2008, SETSSP | USES1 | USES2 }, /* tst rm,rn */ - { 0x2009, SETS1 | USES1 | USES2 }, /* and rm,rn */ - { 0x200a, SETS1 | USES1 | USES2 }, /* xor rm,rn */ - { 0x200b, SETS1 | USES1 | USES2 }, /* or rm,rn */ - { 0x200c, SETSSP | USES1 | USES2 }, /* cmp/str rm,rn */ - { 0x200d, SETS1 | USES1 | USES2 }, /* xtrct rm,rn */ - { 0x200e, SETSSP | USES1 | USES2 }, /* mulu.w rm,rn */ - { 0x200f, SETSSP | USES1 | USES2 } /* muls.w rm,rn */ -}; - -static const struct sh_minor_opcode sh_opcode2[] = -{ - { MAP (sh_opcode20), 0xf00f } -}; - -static const struct sh_opcode sh_opcode30[] = -{ - { 0x3000, SETSSP | USES1 | USES2 }, /* cmp/eq rm,rn */ - { 0x3002, SETSSP | USES1 | USES2 }, /* cmp/hs rm,rn */ - { 0x3003, SETSSP | USES1 | USES2 }, /* cmp/ge rm,rn */ - { 0x3004, SETSSP | USESSP | USES1 | USES2 }, /* div1 rm,rn */ - { 0x3005, SETSSP | USES1 | USES2 }, /* dmulu.l rm,rn */ - { 0x3006, SETSSP | USES1 | USES2 }, /* cmp/hi rm,rn */ - { 0x3007, SETSSP | USES1 | USES2 }, /* cmp/gt rm,rn */ - { 0x3008, SETS1 | USES1 | USES2 }, /* sub rm,rn */ - { 0x300a, SETS1 | SETSSP | USES1 | USES2 | USESSP }, /* subc rm,rn */ - { 0x300b, SETS1 | SETSSP | USES1 | USES2 }, /* subv rm,rn */ - { 0x300c, SETS1 | USES1 | USES2 }, /* add rm,rn */ - { 0x300d, SETSSP | USES1 | USES2 }, /* dmuls.l rm,rn */ - { 0x300e, SETS1 | SETSSP | USES1 | USES2 | USESSP }, /* addc rm,rn */ - { 0x300f, SETS1 | SETSSP | USES1 | USES2 } /* addv rm,rn */ -}; - -static const struct sh_minor_opcode sh_opcode3[] = -{ - { MAP (sh_opcode30), 0xf00f } -}; - -static const struct sh_opcode sh_opcode40[] = -{ - { 0x4000, SETS1 | SETSSP | USES1 }, /* shll rn */ - { 0x4001, SETS1 | SETSSP | USES1 }, /* shlr rn */ - { 0x4002, STORE | SETS1 | USES1 | USESSP }, /* sts.l mach,@-rn */ - { 0x4003, STORE | SETS1 | USES1 | USESSP }, /* stc.l sr,@-rn */ - { 0x4004, SETS1 | SETSSP | USES1 }, /* rotl rn */ - { 0x4005, SETS1 | SETSSP | USES1 }, /* rotr rn */ - { 0x4006, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,mach */ - { 0x4007, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,sr */ - { 0x4008, SETS1 | USES1 }, /* shll2 rn */ - { 0x4009, SETS1 | USES1 }, /* shlr2 rn */ - { 0x400a, SETSSP | USES1 }, /* lds rm,mach */ - { 0x400b, BRANCH | DELAY | USES1 }, /* jsr @rn */ - { 0x400e, SETSSP | USES1 }, /* ldc rm,sr */ - { 0x4010, SETS1 | SETSSP | USES1 }, /* dt rn */ - { 0x4011, SETSSP | USES1 }, /* cmp/pz rn */ - { 0x4012, STORE | SETS1 | USES1 | USESSP }, /* sts.l macl,@-rn */ - { 0x4013, STORE | SETS1 | USES1 | USESSP }, /* stc.l gbr,@-rn */ - { 0x4015, SETSSP | USES1 }, /* cmp/pl rn */ - { 0x4016, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,macl */ - { 0x4017, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,gbr */ - { 0x4018, SETS1 | USES1 }, /* shll8 rn */ - { 0x4019, SETS1 | USES1 }, /* shlr8 rn */ - { 0x401a, SETSSP | USES1 }, /* lds rm,macl */ - { 0x401b, LOAD | SETSSP | USES1 }, /* tas.b @rn */ - { 0x401e, SETSSP | USES1 }, /* ldc rm,gbr */ - { 0x4020, SETS1 | SETSSP | USES1 }, /* shal rn */ - { 0x4021, SETS1 | SETSSP | USES1 }, /* shar rn */ - { 0x4022, STORE | SETS1 | USES1 | USESSP }, /* sts.l pr,@-rn */ - { 0x4023, STORE | SETS1 | USES1 | USESSP }, /* stc.l vbr,@-rn */ - { 0x4024, SETS1 | SETSSP | USES1 | USESSP }, /* rotcl rn */ - { 0x4025, SETS1 | SETSSP | USES1 | USESSP }, /* rotcr rn */ - { 0x4026, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,pr */ - { 0x4027, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,vbr */ - { 0x4028, SETS1 | USES1 }, /* shll16 rn */ - { 0x4029, SETS1 | USES1 }, /* shlr16 rn */ - { 0x402a, SETSSP | USES1 }, /* lds rm,pr */ - { 0x402b, BRANCH | DELAY | USES1 }, /* jmp @rn */ - { 0x402e, SETSSP | USES1 }, /* ldc rm,vbr */ - { 0x4033, STORE | SETS1 | USES1 | USESSP }, /* stc.l ssr,@-rn */ - { 0x4037, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,ssr */ - { 0x403e, SETSSP | USES1 }, /* ldc rm,ssr */ - { 0x4043, STORE | SETS1 | USES1 | USESSP }, /* stc.l spc,@-rn */ - { 0x4047, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,spc */ - { 0x404e, SETSSP | USES1 }, /* ldc rm,spc */ - { 0x4052, STORE | SETS1 | USES1 | USESSP }, /* sts.l fpul,@-rn */ - { 0x4056, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,fpul */ - { 0x405a, SETSSP | USES1 }, /* lds.l rm,fpul */ - { 0x4062, STORE | SETS1 | USES1 | USESSP }, /* sts.l fpscr,@-rn */ - { 0x4066, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,fpscr */ - { 0x406a, SETSSP | USES1 } /* lds rm,fpscr */ -}; - -static const struct sh_opcode sh_opcode41[] = -{ - { 0x4083, STORE | SETS1 | USES1 | USESSP }, /* stc.l rx_bank,@-rn */ - { 0x4087, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,rx_bank */ - { 0x408e, SETSSP | USES1 } /* ldc rm,rx_bank */ -}; - -static const struct sh_opcode sh_opcode42[] = -{ - { 0x400c, SETS1 | USES1 | USES2 }, /* shad rm,rn */ - { 0x400d, SETS1 | USES1 | USES2 }, /* shld rm,rn */ - { 0x400f, LOAD|SETS1|SETS2|SETSSP|USES1|USES2|USESSP }, /* mac.w @rm+,@rn+ */ -}; - -static const struct sh_minor_opcode sh_opcode4[] = -{ - { MAP (sh_opcode40), 0xf0ff }, - { MAP (sh_opcode41), 0xf08f }, - { MAP (sh_opcode42), 0xf00f } -}; - -static const struct sh_opcode sh_opcode50[] = -{ - { 0x5000, LOAD | SETS1 | USES2 } /* mov.l @(disp,rm),rn */ -}; - -static const struct sh_minor_opcode sh_opcode5[] = -{ - { MAP (sh_opcode50), 0xf000 } -}; - -static const struct sh_opcode sh_opcode60[] = -{ - { 0x6000, LOAD | SETS1 | USES2 }, /* mov.b @rm,rn */ - { 0x6001, LOAD | SETS1 | USES2 }, /* mov.w @rm,rn */ - { 0x6002, LOAD | SETS1 | USES2 }, /* mov.l @rm,rn */ - { 0x6003, SETS1 | USES2 }, /* mov rm,rn */ - { 0x6004, LOAD | SETS1 | SETS2 | USES2 }, /* mov.b @rm+,rn */ - { 0x6005, LOAD | SETS1 | SETS2 | USES2 }, /* mov.w @rm+,rn */ - { 0x6006, LOAD | SETS1 | SETS2 | USES2 }, /* mov.l @rm+,rn */ - { 0x6007, SETS1 | USES2 }, /* not rm,rn */ - { 0x6008, SETS1 | USES2 }, /* swap.b rm,rn */ - { 0x6009, SETS1 | USES2 }, /* swap.w rm,rn */ - { 0x600a, SETS1 | SETSSP | USES2 | USESSP }, /* negc rm,rn */ - { 0x600b, SETS1 | USES2 }, /* neg rm,rn */ - { 0x600c, SETS1 | USES2 }, /* extu.b rm,rn */ - { 0x600d, SETS1 | USES2 }, /* extu.w rm,rn */ - { 0x600e, SETS1 | USES2 }, /* exts.b rm,rn */ - { 0x600f, SETS1 | USES2 } /* exts.w rm,rn */ -}; - -static const struct sh_minor_opcode sh_opcode6[] = -{ - { MAP (sh_opcode60), 0xf00f } -}; - -static const struct sh_opcode sh_opcode70[] = -{ - { 0x7000, SETS1 | USES1 } /* add #imm,rn */ -}; - -static const struct sh_minor_opcode sh_opcode7[] = -{ - { MAP (sh_opcode70), 0xf000 } -}; - -static const struct sh_opcode sh_opcode80[] = -{ - { 0x8000, STORE | USES2 | USESR0 }, /* mov.b r0,@(disp,rn) */ - { 0x8100, STORE | USES2 | USESR0 }, /* mov.w r0,@(disp,rn) */ - { 0x8400, LOAD | SETSR0 | USES2 }, /* mov.b @(disp,rm),r0 */ - { 0x8500, LOAD | SETSR0 | USES2 }, /* mov.w @(disp,rn),r0 */ - { 0x8800, SETSSP | USESR0 }, /* cmp/eq #imm,r0 */ - { 0x8900, BRANCH | USESSP }, /* bt label */ - { 0x8b00, BRANCH | USESSP }, /* bf label */ - { 0x8d00, BRANCH | DELAY | USESSP }, /* bt/s label */ - { 0x8f00, BRANCH | DELAY | USESSP } /* bf/s label */ -}; - -static const struct sh_minor_opcode sh_opcode8[] = -{ - { MAP (sh_opcode80), 0xff00 } -}; - -static const struct sh_opcode sh_opcode90[] = -{ - { 0x9000, LOAD | SETS1 } /* mov.w @(disp,pc),rn */ -}; - -static const struct sh_minor_opcode sh_opcode9[] = -{ - { MAP (sh_opcode90), 0xf000 } -}; - -static const struct sh_opcode sh_opcodea0[] = -{ - { 0xa000, BRANCH | DELAY } /* bra label */ -}; - -static const struct sh_minor_opcode sh_opcodea[] = -{ - { MAP (sh_opcodea0), 0xf000 } -}; - -static const struct sh_opcode sh_opcodeb0[] = -{ - { 0xb000, BRANCH | DELAY } /* bsr label */ -}; - -static const struct sh_minor_opcode sh_opcodeb[] = -{ - { MAP (sh_opcodeb0), 0xf000 } -}; - -static const struct sh_opcode sh_opcodec0[] = -{ - { 0xc000, STORE | USESR0 | USESSP }, /* mov.b r0,@(disp,gbr) */ - { 0xc100, STORE | USESR0 | USESSP }, /* mov.w r0,@(disp,gbr) */ - { 0xc200, STORE | USESR0 | USESSP }, /* mov.l r0,@(disp,gbr) */ - { 0xc300, BRANCH | USESSP }, /* trapa #imm */ - { 0xc400, LOAD | SETSR0 | USESSP }, /* mov.b @(disp,gbr),r0 */ - { 0xc500, LOAD | SETSR0 | USESSP }, /* mov.w @(disp,gbr),r0 */ - { 0xc600, LOAD | SETSR0 | USESSP }, /* mov.l @(disp,gbr),r0 */ - { 0xc700, SETSR0 }, /* mova @(disp,pc),r0 */ - { 0xc800, SETSSP | USESR0 }, /* tst #imm,r0 */ - { 0xc900, SETSR0 | USESR0 }, /* and #imm,r0 */ - { 0xca00, SETSR0 | USESR0 }, /* xor #imm,r0 */ - { 0xcb00, SETSR0 | USESR0 }, /* or #imm,r0 */ - { 0xcc00, LOAD | SETSSP | USESR0 | USESSP }, /* tst.b #imm,@(r0,gbr) */ - { 0xcd00, LOAD | STORE | USESR0 | USESSP }, /* and.b #imm,@(r0,gbr) */ - { 0xce00, LOAD | STORE | USESR0 | USESSP }, /* xor.b #imm,@(r0,gbr) */ - { 0xcf00, LOAD | STORE | USESR0 | USESSP } /* or.b #imm,@(r0,gbr) */ -}; - -static const struct sh_minor_opcode sh_opcodec[] = -{ - { MAP (sh_opcodec0), 0xff00 } -}; - -static const struct sh_opcode sh_opcoded0[] = -{ - { 0xd000, LOAD | SETS1 } /* mov.l @(disp,pc),rn */ -}; - -static const struct sh_minor_opcode sh_opcoded[] = -{ - { MAP (sh_opcoded0), 0xf000 } -}; - -static const struct sh_opcode sh_opcodee0[] = -{ - { 0xe000, SETS1 } /* mov #imm,rn */ -}; - -static const struct sh_minor_opcode sh_opcodee[] = -{ - { MAP (sh_opcodee0), 0xf000 } -}; - -static const struct sh_opcode sh_opcodef0[] = -{ - { 0xf000, SETSF1 | USESF1 | USESF2 }, /* fadd fm,fn */ - { 0xf001, SETSF1 | USESF1 | USESF2 }, /* fsub fm,fn */ - { 0xf002, SETSF1 | USESF1 | USESF2 }, /* fmul fm,fn */ - { 0xf003, SETSF1 | USESF1 | USESF2 }, /* fdiv fm,fn */ - { 0xf004, SETSSP | USESF1 | USESF2 }, /* fcmp/eq fm,fn */ - { 0xf005, SETSSP | USESF1 | USESF2 }, /* fcmp/gt fm,fn */ - { 0xf006, LOAD | SETSF1 | USES2 | USESR0 }, /* fmov.s @(r0,rm),fn */ - { 0xf007, STORE | USES1 | USESF2 | USESR0 }, /* fmov.s fm,@(r0,rn) */ - { 0xf008, LOAD | SETSF1 | USES2 }, /* fmov.s @rm,fn */ - { 0xf009, LOAD | SETS2 | SETSF1 | USES2 }, /* fmov.s @rm+,fn */ - { 0xf00a, STORE | USES1 | USESF2 }, /* fmov.s fm,@rn */ - { 0xf00b, STORE | SETS1 | USES1 | USESF2 }, /* fmov.s fm,@-rn */ - { 0xf00c, SETSF1 | USESF2 }, /* fmov fm,fn */ - { 0xf00e, SETSF1 | USESF1 | USESF2 | USESF0 } /* fmac f0,fm,fn */ -}; - -static const struct sh_opcode sh_opcodef1[] = -{ - { 0xf00d, SETSF1 | USESSP }, /* fsts fpul,fn */ - { 0xf01d, SETSSP | USESF1 }, /* flds fn,fpul */ - { 0xf02d, SETSF1 | USESSP }, /* float fpul,fn */ - { 0xf03d, SETSSP | USESF1 }, /* ftrc fn,fpul */ - { 0xf04d, SETSF1 | USESF1 }, /* fneg fn */ - { 0xf05d, SETSF1 | USESF1 }, /* fabs fn */ - { 0xf06d, SETSF1 | USESF1 }, /* fsqrt fn */ - { 0xf07d, SETSSP | USESF1 }, /* ftst/nan fn */ - { 0xf08d, SETSF1 }, /* fldi0 fn */ - { 0xf09d, SETSF1 } /* fldi1 fn */ -}; - -static const struct sh_minor_opcode sh_opcodef[] = -{ - { MAP (sh_opcodef0), 0xf00f }, - { MAP (sh_opcodef1), 0xf0ff } -}; - -static const struct sh_major_opcode sh_opcodes[] = -{ - { MAP (sh_opcode0) }, - { MAP (sh_opcode1) }, - { MAP (sh_opcode2) }, - { MAP (sh_opcode3) }, - { MAP (sh_opcode4) }, - { MAP (sh_opcode5) }, - { MAP (sh_opcode6) }, - { MAP (sh_opcode7) }, - { MAP (sh_opcode8) }, - { MAP (sh_opcode9) }, - { MAP (sh_opcodea) }, - { MAP (sh_opcodeb) }, - { MAP (sh_opcodec) }, - { MAP (sh_opcoded) }, - { MAP (sh_opcodee) }, - { MAP (sh_opcodef) } -}; - -/* Given an instruction, return a pointer to the corresponding - sh_opcode structure. Return NULL if the instruction is not - recognized. */ - -static const struct sh_opcode * -sh_insn_info (insn) - unsigned int insn; -{ - const struct sh_major_opcode *maj; - const struct sh_minor_opcode *min, *minend; - - maj = &sh_opcodes[(insn & 0xf000) >> 12]; - min = maj->minor_opcodes; - minend = min + maj->count; - for (; min < minend; min++) - { - unsigned int l; - const struct sh_opcode *op, *opend; - - l = insn & min->mask; - op = min->opcodes; - opend = op + min->count; - - /* Since the opcodes tables are sorted, we could use a binary - search here if the count were above some cutoff value. */ - for (; op < opend; op++) - if (op->opcode == l) - return op; - } - - return NULL; -} - -/* See whether an instruction uses a general purpose register. */ - -static boolean -sh_insn_uses_reg (insn, op, reg) - unsigned int insn; - const struct sh_opcode *op; - unsigned int reg; -{ - unsigned int f; - - f = op->flags; - - if ((f & USES1) != 0 - && ((insn & 0x0f00) >> 8) == reg) - return true; - if ((f & USES2) != 0 - && ((insn & 0x00f0) >> 4) == reg) - return true; - if ((f & USESR0) != 0 - && reg == 0) - return true; - - return false; -} - -/* See whether an instruction uses a floating point register. */ - -static boolean -sh_insn_uses_freg (insn, op, freg) - unsigned int insn; - const struct sh_opcode *op; - unsigned int freg; -{ - unsigned int f; - - f = op->flags; - - if ((f & USESF1) != 0 - && ((insn & 0x0f00) >> 8) == freg) - return true; - if ((f & USESF2) != 0 - && ((insn & 0x00f0) >> 4) == freg) - return true; - if ((f & USESF0) != 0 - && freg == 0) - return true; - - return false; -} - -/* See whether instructions I1 and I2 conflict, assuming I1 comes - before I2. OP1 and OP2 are the corresponding sh_opcode structures. - This should return true if there is a conflict, or false if the - instructions can be swapped safely. */ - -static boolean -sh_insns_conflict (i1, op1, i2, op2) - unsigned int i1; - const struct sh_opcode *op1; - unsigned int i2; - const struct sh_opcode *op2; -{ - unsigned int f1, f2; - - f1 = op1->flags; - f2 = op2->flags; - - if ((f1 & (BRANCH | DELAY)) != 0 - || (f2 & (BRANCH | DELAY)) != 0) - return true; - - if ((f1 & SETSSP) != 0 && (f2 & USESSP) != 0) - return true; - if ((f2 & SETSSP) != 0 && (f1 & USESSP) != 0) - return true; - - if ((f1 & SETS1) != 0 - && sh_insn_uses_reg (i2, op2, (i1 & 0x0f00) >> 8)) - return true; - if ((f1 & SETS2) != 0 - && sh_insn_uses_reg (i2, op2, (i1 & 0x00f0) >> 4)) - return true; - if ((f1 & SETSR0) != 0 - && sh_insn_uses_reg (i2, op2, 0)) - return true; - if ((f1 & SETSF1) != 0 - && sh_insn_uses_freg (i2, op2, (i1 & 0x0f00) >> 8)) - return true; - - if ((f2 & SETS1) != 0 - && sh_insn_uses_reg (i1, op1, (i2 & 0x0f00) >> 8)) - return true; - if ((f2 & SETS2) != 0 - && sh_insn_uses_reg (i1, op1, (i2 & 0x00f0) >> 4)) - return true; - if ((f2 & SETSR0) != 0 - && sh_insn_uses_reg (i1, op1, 0)) - return true; - if ((f2 & SETSF1) != 0 - && sh_insn_uses_freg (i1, op1, (i2 & 0x0f00) >> 8)) - return true; - - /* The instructions do not conflict. */ - return false; -} - -/* I1 is a load instruction, and I2 is some other instruction. Return - true if I1 loads a register which I2 uses. */ - -static boolean -sh_load_use (i1, op1, i2, op2) - unsigned int i1; - const struct sh_opcode *op1; - unsigned int i2; - const struct sh_opcode *op2; -{ - unsigned int f1; - - f1 = op1->flags; - - if ((f1 & LOAD) == 0) - return false; - - /* If both SETS1 and SETSSP are set, that means a load to a special - register using postincrement addressing mode, which we don't care - about here. */ - if ((f1 & SETS1) != 0 - && (f1 & SETSSP) == 0 - && sh_insn_uses_reg (i2, op2, (i1 & 0x0f00) >> 8)) - return true; - - if ((f1 & SETSR0) != 0 - && sh_insn_uses_reg (i2, op2, 0)) - return true; - - if ((f1 & SETSF1) != 0 - && sh_insn_uses_freg (i2, op2, (i1 & 0x0f00) >> 8)) - return true; - - return false; -} - -/* Try to align loads and stores within a span of memory. This is - called by both the ELF and the COFF sh targets. ABFD and SEC are - the BFD and section we are examining. CONTENTS is the contents of - the section. SWAP is the routine to call to swap two instructions. - RELOCS is a pointer to the internal relocation information, to be - passed to SWAP. PLABEL is a pointer to the current label in a - sorted list of labels; LABEL_END is the end of the list. START and - STOP are the range of memory to examine. If a swap is made, - *PSWAPPED is set to true. */ - -boolean -_bfd_sh_align_load_span (abfd, sec, contents, swap, relocs, - plabel, label_end, start, stop, pswapped) - bfd *abfd; - asection *sec; - bfd_byte *contents; - boolean (*swap) PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma)); - PTR relocs; - bfd_vma **plabel; - bfd_vma *label_end; - bfd_vma start; - bfd_vma stop; - boolean *pswapped; -{ - bfd_vma i; - - /* Instructions should be aligned on 2 byte boundaries. */ - if ((start & 1) == 1) - ++start; - - /* Now look through the unaligned addresses. */ - i = start; - if ((i & 2) == 0) - i += 2; - for (; i < stop; i += 4) - { - unsigned int insn; - const struct sh_opcode *op; - unsigned int prev_insn = 0; - const struct sh_opcode *prev_op = NULL; - - insn = bfd_get_16 (abfd, contents + i); - op = sh_insn_info (insn); - if (op == NULL - || (op->flags & (LOAD | STORE)) == 0) - continue; - - /* This is a load or store which is not on a four byte boundary. */ - - while (*plabel < label_end && **plabel < i) - ++*plabel; - - if (i > start) - { - prev_insn = bfd_get_16 (abfd, contents + i - 2); - prev_op = sh_insn_info (prev_insn); - - /* If the load/store instruction is in a delay slot, we - can't swap. */ - if (prev_op == NULL - || (prev_op->flags & DELAY) != 0) - continue; - } - if (i > start - && (*plabel >= label_end || **plabel != i) - && prev_op != NULL - && (prev_op->flags & (LOAD | STORE)) == 0 - && ! sh_insns_conflict (prev_insn, prev_op, insn, op)) - { - boolean ok; - - /* The load/store instruction does not have a label, and - there is a previous instruction; PREV_INSN is not - itself a load/store instruction, and PREV_INSN and - INSN do not conflict. */ - - ok = true; - - if (i >= start + 4) - { - unsigned int prev2_insn; - const struct sh_opcode *prev2_op; - - prev2_insn = bfd_get_16 (abfd, contents + i - 4); - prev2_op = sh_insn_info (prev2_insn); - - /* If the instruction before PREV_INSN has a delay - slot--that is, PREV_INSN is in a delay slot--we - can not swap. */ - if (prev2_op == NULL - || (prev2_op->flags & DELAY) != 0) - ok = false; - - /* If the instruction before PREV_INSN is a load, - and it sets a register which INSN uses, then - putting INSN immediately after PREV_INSN will - cause a pipeline bubble, so there is no point to - making the swap. */ - if (ok - && (prev2_op->flags & LOAD) != 0 - && sh_load_use (prev2_insn, prev2_op, insn, op)) - ok = false; - } - - if (ok) - { - if (! (*swap) (abfd, sec, relocs, contents, i - 2)) - return false; - *pswapped = true; - continue; - } - } - - while (*plabel < label_end && **plabel < i + 2) - ++*plabel; - - if (i + 2 < stop - && (*plabel >= label_end || **plabel != i + 2)) - { - unsigned int next_insn; - const struct sh_opcode *next_op; - - /* There is an instruction after the load/store - instruction, and it does not have a label. */ - next_insn = bfd_get_16 (abfd, contents + i + 2); - next_op = sh_insn_info (next_insn); - if (next_op != NULL - && (next_op->flags & (LOAD | STORE)) == 0 - && ! sh_insns_conflict (insn, op, next_insn, next_op)) - { - boolean ok; - - /* NEXT_INSN is not itself a load/store instruction, - and it does not conflict with INSN. */ - - ok = true; - - /* If PREV_INSN is a load, and it sets a register - which NEXT_INSN uses, then putting NEXT_INSN - immediately after PREV_INSN will cause a pipeline - bubble, so there is no reason to make this swap. */ - if (prev_op != NULL - && (prev_op->flags & LOAD) != 0 - && sh_load_use (prev_insn, prev_op, next_insn, next_op)) - ok = false; - - /* If INSN is a load, and it sets a register which - the insn after NEXT_INSN uses, then doing the - swap will cause a pipeline bubble, so there is no - reason to make the swap. However, if the insn - after NEXT_INSN is itself a load or store - instruction, then it is misaligned, so - optimistically hope that it will be swapped - itself, and just live with the pipeline bubble if - it isn't. */ - if (ok - && i + 4 < stop - && (op->flags & LOAD) != 0) - { - unsigned int next2_insn; - const struct sh_opcode *next2_op; - - next2_insn = bfd_get_16 (abfd, contents + i + 4); - next2_op = sh_insn_info (next2_insn); - if ((next2_op->flags & (LOAD | STORE)) == 0 - && sh_load_use (insn, op, next2_insn, next2_op)) - ok = false; - } - - if (ok) - { - if (! (*swap) (abfd, sec, relocs, contents, i)) - return false; - *pswapped = true; - continue; - } - } - } - } - - return true; -} - -/* Look for loads and stores which we can align to four byte - boundaries. See the longer comment above sh_relax_section for why - this is desirable. This sets *PSWAPPED if some instruction was - swapped. */ - -static boolean -sh_align_loads (abfd, sec, internal_relocs, contents, pswapped) - bfd *abfd; - asection *sec; - struct internal_reloc *internal_relocs; - bfd_byte *contents; - boolean *pswapped; -{ - struct internal_reloc *irel, *irelend; - bfd_vma *labels = NULL; - bfd_vma *label, *label_end; - - *pswapped = false; - - irelend = internal_relocs + sec->reloc_count; - - /* Get all the addresses with labels on them. */ - labels = (bfd_vma *) bfd_malloc (sec->reloc_count * sizeof (bfd_vma)); - if (labels == NULL) - goto error_return; - label_end = labels; - for (irel = internal_relocs; irel < irelend; irel++) - { - if (irel->r_type == R_SH_LABEL) - { - *label_end = irel->r_vaddr - sec->vma; - ++label_end; - } - } - - /* Note that the assembler currently always outputs relocs in - address order. If that ever changes, this code will need to sort - the label values and the relocs. */ - - label = labels; - - for (irel = internal_relocs; irel < irelend; irel++) - { - bfd_vma start, stop; - - if (irel->r_type != R_SH_CODE) - continue; - - start = irel->r_vaddr - sec->vma; - - for (irel++; irel < irelend; irel++) - if (irel->r_type == R_SH_DATA) - break; - if (irel < irelend) - stop = irel->r_vaddr - sec->vma; - else - stop = sec->_cooked_size; - - if (! _bfd_sh_align_load_span (abfd, sec, contents, sh_swap_insns, - (PTR) internal_relocs, &label, - label_end, start, stop, pswapped)) - goto error_return; - } - - free (labels); - - return true; - - error_return: - if (labels != NULL) - free (labels); - return false; -} - -/* Swap two SH instructions. */ - -static boolean -sh_swap_insns (abfd, sec, relocs, contents, addr) - bfd *abfd; - asection *sec; - PTR relocs; - bfd_byte *contents; - bfd_vma addr; -{ - struct internal_reloc *internal_relocs = (struct internal_reloc *) relocs; - unsigned short i1, i2; - struct internal_reloc *irel, *irelend; - - /* Swap the instructions themselves. */ - i1 = bfd_get_16 (abfd, contents + addr); - i2 = bfd_get_16 (abfd, contents + addr + 2); - bfd_put_16 (abfd, i2, contents + addr); - bfd_put_16 (abfd, i1, contents + addr + 2); - - /* Adjust all reloc addresses. */ - irelend = internal_relocs + sec->reloc_count; - for (irel = internal_relocs; irel < irelend; irel++) - { - int type, add; - - /* There are a few special types of relocs that we don't want to - adjust. These relocs do not apply to the instruction itself, - but are only associated with the address. */ - type = irel->r_type; - if (type == R_SH_ALIGN - || type == R_SH_CODE - || type == R_SH_DATA - || type == R_SH_LABEL) - continue; - - /* If an R_SH_USES reloc points to one of the addresses being - swapped, we must adjust it. It would be incorrect to do this - for a jump, though, since we want to execute both - instructions after the jump. (We have avoided swapping - around a label, so the jump will not wind up executing an - instruction it shouldn't). */ - if (type == R_SH_USES) - { - bfd_vma off; - - off = irel->r_vaddr - sec->vma + 4 + irel->r_offset; - if (off == addr) - irel->r_offset += 2; - else if (off == addr + 2) - irel->r_offset -= 2; - } - - if (irel->r_vaddr - sec->vma == addr) - { - irel->r_vaddr += 2; - add = -2; - } - else if (irel->r_vaddr - sec->vma == addr + 2) - { - irel->r_vaddr -= 2; - add = 2; - } - else - add = 0; - - if (add != 0) - { - bfd_byte *loc; - unsigned short insn, oinsn; - boolean overflow; - - loc = contents + irel->r_vaddr - sec->vma; - overflow = false; - switch (type) - { - default: - break; - - case R_SH_PCDISP8BY2: - case R_SH_PCRELIMM8BY2: - insn = bfd_get_16 (abfd, loc); - oinsn = insn; - insn += add / 2; - if ((oinsn & 0xff00) != (insn & 0xff00)) - overflow = true; - bfd_put_16 (abfd, insn, loc); - break; - - case R_SH_PCDISP: - insn = bfd_get_16 (abfd, loc); - oinsn = insn; - insn += add / 2; - if ((oinsn & 0xf000) != (insn & 0xf000)) - overflow = true; - bfd_put_16 (abfd, insn, loc); - break; - - case R_SH_PCRELIMM8BY4: - /* This reloc ignores the least significant 3 bits of - the program counter before adding in the offset. - This means that if ADDR is at an even address, the - swap will not affect the offset. If ADDR is an at an - odd address, then the instruction will be crossing a - four byte boundary, and must be adjusted. */ - if ((addr & 3) != 0) - { - insn = bfd_get_16 (abfd, loc); - oinsn = insn; - insn += add / 2; - if ((oinsn & 0xff00) != (insn & 0xff00)) - overflow = true; - bfd_put_16 (abfd, insn, loc); - } - - 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; - } - } - } - - 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 - { - if (symndx < 0 - || (unsigned long) symndx >= obj_raw_syment_count (input_bfd)) - { - (*_bfd_error_handler) - ("%s: illegal symbol index %ld in relocs", - bfd_get_filename (input_bfd), symndx); - bfd_set_error (bfd_error_bad_value); - return false; - } - h = obj_coff_sym_hashes (input_bfd)[symndx]; - sym = syms + symndx; - } - - 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, -}; - -/* Some people want versions of the SH COFF target which do not align - to 16 byte boundaries. We implement that by adding a couple of new - target vectors. These are just like the ones above, but they - change the default section alignment. To generate them in the - assembler, use -small. To use them in the linker, use -b - coff-sh{l}-small and -oformat coff-sh{l}-small. - - Yes, this is a horrible hack. A general solution for setting - section alignment in COFF is rather complex. ELF handles this - correctly. */ - -/* Only recognize the small versions if the target was not defaulted. - Otherwise we won't recognize the non default endianness. */ - -static const bfd_target * -coff_small_object_p (abfd) - bfd *abfd; -{ - if (abfd->target_defaulted) - { - bfd_set_error (bfd_error_wrong_format); - return NULL; - } - return coff_object_p (abfd); -} - -/* Set the section alignment for the small versions. */ - -static boolean -coff_small_new_section_hook (abfd, section) - bfd *abfd; - asection *section; -{ - if (! coff_new_section_hook (abfd, section)) - return false; - - /* We must align to at least a four byte boundary, because longword - accesses must be on a four byte boundary. */ - if (section->alignment_power == COFF_DEFAULT_SECTION_ALIGNMENT_POWER) - section->alignment_power = 2; - - return true; -} - -/* This is copied from bfd_coff_std_swap_table so that we can change - the default section alignment power. */ - -static const bfd_coff_backend_data bfd_coff_small_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 -#ifdef COFF_LONG_SECTION_NAMES - true, -#else - false, -#endif - 2, - 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, - coff_link_output_has_begun, coff_final_link_postscript -}; - -#define coff_small_close_and_cleanup \ - coff_close_and_cleanup -#define coff_small_bfd_free_cached_info \ - coff_bfd_free_cached_info -#define coff_small_get_section_contents \ - coff_get_section_contents -#define coff_small_get_section_contents_in_window \ - coff_get_section_contents_in_window - -const bfd_target shcoff_small_vec = -{ - "coff-sh-small", /* 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_small_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_small), - 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), - - (PTR) &bfd_coff_small_swap_table -}; - -const bfd_target shlcoff_small_vec = -{ - "coff-shl-small", /* 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_small_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_small), - 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), - - (PTR) &bfd_coff_small_swap_table -}; diff --git a/contrib/binutils/bfd/cpu-sh.c b/contrib/binutils/bfd/cpu-sh.c deleted file mode 100644 index 9f7ef2021421..000000000000 --- a/contrib/binutils/bfd/cpu-sh.c +++ /dev/null @@ -1,117 +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" - - -static boolean -scan_mach (info, string) - const struct bfd_arch_info *info; - const char *string; -{ - if (strcasecmp (info->printable_name, string) == 0) - return true; - return false; -} - - -#if 0 -/* This routine is provided two arch_infos and returns whether - they'd be compatible */ - -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 - -#define SH_NEXT &arch_info_struct[0] -#define SH3_NEXT &arch_info_struct[1] -#define SH3E_NEXT &arch_info_struct[2] -#define SH4_NEXT NULL - -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_sh, - bfd_mach_sh3, - "sh", /* arch_name */ - "sh3", /* printable name */ - 1, - false, /* not the default */ - bfd_default_compatible, - scan_mach, - SH3_NEXT - }, - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_sh, - bfd_mach_sh3e, - "sh", /* arch_name */ - "sh3e", /* printable name */ - 1, - false, /* not the default */ - bfd_default_compatible, - scan_mach, - SH3E_NEXT - }, - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_sh, - bfd_mach_sh4, - "sh", /* arch_name */ - "sh4", /* printable name */ - 1, - false, /* not the default */ - bfd_default_compatible, - scan_mach, - SH4_NEXT - }, -}; - -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, - bfd_mach_sh, - "sh", /* arch_name */ - "sh", /* printable name */ - 1, - true, /* the default machine */ - bfd_default_compatible, - scan_mach, - SH_NEXT -}; diff --git a/contrib/binutils/bfd/doc/aoutx.texi b/contrib/binutils/bfd/doc/aoutx.texi deleted file mode 100644 index d97e96aeb793..000000000000 --- a/contrib/binutils/bfd/doc/aoutx.texi +++ /dev/null @@ -1,211 +0,0 @@ -@section a.out backends - - -@strong{Description}@* -BFD supports a number of different flavours of a.out format, -though the major differences are only the sizes of the -structures on disk, and the shape of the relocation -information. - -The support is split into a basic support file @file{aoutx.h} -and other files which derive functions from the base. One -derivation file is @file{aoutf1.h} (for a.out flavour 1), and -adds to the basic a.out functions support for sun3, sun4, 386 -and 29k a.out files, to create a target jump vector for a -specific target. - -This information is further split out into more specific files -for each machine, including @file{sunos.c} for sun3 and sun4, -@file{newsos3.c} for the Sony NEWS, and @file{demo64.c} for a -demonstration of a 64 bit a.out format. - -The base file @file{aoutx.h} defines general mechanisms for -reading and writing records to and from disk and various -other methods which BFD requires. It is included by -@file{aout32.c} and @file{aout64.c} to form the names -@code{aout_32_swap_exec_header_in}, @code{aout_64_swap_exec_header_in}, etc. - -As an example, this is what goes on to make the back end for a -sun4, from @file{aout32.c}: - -@example - #define ARCH_SIZE 32 - #include "aoutx.h" -@end example - -Which exports names: - -@example - ... - aout_32_canonicalize_reloc - aout_32_find_nearest_line - aout_32_get_lineno - aout_32_get_reloc_upper_bound - ... -@end example - -from @file{sunos.c}: - -@example - #define TARGET_NAME "a.out-sunos-big" - #define VECNAME sunos_big_vec - #include "aoutf1.h" -@end example - -requires all the names from @file{aout32.c}, and produces the jump vector - -@example - sunos_big_vec -@end example - -The file @file{host-aout.c} is a special case. It is for a large set -of hosts that use ``more or less standard'' a.out files, and -for which cross-debugging is not interesting. It uses the -standard 32-bit a.out support routines, but determines the -file offsets and addresses of the text, data, and BSS -sections, the machine architecture and machine type, and the -entry point address, in a host-dependent manner. Once these -values have been determined, generic code is used to handle -the object file. - -When porting it to run on a new system, you must supply: - -@example - HOST_PAGE_SIZE - HOST_SEGMENT_SIZE - HOST_MACHINE_ARCH (optional) - HOST_MACHINE_MACHINE (optional) - HOST_TEXT_START_ADDR - HOST_STACK_END_ADDR -@end example - -in the file @file{../include/sys/h-@var{XXX}.h} (for your host). These -values, plus the structures and macros defined in @file{a.out.h} on -your host system, will produce a BFD target that will access -ordinary a.out files on your host. To configure a new machine -to use @file{host-aout.c}, specify: - -@example - TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec - TDEPFILES= host-aout.o trad-core.o -@end example - -in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in} -to use the -@file{@var{XXX}.mt} file (by setting "@code{bfd_target=XXX}") when your -configuration is selected. - -@subsection Relocations - - -@strong{Description}@* -The file @file{aoutx.h} provides for both the @emph{standard} -and @emph{extended} forms of a.out relocation records. - -The standard records contain only an -address, a symbol index, and a type field. The extended records -(used on 29ks and sparcs) also have a full integer for an -addend. - -@subsection Internal entry points - - -@strong{Description}@* -@file{aoutx.h} exports several routines for accessing the -contents of an a.out file, which are gathered and exported in -turn by various format specific files (eg sunos.c). - -@findex aout_@var{size}_swap_exec_header_in -@subsubsection @code{aout_@var{size}_swap_exec_header_in} -@strong{Synopsis} -@example -void aout_@var{size}_swap_exec_header_in, - (bfd *abfd, - struct external_exec *raw_bytes, - struct internal_exec *execp); -@end example -@strong{Description}@* -Swap the information in an executable header @var{raw_bytes} taken -from a raw byte stream memory image into the internal exec header -structure @var{execp}. - -@findex aout_@var{size}_swap_exec_header_out -@subsubsection @code{aout_@var{size}_swap_exec_header_out} -@strong{Synopsis} -@example -void aout_@var{size}_swap_exec_header_out - (bfd *abfd, - struct internal_exec *execp, - struct external_exec *raw_bytes); -@end example -@strong{Description}@* -Swap the information in an internal exec header structure -@var{execp} into the buffer @var{raw_bytes} ready for writing to disk. - -@findex aout_@var{size}_some_aout_object_p -@subsubsection @code{aout_@var{size}_some_aout_object_p} -@strong{Synopsis} -@example -const bfd_target *aout_@var{size}_some_aout_object_p - (bfd *abfd, - const bfd_target *(*callback_to_real_object_p)()); -@end example -@strong{Description}@* -Some a.out variant thinks that the file open in @var{abfd} -checking is an a.out file. Do some more checking, and set up -for access if it really is. Call back to the calling -environment's "finish up" function just before returning, to -handle any last-minute setup. - -@findex aout_@var{size}_mkobject -@subsubsection @code{aout_@var{size}_mkobject} -@strong{Synopsis} -@example -boolean aout_@var{size}_mkobject, (bfd *abfd); -@end example -@strong{Description}@* -Initialize BFD @var{abfd} for use with a.out files. - -@findex aout_@var{size}_machine_type -@subsubsection @code{aout_@var{size}_machine_type} -@strong{Synopsis} -@example -enum machine_type aout_@var{size}_machine_type - (enum bfd_architecture arch, - unsigned long machine)); -@end example -@strong{Description}@* -Keep track of machine architecture and machine type for -a.out's. Return the @code{machine_type} for a particular -architecture and machine, or @code{M_UNKNOWN} if that exact architecture -and machine can't be represented in a.out format. - -If the architecture is understood, machine type 0 (default) -is always understood. - -@findex aout_@var{size}_set_arch_mach -@subsubsection @code{aout_@var{size}_set_arch_mach} -@strong{Synopsis} -@example -boolean aout_@var{size}_set_arch_mach, - (bfd *, - enum bfd_architecture arch, - unsigned long machine)); -@end example -@strong{Description}@* -Set the architecture and the machine of the BFD @var{abfd} to the -values @var{arch} and @var{machine}. Verify that @var{abfd}'s format -can support the architecture required. - -@findex aout_@var{size}_new_section_hook -@subsubsection @code{aout_@var{size}_new_section_hook} -@strong{Synopsis} -@example -boolean aout_@var{size}_new_section_hook, - (bfd *abfd, - asection *newsect)); -@end example -@strong{Description}@* -Called by the BFD in response to a @code{bfd_make_section} -request. - diff --git a/contrib/binutils/bfd/doc/archive.texi b/contrib/binutils/bfd/doc/archive.texi deleted file mode 100644 index 7e91a1690c8b..000000000000 --- a/contrib/binutils/bfd/doc/archive.texi +++ /dev/null @@ -1,95 +0,0 @@ -@section Archives - - -@strong{Description}@* -An archive (or library) is just another BFD. It has a symbol -table, although there's not much a user program will do with it. - -The big difference between an archive BFD and an ordinary BFD -is that the archive doesn't have sections. Instead it has a -chain of BFDs that are considered its contents. These BFDs can -be manipulated like any other. The BFDs contained in an -archive opened for reading will all be opened for reading. You -may put either input or output BFDs into an archive opened for -output; they will be handled correctly when the archive is closed. - -Use @code{bfd_openr_next_archived_file} to step through -the contents of an archive opened for input. You don't -have to read the entire archive if you don't want -to! Read it until you find what you want. - -Archive contents of output BFDs are chained through the -@code{next} pointer in a BFD. The first one is findable through -the @code{archive_head} slot of the archive. Set it with -@code{bfd_set_archive_head} (q.v.). A given BFD may be in only one -open output archive at a time. - -As expected, the BFD archive code is more general than the -archive code of any given environment. BFD archives may -contain files of different formats (e.g., a.out and coff) and -even different architectures. You may even place archives -recursively into archives! - -This can cause unexpected confusion, since some archive -formats are more expressive than others. For instance, Intel -COFF archives can preserve long filenames; SunOS a.out archives -cannot. If you move a file from the first to the second -format and back again, the filename may be truncated. -Likewise, different a.out environments have different -conventions as to how they truncate filenames, whether they -preserve directory names in filenames, etc. When -interoperating with native tools, be sure your files are -homogeneous. - -Beware: most of these formats do not react well to the -presence of spaces in filenames. We do the best we can, but -can't always handle this case due to restrictions in the format of -archives. Many Unix utilities are braindead in regards to -spaces and such in filenames anyway, so this shouldn't be much -of a restriction. - -Archives are supported in BFD in @code{archive.c}. - -@findex bfd_get_next_mapent -@subsubsection @code{bfd_get_next_mapent} -@strong{Synopsis} -@example -symindex bfd_get_next_mapent(bfd *abfd, symindex previous, carsym **sym); -@end example -@strong{Description}@* -Step through archive @var{abfd}'s symbol table (if it -has one). Successively update @var{sym} with the next symbol's -information, returning that symbol's (internal) index into the -symbol table. - -Supply @code{BFD_NO_MORE_SYMBOLS} as the @var{previous} entry to get -the first one; returns @code{BFD_NO_MORE_SYMBOLS} when you've already -got the last one. - -A @code{carsym} is a canonical archive symbol. The only -user-visible element is its name, a null-terminated string. - -@findex bfd_set_archive_head -@subsubsection @code{bfd_set_archive_head} -@strong{Synopsis} -@example -boolean bfd_set_archive_head(bfd *output, bfd *new_head); -@end example -@strong{Description}@* -Set the head of the chain of -BFDs contained in the archive @var{output} to @var{new_head}. - -@findex bfd_openr_next_archived_file -@subsubsection @code{bfd_openr_next_archived_file} -@strong{Synopsis} -@example -bfd *bfd_openr_next_archived_file(bfd *archive, bfd *previous); -@end example -@strong{Description}@* -Provided a BFD, @var{archive}, containing an archive and NULL, open -an input BFD on the first contained element and returns that. -Subsequent calls should pass -the archive and the previous return value to return a created -BFD to the next contained element. NULL is returned when there -are no more. - diff --git a/contrib/binutils/bfd/doc/archures.texi b/contrib/binutils/bfd/doc/archures.texi deleted file mode 100644 index c555ea733ca0..000000000000 --- a/contrib/binutils/bfd/doc/archures.texi +++ /dev/null @@ -1,354 +0,0 @@ -@section Architectures -BFD keeps one atom in a BFD describing the -architecture of the data attached to the BFD: a pointer to a -@code{bfd_arch_info_type}. - -Pointers to structures can be requested independently of a BFD -so that an architecture's information can be interrogated -without access to an open BFD. - -The architecture information is provided by each architecture package. -The set of default architectures is selected by the macro -@code{SELECT_ARCHITECTURES}. This is normally set up in the -@file{config/@var{target}.mt} file of your choice. If the name is not -defined, then all the architectures supported are included. - -When BFD starts up, all the architectures are called with an -initialize method. It is up to the architecture back end to -insert as many items into the list of architectures as it wants to; -generally this would be one for each machine and one for the -default case (an item with a machine field of 0). - -BFD's idea of an architecture is implemented in @file{archures.c}. - -@subsection bfd_architecture - - -@strong{Description}@* -This enum gives the object file's CPU architecture, in a -global sense---i.e., what processor family does it belong to? -Another field indicates which processor within -the family is in use. The machine gives a number which -distinguishes different versions of the architecture, -containing, for example, 2 and 3 for Intel i960 KA and i960 KB, -and 68020 and 68030 for Motorola 68020 and 68030. -@example -enum bfd_architecture -@{ - bfd_arch_unknown, /* File arch not known */ - bfd_arch_obscure, /* Arch known, not one of these */ - bfd_arch_m68k, /* Motorola 68xxx */ -#define bfd_mach_m68000 1 -#define bfd_mach_m68008 2 -#define bfd_mach_m68010 3 -#define bfd_mach_m68020 4 -#define bfd_mach_m68030 5 -#define bfd_mach_m68040 6 -#define bfd_mach_m68060 7 - bfd_arch_vax, /* DEC Vax */ - bfd_arch_i960, /* Intel 960 */ - /* The order of the following is important. - lower number indicates a machine type that - only accepts a subset of the instructions - available to machines with higher numbers. - The exception is the "ca", which is - incompatible with all other machines except - "core". */ - -#define bfd_mach_i960_core 1 -#define bfd_mach_i960_ka_sa 2 -#define bfd_mach_i960_kb_sb 3 -#define bfd_mach_i960_mc 4 -#define bfd_mach_i960_xa 5 -#define bfd_mach_i960_ca 6 -#define bfd_mach_i960_jx 7 -#define bfd_mach_i960_hx 8 - - bfd_arch_a29k, /* AMD 29000 */ - bfd_arch_sparc, /* SPARC */ -#define bfd_mach_sparc 1 - /* The difference between v8plus and v9 is that v9 is a true 64 bit env. */ -#define bfd_mach_sparc_sparclet 2 -#define bfd_mach_sparc_sparclite 3 -#define bfd_mach_sparc_v8plus 4 -#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns */ -#define bfd_mach_sparc_v9 6 -#define bfd_mach_sparc_v9a 7 /* with ultrasparc add'ns */ - /* Nonzero if MACH has the v9 instruction set. */ -#define bfd_mach_sparc_v9_p(mach) \ - ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9a) - bfd_arch_mips, /* MIPS Rxxxx */ -#define bfd_mach_mips3000 3000 -#define bfd_mach_mips3900 3900 -#define bfd_mach_mips4000 4000 -#define bfd_mach_mips4010 4010 -#define bfd_mach_mips4100 4100 -#define bfd_mach_mips4300 4300 -#define bfd_mach_mips4400 4400 -#define bfd_mach_mips4600 4600 -#define bfd_mach_mips4650 4650 -#define bfd_mach_mips5000 5000 -#define bfd_mach_mips6000 6000 -#define bfd_mach_mips8000 8000 -#define bfd_mach_mips10000 10000 -#define bfd_mach_mips16 16 - bfd_arch_i386, /* Intel 386 */ -#define bfd_mach_i386_i386 0 -#define bfd_mach_i386_i8086 1 - bfd_arch_we32k, /* AT&T WE32xxx */ - bfd_arch_tahoe, /* CCI/Harris Tahoe */ - bfd_arch_i860, /* Intel 860 */ - bfd_arch_romp, /* IBM ROMP PC/RT */ - bfd_arch_alliant, /* Alliant */ - bfd_arch_convex, /* Convex */ - bfd_arch_m88k, /* Motorola 88xxx */ - bfd_arch_pyramid, /* Pyramid Technology */ - bfd_arch_h8300, /* Hitachi H8/300 */ -#define bfd_mach_h8300 1 -#define bfd_mach_h8300h 2 -#define bfd_mach_h8300s 3 - bfd_arch_powerpc, /* PowerPC */ - bfd_arch_rs6000, /* IBM RS/6000 */ - bfd_arch_hppa, /* HP PA RISC */ - bfd_arch_d10v, /* Mitsubishi D10V */ - bfd_arch_z8k, /* Zilog Z8000 */ -#define bfd_mach_z8001 1 -#define bfd_mach_z8002 2 - bfd_arch_h8500, /* Hitachi H8/500 */ - bfd_arch_sh, /* Hitachi SH */ -#define bfd_mach_sh 0 -#define bfd_mach_sh3 0x30 -#define bfd_mach_sh3e 0x3e -#define bfd_mach_sh4 0x40 - bfd_arch_alpha, /* Dec Alpha */ - bfd_arch_arm, /* Advanced Risc Machines ARM */ -#define bfd_mach_arm_2 1 -#define bfd_mach_arm_2a 2 -#define bfd_mach_arm_3 3 -#define bfd_mach_arm_3M 4 -#define bfd_mach_arm_4 5 -#define bfd_mach_arm_4T 6 - bfd_arch_ns32k, /* National Semiconductors ns32000 */ - bfd_arch_w65, /* WDC 65816 */ - bfd_arch_tic30, /* Texas Instruments TMS320C30 */ - bfd_arch_v850, /* NEC V850 */ -#define bfd_mach_v850 0 - bfd_arch_arc, /* Argonaut RISC Core */ -#define bfd_mach_arc_base 0 - bfd_arch_m32r, /* Mitsubishi M32R/D */ -#define bfd_mach_m32r 0 /* backwards compatibility */ - bfd_arch_mn10200, /* Matsushita MN10200 */ - bfd_arch_mn10300, /* Matsushita MN10300 */ - bfd_arch_last - @}; -@end example - -@subsection bfd_arch_info - - -@strong{Description}@* -This structure contains information on architectures for use -within BFD. -@example - -typedef struct bfd_arch_info -@{ - int bits_per_word; - int bits_per_address; - int bits_per_byte; - enum bfd_architecture arch; - unsigned long mach; - const char *arch_name; - const char *printable_name; - unsigned int section_align_power; - /* true if this is the default machine for the architecture */ - boolean the_default; - const struct bfd_arch_info * (*compatible) - PARAMS ((const struct bfd_arch_info *a, - const struct bfd_arch_info *b)); - - boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *)); - - const struct bfd_arch_info *next; -@} bfd_arch_info_type; -@end example - -@findex bfd_printable_name -@subsubsection @code{bfd_printable_name} -@strong{Synopsis} -@example -const char *bfd_printable_name(bfd *abfd); -@end example -@strong{Description}@* -Return a printable string representing the architecture and machine -from the pointer to the architecture info structure. - -@findex bfd_scan_arch -@subsubsection @code{bfd_scan_arch} -@strong{Synopsis} -@example -const bfd_arch_info_type *bfd_scan_arch(const char *string); -@end example -@strong{Description}@* -Figure out if BFD supports any cpu which could be described with -the name @var{string}. Return a pointer to an @code{arch_info} -structure if a machine is found, otherwise NULL. - -@findex bfd_arch_list -@subsubsection @code{bfd_arch_list} -@strong{Synopsis} -@example -const char **bfd_arch_list(void); -@end example -@strong{Description}@* -Return a freshly malloced NULL-terminated vector of the names -of all the valid BFD architectures. Do not modify the names. - -@findex bfd_arch_get_compatible -@subsubsection @code{bfd_arch_get_compatible} -@strong{Synopsis} -@example -const bfd_arch_info_type *bfd_arch_get_compatible( - const bfd *abfd, - const bfd *bbfd); -@end example -@strong{Description}@* -Determine whether two BFDs' -architectures and machine types are compatible. Calculates -the lowest common denominator between the two architectures -and machine types implied by the BFDs and returns a pointer to -an @code{arch_info} structure describing the compatible machine. - -@findex bfd_default_arch_struct -@subsubsection @code{bfd_default_arch_struct} -@strong{Description}@* -The @code{bfd_default_arch_struct} is an item of -@code{bfd_arch_info_type} which has been initialized to a fairly -generic state. A BFD starts life by pointing to this -structure, until the correct back end has determined the real -architecture of the file. -@example -extern const bfd_arch_info_type bfd_default_arch_struct; -@end example - -@findex bfd_set_arch_info -@subsubsection @code{bfd_set_arch_info} -@strong{Synopsis} -@example -void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg); -@end example -@strong{Description}@* -Set the architecture info of @var{abfd} to @var{arg}. - -@findex bfd_default_set_arch_mach -@subsubsection @code{bfd_default_set_arch_mach} -@strong{Synopsis} -@example -boolean bfd_default_set_arch_mach(bfd *abfd, - enum bfd_architecture arch, - unsigned long mach); -@end example -@strong{Description}@* -Set the architecture and machine type in BFD @var{abfd} -to @var{arch} and @var{mach}. Find the correct -pointer to a structure and insert it into the @code{arch_info} -pointer. - -@findex bfd_get_arch -@subsubsection @code{bfd_get_arch} -@strong{Synopsis} -@example -enum bfd_architecture bfd_get_arch(bfd *abfd); -@end example -@strong{Description}@* -Return the enumerated type which describes the BFD @var{abfd}'s -architecture. - -@findex bfd_get_mach -@subsubsection @code{bfd_get_mach} -@strong{Synopsis} -@example -unsigned long bfd_get_mach(bfd *abfd); -@end example -@strong{Description}@* -Return the long type which describes the BFD @var{abfd}'s -machine. - -@findex bfd_arch_bits_per_byte -@subsubsection @code{bfd_arch_bits_per_byte} -@strong{Synopsis} -@example -unsigned int bfd_arch_bits_per_byte(bfd *abfd); -@end example -@strong{Description}@* -Return the number of bits in one of the BFD @var{abfd}'s -architecture's bytes. - -@findex bfd_arch_bits_per_address -@subsubsection @code{bfd_arch_bits_per_address} -@strong{Synopsis} -@example -unsigned int bfd_arch_bits_per_address(bfd *abfd); -@end example -@strong{Description}@* -Return the number of bits in one of the BFD @var{abfd}'s -architecture's addresses. - -@findex bfd_default_compatible -@subsubsection @code{bfd_default_compatible} -@strong{Synopsis} -@example -const bfd_arch_info_type *bfd_default_compatible - (const bfd_arch_info_type *a, - const bfd_arch_info_type *b); -@end example -@strong{Description}@* -The default function for testing for compatibility. - -@findex bfd_default_scan -@subsubsection @code{bfd_default_scan} -@strong{Synopsis} -@example -boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string); -@end example -@strong{Description}@* -The default function for working out whether this is an -architecture hit and a machine hit. - -@findex bfd_get_arch_info -@subsubsection @code{bfd_get_arch_info} -@strong{Synopsis} -@example -const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd); -@end example -@strong{Description}@* -Return the architecture info struct in @var{abfd}. - -@findex bfd_lookup_arch -@subsubsection @code{bfd_lookup_arch} -@strong{Synopsis} -@example -const bfd_arch_info_type *bfd_lookup_arch - (enum bfd_architecture - arch, - unsigned long machine); -@end example -@strong{Description}@* -Look for the architecure info structure which matches the -arguments @var{arch} and @var{machine}. A machine of 0 matches the -machine/architecture structure which marks itself as the -default. - -@findex bfd_printable_arch_mach -@subsubsection @code{bfd_printable_arch_mach} -@strong{Synopsis} -@example -const char *bfd_printable_arch_mach - (enum bfd_architecture arch, unsigned long machine); -@end example -@strong{Description}@* -Return a printable string representing the architecture and -machine type. - -This routine is depreciated. - diff --git a/contrib/binutils/bfd/doc/bfd.texi b/contrib/binutils/bfd/doc/bfd.texi deleted file mode 100644 index ea0ca9e56dc9..000000000000 --- a/contrib/binutils/bfd/doc/bfd.texi +++ /dev/null @@ -1,585 +0,0 @@ -@section @code{typedef bfd} -A BFD has type @code{bfd}; objects of this type are the -cornerstone of any application using BFD. Using BFD -consists of making references though the BFD and to data in the BFD. - -Here is the structure that defines the type @code{bfd}. It -contains the major data about the file and pointers -to the rest of the data. -@* -. -@example -struct _bfd -@{ - /* The filename the application opened the BFD with. */ - CONST char *filename; - - /* A pointer to the target jump table. */ - const struct bfd_target *xvec; - - /* To avoid dragging too many header files into every file that - includes `@code{bfd.h}', IOSTREAM has been declared as a "char - *", and MTIME as a "long". Their correct types, to which they - are cast when used, are "FILE *" and "time_t". The iostream - is the result of an fopen on the filename. However, if the - BFD_IN_MEMORY flag is set, then iostream is actually a pointer - to a bfd_in_memory struct. */ - PTR iostream; - - /* Is the file descriptor being cached? That is, can it be closed as - needed, and re-opened when accessed later? */ - - boolean cacheable; - - /* Marks whether there was a default target specified when the - BFD was opened. This is used to select which matching algorithm - to use to choose the back end. */ - - boolean target_defaulted; - - /* The caching routines use these to maintain a - least-recently-used list of BFDs */ - - struct _bfd *lru_prev, *lru_next; - - /* When a file is closed by the caching routines, BFD retains - state information on the file here: */ - - file_ptr where; - - /* and here: (``once'' means at least once) */ - - boolean opened_once; - - /* Set if we have a locally maintained mtime value, rather than - getting it from the file each time: */ - - boolean mtime_set; - - /* File modified time, if mtime_set is true: */ - - long mtime; - - /* Reserved for an unimplemented file locking extension.*/ - - int ifd; - - /* The format which belongs to the BFD. (object, core, etc.) */ - - bfd_format format; - - /* The direction the BFD was opened with*/ - - enum bfd_direction @{no_direction = 0, - read_direction = 1, - write_direction = 2, - both_direction = 3@} direction; - - /* Format_specific flags*/ - - flagword flags; - - /* Currently my_archive is tested before adding origin to - anything. I believe that this can become always an add of - origin, with origin set to 0 for non archive files. */ - - file_ptr origin; - - /* Remember when output has begun, to stop strange things - from happening. */ - boolean output_has_begun; - - /* Pointer to linked list of sections*/ - struct sec *sections; - - /* The number of sections */ - unsigned int section_count; - - /* Stuff only useful for object files: - The start address. */ - bfd_vma start_address; - - /* Used for input and output*/ - unsigned int symcount; - - /* Symbol table for output BFD (with symcount entries) */ - struct symbol_cache_entry **outsymbols; - - /* Pointer to structure which contains architecture information*/ - const struct bfd_arch_info *arch_info; - - /* Stuff only useful for archives:*/ - PTR arelt_data; - struct _bfd *my_archive; /* The containing archive BFD. */ - struct _bfd *next; /* The next BFD in the archive. */ - struct _bfd *archive_head; /* The first BFD in the archive. */ - boolean has_armap; - - /* A chain of BFD structures involved in a link. */ - struct _bfd *link_next; - - /* A field used by _bfd_generic_link_add_archive_symbols. This will - be used only for archive elements. */ - int archive_pass; - - /* Used by the back end to hold private data. */ - - union - @{ - struct aout_data_struct *aout_data; - struct artdata *aout_ar_data; - struct _oasys_data *oasys_obj_data; - struct _oasys_ar_data *oasys_ar_data; - struct coff_tdata *coff_obj_data; - struct pe_tdata *pe_obj_data; - struct xcoff_tdata *xcoff_obj_data; - struct ecoff_tdata *ecoff_obj_data; - struct ieee_data_struct *ieee_data; - struct ieee_ar_data_struct *ieee_ar_data; - struct srec_data_struct *srec_data; - struct ihex_data_struct *ihex_data; - struct tekhex_data_struct *tekhex_data; - struct elf_obj_tdata *elf_obj_data; - struct nlm_obj_tdata *nlm_obj_data; - struct bout_data_struct *bout_data; - struct sun_core_struct *sun_core_data; - struct trad_core_struct *trad_core_data; - struct som_data_struct *som_data; - struct hpux_core_struct *hpux_core_data; - struct hppabsd_core_struct *hppabsd_core_data; - struct sgi_core_struct *sgi_core_data; - struct lynx_core_struct *lynx_core_data; - struct osf_core_struct *osf_core_data; - struct cisco_core_struct *cisco_core_data; - struct versados_data_struct *versados_data; - struct netbsd_core_struct *netbsd_core_data; - PTR any; - @} tdata; - - /* Used by the application to hold private data*/ - PTR usrdata; - - /* Where all the allocated stuff under this BFD goes. This is a - struct objalloc *, but we use PTR to avoid requiring the inclusion of - objalloc.h. */ - PTR memory; -@}; - -@end example -@section Error reporting -Most BFD functions return nonzero on success (check their -individual documentation for precise semantics). On an error, -they call @code{bfd_set_error} to set an error condition that callers -can check by calling @code{bfd_get_error}. -If that returns @code{bfd_error_system_call}, then check -@code{errno}. - -The easiest way to report a BFD error to the user is to -use @code{bfd_perror}. -@* -@subsection Type @code{bfd_error_type} -The values returned by @code{bfd_get_error} are defined by the -enumerated type @code{bfd_error_type}. -@* -. -@example -typedef enum bfd_error -@{ - bfd_error_no_error = 0, - bfd_error_system_call, - bfd_error_invalid_target, - bfd_error_wrong_format, - bfd_error_invalid_operation, - bfd_error_no_memory, - bfd_error_no_symbols, - bfd_error_no_armap, - bfd_error_no_more_archived_files, - bfd_error_malformed_archive, - bfd_error_file_not_recognized, - bfd_error_file_ambiguously_recognized, - bfd_error_no_contents, - bfd_error_nonrepresentable_section, - bfd_error_no_debug_section, - bfd_error_bad_value, - bfd_error_file_truncated, - bfd_error_file_too_big, - bfd_error_invalid_error_code -@} bfd_error_type; - -@end example -@findex bfd_get_error -@subsubsection @code{bfd_get_error} -@strong{Synopsis} -@example -bfd_error_type bfd_get_error (void); -@end example -@strong{Description}@* -Return the current BFD error condition. -@* -@findex bfd_set_error -@subsubsection @code{bfd_set_error} -@strong{Synopsis} -@example -void bfd_set_error (bfd_error_type error_tag); -@end example -@strong{Description}@* -Set the BFD error condition to be @var{error_tag}. -@* -@findex bfd_errmsg -@subsubsection @code{bfd_errmsg} -@strong{Synopsis} -@example -CONST char *bfd_errmsg (bfd_error_type error_tag); -@end example -@strong{Description}@* -Return a string describing the error @var{error_tag}, or -the system error if @var{error_tag} is @code{bfd_error_system_call}. -@* -@findex bfd_perror -@subsubsection @code{bfd_perror} -@strong{Synopsis} -@example -void bfd_perror (CONST char *message); -@end example -@strong{Description}@* -Print to the standard error stream a string describing the -last BFD error that occurred, or the last system error if -the last BFD error was a system call failure. If @var{message} -is non-NULL and non-empty, the error string printed is preceded -by @var{message}, a colon, and a space. It is followed by a newline. -@* -@subsection BFD error handler -Some BFD functions want to print messages describing the -problem. They call a BFD error handler function. This -function may be overriden by the program. - -The BFD error handler acts like printf. -@* -. -@example -typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...)); - -@end example -@findex bfd_set_error_handler -@subsubsection @code{bfd_set_error_handler} -@strong{Synopsis} -@example -bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); -@end example -@strong{Description}@* -Set the BFD error handler function. Returns the previous -function. -@* -@findex bfd_set_error_program_name -@subsubsection @code{bfd_set_error_program_name} -@strong{Synopsis} -@example -void bfd_set_error_program_name (const char *); -@end example -@strong{Description}@* -Set the program name to use when printing a BFD error. This -is printed before the error message followed by a colon and -space. The string must not be changed after it is passed to -this function. -@* -@section Symbols - -@* -@findex bfd_get_reloc_upper_bound -@subsubsection @code{bfd_get_reloc_upper_bound} -@strong{Synopsis} -@example -long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect); -@end example -@strong{Description}@* -Return the number of bytes required to store the -relocation information associated with section @var{sect} -attached to bfd @var{abfd}. If an error occurs, return -1. -@* -@findex bfd_canonicalize_reloc -@subsubsection @code{bfd_canonicalize_reloc} -@strong{Synopsis} -@example -long bfd_canonicalize_reloc - (bfd *abfd, - asection *sec, - arelent **loc, - asymbol **syms); -@end example -@strong{Description}@* -Call the back end associated with the open BFD -@var{abfd} and translate the external form of the relocation -information attached to @var{sec} into the internal canonical -form. Place the table into memory at @var{loc}, which has -been preallocated, usually by a call to -@code{bfd_get_reloc_upper_bound}. Returns the number of relocs, or --1 on error. - -The @var{syms} table is also needed for horrible internal magic -reasons. -@* -@findex bfd_set_reloc -@subsubsection @code{bfd_set_reloc} -@strong{Synopsis} -@example -void bfd_set_reloc - (bfd *abfd, asection *sec, arelent **rel, unsigned int count) -@end example -@strong{Description}@* -Set the relocation pointer and count within -section @var{sec} to the values @var{rel} and @var{count}. -The argument @var{abfd} is ignored. -@* -@findex bfd_set_file_flags -@subsubsection @code{bfd_set_file_flags} -@strong{Synopsis} -@example -boolean bfd_set_file_flags(bfd *abfd, flagword flags); -@end example -@strong{Description}@* -Set the flag word in the BFD @var{abfd} to the value @var{flags}. - -Possible errors are: -@itemize @bullet - -@item -@code{bfd_error_wrong_format} - The target bfd was not of object format. -@item -@code{bfd_error_invalid_operation} - The target bfd was open for reading. -@item -@code{bfd_error_invalid_operation} - -The flag word contained a bit which was not applicable to the -type of file. E.g., an attempt was made to set the @code{D_PAGED} bit -on a BFD format which does not support demand paging. -@end itemize -@* -@findex bfd_set_start_address -@subsubsection @code{bfd_set_start_address} -@strong{Synopsis} -@example -boolean bfd_set_start_address(bfd *abfd, bfd_vma vma); -@end example -@strong{Description}@* -Make @var{vma} the entry point of output BFD @var{abfd}. -@* -@strong{Returns}@* -Returns @code{true} on success, @code{false} otherwise. -@* -@findex bfd_get_mtime -@subsubsection @code{bfd_get_mtime} -@strong{Synopsis} -@example -long bfd_get_mtime(bfd *abfd); -@end example -@strong{Description}@* -Return the file modification time (as read from the file system, or -from the archive header for archive members). -@* -@findex bfd_get_size -@subsubsection @code{bfd_get_size} -@strong{Synopsis} -@example -long bfd_get_size(bfd *abfd); -@end example -@strong{Description}@* -Return the file size (as read from file system) for the file -associated with BFD @var{abfd}. - -The initial motivation for, and use of, this routine is not -so we can get the exact size of the object the BFD applies to, since -that might not be generally possible (archive members for example). -It would be ideal if someone could eventually modify -it so that such results were guaranteed. - -Instead, we want to ask questions like "is this NNN byte sized -object I'm about to try read from file offset YYY reasonable?" -As as example of where we might do this, some object formats -use string tables for which the first @code{sizeof(long)} bytes of the -table contain the size of the table itself, including the size bytes. -If an application tries to read what it thinks is one of these -string tables, without some way to validate the size, and for -some reason the size is wrong (byte swapping error, wrong location -for the string table, etc.), the only clue is likely to be a read -error when it tries to read the table, or a "virtual memory -exhausted" error when it tries to allocate 15 bazillon bytes -of space for the 15 bazillon byte table it is about to read. -This function at least allows us to answer the quesion, "is the -size reasonable?". -@* -@findex bfd_get_gp_size -@subsubsection @code{bfd_get_gp_size} -@strong{Synopsis} -@example -int bfd_get_gp_size(bfd *abfd); -@end example -@strong{Description}@* -Return the maximum size of objects to be optimized using the GP -register under MIPS ECOFF. This is typically set by the @code{-G} -argument to the compiler, assembler or linker. -@* -@findex bfd_set_gp_size -@subsubsection @code{bfd_set_gp_size} -@strong{Synopsis} -@example -void bfd_set_gp_size(bfd *abfd, int i); -@end example -@strong{Description}@* -Set the maximum size of objects to be optimized using the GP -register under ECOFF or MIPS ELF. This is typically set by -the @code{-G} argument to the compiler, assembler or linker. -@* -@findex bfd_scan_vma -@subsubsection @code{bfd_scan_vma} -@strong{Synopsis} -@example -bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base); -@end example -@strong{Description}@* -Convert, like @code{strtoul}, a numerical expression -@var{string} into a @code{bfd_vma} integer, and return that integer. -(Though without as many bells and whistles as @code{strtoul}.) -The expression is assumed to be unsigned (i.e., positive). -If given a @var{base}, it is used as the base for conversion. -A base of 0 causes the function to interpret the string -in hex if a leading "0x" or "0X" is found, otherwise -in octal if a leading zero is found, otherwise in decimal. - -Overflow is not detected. -@* -@findex bfd_copy_private_bfd_data -@subsubsection @code{bfd_copy_private_bfd_data} -@strong{Synopsis} -@example -boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd); -@end example -@strong{Description}@* -Copy private BFD information from the BFD @var{ibfd} to the -the BFD @var{obfd}. Return @code{true} on success, @code{false} on error. -Possible error returns are: - -@itemize @bullet - -@item -@code{bfd_error_no_memory} - -Not enough memory exists to create private data for @var{obfd}. -@end itemize -@example -#define bfd_copy_private_bfd_data(ibfd, obfd) \ - BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ - (ibfd, obfd)) -@end example -@* -@findex bfd_merge_private_bfd_data -@subsubsection @code{bfd_merge_private_bfd_data} -@strong{Synopsis} -@example -boolean bfd_merge_private_bfd_data(bfd *ibfd, bfd *obfd); -@end example -@strong{Description}@* -Merge private BFD information from the BFD @var{ibfd} to the -the output file BFD @var{obfd} when linking. Return @code{true} -on success, @code{false} on error. Possible error returns are: - -@itemize @bullet - -@item -@code{bfd_error_no_memory} - -Not enough memory exists to create private data for @var{obfd}. -@end itemize -@example -#define bfd_merge_private_bfd_data(ibfd, obfd) \ - BFD_SEND (obfd, _bfd_merge_private_bfd_data, \ - (ibfd, obfd)) -@end example -@* -@findex bfd_set_private_flags -@subsubsection @code{bfd_set_private_flags} -@strong{Synopsis} -@example -boolean bfd_set_private_flags(bfd *abfd, flagword flags); -@end example -@strong{Description}@* -Set private BFD flag information in the BFD @var{abfd}. -Return @code{true} on success, @code{false} on error. Possible error -returns are: - -@itemize @bullet - -@item -@code{bfd_error_no_memory} - -Not enough memory exists to create private data for @var{obfd}. -@end itemize -@example -#define bfd_set_private_flags(abfd, flags) \ - BFD_SEND (abfd, _bfd_set_private_flags, \ - (abfd, flags)) -@end example -@* -@findex stuff -@subsubsection @code{stuff} -@strong{Description}@* -Stuff which should be documented: -@example -#define bfd_sizeof_headers(abfd, reloc) \ - BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) - -#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ - BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line)) - - /* Do these three do anything useful at all, for any back end? */ -#define bfd_debug_info_start(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) - -#define bfd_debug_info_end(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) - -#define bfd_debug_info_accumulate(abfd, section) \ - BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) - - -#define bfd_stat_arch_elt(abfd, stat) \ - BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) - -#define bfd_update_armap_timestamp(abfd) \ - BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd)) - -#define bfd_set_arch_mach(abfd, arch, mach)\ - BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) - -#define bfd_relax_section(abfd, section, link_info, again) \ - BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) - -#define bfd_link_hash_table_create(abfd) \ - BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) - -#define bfd_link_add_symbols(abfd, info) \ - BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) - -#define bfd_final_link(abfd, info) \ - BFD_SEND (abfd, _bfd_final_link, (abfd, info)) - -#define bfd_free_cached_info(abfd) \ - BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) - -#define bfd_get_dynamic_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) - -#define bfd_print_private_bfd_data(abfd, file)\ - BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file)) - -#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ - BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) - -#define bfd_get_dynamic_reloc_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) - -#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ - BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) - -extern bfd_byte *bfd_get_relocated_section_contents - PARAMS ((bfd *, struct bfd_link_info *, - struct bfd_link_order *, bfd_byte *, - boolean, asymbol **)); - -@end example -@* diff --git a/contrib/binutils/bfd/doc/bfdt.texi b/contrib/binutils/bfd/doc/bfdt.texi deleted file mode 100644 index 6013d6a5ed22..000000000000 --- a/contrib/binutils/bfd/doc/bfdt.texi +++ /dev/null @@ -1,597 +0,0 @@ -@section @code{typedef bfd} -A BFD has type @code{bfd}; objects of this type are the -cornerstone of any application using BFD. Using BFD -consists of making references though the BFD and to data in the BFD. - -Here is the structure that defines the type @code{bfd}. It -contains the major data about the file and pointers -to the rest of the data. - - -@example - -struct _bfd -@{ - /* The filename the application opened the BFD with. */ - CONST char *filename; - - /* A pointer to the target jump table. */ - const struct bfd_target *xvec; - - /* To avoid dragging too many header files into every file that - includes `@code{bfd.h}', IOSTREAM has been declared as a "char - *", and MTIME as a "long". Their correct types, to which they - are cast when used, are "FILE *" and "time_t". The iostream - is the result of an fopen on the filename. However, if the - BFD_IN_MEMORY flag is set, then iostream is actually a pointer - to a bfd_in_memory struct. */ - PTR iostream; - - /* Is the file descriptor being cached? That is, can it be closed as - needed, and re-opened when accessed later? */ - - boolean cacheable; - - /* Marks whether there was a default target specified when the - BFD was opened. This is used to select which matching algorithm - to use to choose the back end. */ - - boolean target_defaulted; - - /* The caching routines use these to maintain a - least-recently-used list of BFDs */ - - struct _bfd *lru_prev, *lru_next; - - /* When a file is closed by the caching routines, BFD retains - state information on the file here: */ - - file_ptr where; - - /* and here: (``once'' means at least once) */ - - boolean opened_once; - - /* Set if we have a locally maintained mtime value, rather than - getting it from the file each time: */ - - boolean mtime_set; - - /* File modified time, if mtime_set is true: */ - - long mtime; - - /* Reserved for an unimplemented file locking extension.*/ - - int ifd; - - /* The format which belongs to the BFD. (object, core, etc.) */ - - bfd_format format; - - /* The direction the BFD was opened with*/ - - enum bfd_direction @{no_direction = 0, - read_direction = 1, - write_direction = 2, - both_direction = 3@} direction; - - /* Format_specific flags*/ - - flagword flags; - - /* Currently my_archive is tested before adding origin to - anything. I believe that this can become always an add of - origin, with origin set to 0 for non archive files. */ - - file_ptr origin; - - /* Remember when output has begun, to stop strange things - from happening. */ - boolean output_has_begun; - - /* Pointer to linked list of sections*/ - struct sec *sections; - - /* The number of sections */ - unsigned int section_count; - - /* Stuff only useful for object files: - The start address. */ - bfd_vma start_address; - - /* Used for input and output*/ - unsigned int symcount; - - /* Symbol table for output BFD (with symcount entries) */ - struct symbol_cache_entry **outsymbols; - - /* Pointer to structure which contains architecture information*/ - const struct bfd_arch_info *arch_info; - - /* Stuff only useful for archives:*/ - PTR arelt_data; - struct _bfd *my_archive; /* The containing archive BFD. */ - struct _bfd *next; /* The next BFD in the archive. */ - struct _bfd *archive_head; /* The first BFD in the archive. */ - boolean has_armap; - - /* A chain of BFD structures involved in a link. */ - struct _bfd *link_next; - - /* A field used by _bfd_generic_link_add_archive_symbols. This will - be used only for archive elements. */ - int archive_pass; - - /* Used by the back end to hold private data. */ - - union - @{ - struct aout_data_struct *aout_data; - struct artdata *aout_ar_data; - struct _oasys_data *oasys_obj_data; - struct _oasys_ar_data *oasys_ar_data; - struct coff_tdata *coff_obj_data; - struct pe_tdata *pe_obj_data; - struct xcoff_tdata *xcoff_obj_data; - struct ecoff_tdata *ecoff_obj_data; - struct ieee_data_struct *ieee_data; - struct ieee_ar_data_struct *ieee_ar_data; - struct srec_data_struct *srec_data; - struct ihex_data_struct *ihex_data; - struct tekhex_data_struct *tekhex_data; - struct elf_obj_tdata *elf_obj_data; - struct nlm_obj_tdata *nlm_obj_data; - struct bout_data_struct *bout_data; - struct sun_core_struct *sun_core_data; - struct trad_core_struct *trad_core_data; - struct som_data_struct *som_data; - struct hpux_core_struct *hpux_core_data; - struct hppabsd_core_struct *hppabsd_core_data; - struct sgi_core_struct *sgi_core_data; - struct lynx_core_struct *lynx_core_data; - struct osf_core_struct *osf_core_data; - struct cisco_core_struct *cisco_core_data; - struct versados_data_struct *versados_data; - struct netbsd_core_struct *netbsd_core_data; - PTR any; - @} tdata; - - /* Used by the application to hold private data*/ - PTR usrdata; - - /* Where all the allocated stuff under this BFD goes. This is a - struct objalloc *, but we use PTR to avoid requiring the inclusion of - objalloc.h. */ - PTR memory; -@}; - -@end example -@section Error reporting -Most BFD functions return nonzero on success (check their -individual documentation for precise semantics). On an error, -they call @code{bfd_set_error} to set an error condition that callers -can check by calling @code{bfd_get_error}. -If that returns @code{bfd_error_system_call}, then check -@code{errno}. - -The easiest way to report a BFD error to the user is to -use @code{bfd_perror}. - -@subsection Type @code{bfd_error_type} -The values returned by @code{bfd_get_error} are defined by the -enumerated type @code{bfd_error_type}. - - -@example - -typedef enum bfd_error -@{ - bfd_error_no_error = 0, - bfd_error_system_call, - bfd_error_invalid_target, - bfd_error_wrong_format, - bfd_error_invalid_operation, - bfd_error_no_memory, - bfd_error_no_symbols, - bfd_error_no_armap, - bfd_error_no_more_archived_files, - bfd_error_malformed_archive, - bfd_error_file_not_recognized, - bfd_error_file_ambiguously_recognized, - bfd_error_no_contents, - bfd_error_nonrepresentable_section, - bfd_error_no_debug_section, - bfd_error_bad_value, - bfd_error_file_truncated, - bfd_error_file_too_big, - bfd_error_invalid_error_code -@} bfd_error_type; - -@end example -@findex bfd_get_error -@subsubsection @code{bfd_get_error} -@strong{Synopsis} -@example -bfd_error_type bfd_get_error (void); -@end example -@strong{Description}@* -Return the current BFD error condition. - -@findex bfd_set_error -@subsubsection @code{bfd_set_error} -@strong{Synopsis} -@example -void bfd_set_error (bfd_error_type error_tag); -@end example -@strong{Description}@* -Set the BFD error condition to be @var{error_tag}. - -@findex bfd_errmsg -@subsubsection @code{bfd_errmsg} -@strong{Synopsis} -@example -CONST char *bfd_errmsg (bfd_error_type error_tag); -@end example -@strong{Description}@* -Return a string describing the error @var{error_tag}, or -the system error if @var{error_tag} is @code{bfd_error_system_call}. - -@findex bfd_perror -@subsubsection @code{bfd_perror} -@strong{Synopsis} -@example -void bfd_perror (CONST char *message); -@end example -@strong{Description}@* -Print to the standard error stream a string describing the -last BFD error that occurred, or the last system error if -the last BFD error was a system call failure. If @var{message} -is non-NULL and non-empty, the error string printed is preceded -by @var{message}, a colon, and a space. It is followed by a newline. - -@subsection BFD error handler -Some BFD functions want to print messages describing the -problem. They call a BFD error handler function. This -function may be overriden by the program. - -The BFD error handler acts like printf. - - -@example - -typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...)); - -@end example -@findex bfd_set_error_handler -@subsubsection @code{bfd_set_error_handler} -@strong{Synopsis} -@example -bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); -@end example -@strong{Description}@* -Set the BFD error handler function. Returns the previous -function. - -@findex bfd_set_error_program_name -@subsubsection @code{bfd_set_error_program_name} -@strong{Synopsis} -@example -void bfd_set_error_program_name (const char *); -@end example -@strong{Description}@* -Set the program name to use when printing a BFD error. This -is printed before the error message followed by a colon and -space. The string must not be changed after it is passed to -this function. - -@findex bfd_get_error_handler -@subsubsection @code{bfd_get_error_handler} -@strong{Synopsis} -@example -bfd_error_handler_type bfd_get_error_handler (void); -@end example -@strong{Description}@* -Return the BFD error handler function. - -@section Symbols - - -@findex bfd_get_reloc_upper_bound -@subsubsection @code{bfd_get_reloc_upper_bound} -@strong{Synopsis} -@example -long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect); -@end example -@strong{Description}@* -Return the number of bytes required to store the -relocation information associated with section @var{sect} -attached to bfd @var{abfd}. If an error occurs, return -1. - -@findex bfd_canonicalize_reloc -@subsubsection @code{bfd_canonicalize_reloc} -@strong{Synopsis} -@example -long bfd_canonicalize_reloc - (bfd *abfd, - asection *sec, - arelent **loc, - asymbol **syms); -@end example -@strong{Description}@* -Call the back end associated with the open BFD -@var{abfd} and translate the external form of the relocation -information attached to @var{sec} into the internal canonical -form. Place the table into memory at @var{loc}, which has -been preallocated, usually by a call to -@code{bfd_get_reloc_upper_bound}. Returns the number of relocs, or --1 on error. - -The @var{syms} table is also needed for horrible internal magic -reasons. - -@findex bfd_set_reloc -@subsubsection @code{bfd_set_reloc} -@strong{Synopsis} -@example -void bfd_set_reloc - (bfd *abfd, asection *sec, arelent **rel, unsigned int count) -@end example -@strong{Description}@* -Set the relocation pointer and count within -section @var{sec} to the values @var{rel} and @var{count}. -The argument @var{abfd} is ignored. - -@findex bfd_set_file_flags -@subsubsection @code{bfd_set_file_flags} -@strong{Synopsis} -@example -boolean bfd_set_file_flags(bfd *abfd, flagword flags); -@end example -@strong{Description}@* -Set the flag word in the BFD @var{abfd} to the value @var{flags}. - -Possible errors are: -@itemize @bullet - -@item -@code{bfd_error_wrong_format} - The target bfd was not of object format. -@item -@code{bfd_error_invalid_operation} - The target bfd was open for reading. -@item -@code{bfd_error_invalid_operation} - -The flag word contained a bit which was not applicable to the -type of file. E.g., an attempt was made to set the @code{D_PAGED} bit -on a BFD format which does not support demand paging. -@end itemize - -@findex bfd_set_start_address -@subsubsection @code{bfd_set_start_address} -@strong{Synopsis} -@example -boolean bfd_set_start_address(bfd *abfd, bfd_vma vma); -@end example -@strong{Description}@* -Make @var{vma} the entry point of output BFD @var{abfd}. - -@strong{Returns}@* -Returns @code{true} on success, @code{false} otherwise. - -@findex bfd_get_mtime -@subsubsection @code{bfd_get_mtime} -@strong{Synopsis} -@example -long bfd_get_mtime(bfd *abfd); -@end example -@strong{Description}@* -Return the file modification time (as read from the file system, or -from the archive header for archive members). - -@findex bfd_get_size -@subsubsection @code{bfd_get_size} -@strong{Synopsis} -@example -long bfd_get_size(bfd *abfd); -@end example -@strong{Description}@* -Return the file size (as read from file system) for the file -associated with BFD @var{abfd}. - -The initial motivation for, and use of, this routine is not -so we can get the exact size of the object the BFD applies to, since -that might not be generally possible (archive members for example). -It would be ideal if someone could eventually modify -it so that such results were guaranteed. - -Instead, we want to ask questions like "is this NNN byte sized -object I'm about to try read from file offset YYY reasonable?" -As as example of where we might do this, some object formats -use string tables for which the first @code{sizeof(long)} bytes of the -table contain the size of the table itself, including the size bytes. -If an application tries to read what it thinks is one of these -string tables, without some way to validate the size, and for -some reason the size is wrong (byte swapping error, wrong location -for the string table, etc.), the only clue is likely to be a read -error when it tries to read the table, or a "virtual memory -exhausted" error when it tries to allocate 15 bazillon bytes -of space for the 15 bazillon byte table it is about to read. -This function at least allows us to answer the quesion, "is the -size reasonable?". - -@findex bfd_get_gp_size -@subsubsection @code{bfd_get_gp_size} -@strong{Synopsis} -@example -int bfd_get_gp_size(bfd *abfd); -@end example -@strong{Description}@* -Return the maximum size of objects to be optimized using the GP -register under MIPS ECOFF. This is typically set by the @code{-G} -argument to the compiler, assembler or linker. - -@findex bfd_set_gp_size -@subsubsection @code{bfd_set_gp_size} -@strong{Synopsis} -@example -void bfd_set_gp_size(bfd *abfd, int i); -@end example -@strong{Description}@* -Set the maximum size of objects to be optimized using the GP -register under ECOFF or MIPS ELF. This is typically set by -the @code{-G} argument to the compiler, assembler or linker. - -@findex bfd_scan_vma -@subsubsection @code{bfd_scan_vma} -@strong{Synopsis} -@example -bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base); -@end example -@strong{Description}@* -Convert, like @code{strtoul}, a numerical expression -@var{string} into a @code{bfd_vma} integer, and return that integer. -(Though without as many bells and whistles as @code{strtoul}.) -The expression is assumed to be unsigned (i.e., positive). -If given a @var{base}, it is used as the base for conversion. -A base of 0 causes the function to interpret the string -in hex if a leading "0x" or "0X" is found, otherwise -in octal if a leading zero is found, otherwise in decimal. - -Overflow is not detected. - -@findex bfd_copy_private_bfd_data -@subsubsection @code{bfd_copy_private_bfd_data} -@strong{Synopsis} -@example -boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd); -@end example -@strong{Description}@* -Copy private BFD information from the BFD @var{ibfd} to the -the BFD @var{obfd}. Return @code{true} on success, @code{false} on error. -Possible error returns are: - -@itemize @bullet - -@item -@code{bfd_error_no_memory} - -Not enough memory exists to create private data for @var{obfd}. -@end itemize -@example -#define bfd_copy_private_bfd_data(ibfd, obfd) \ - BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ - (ibfd, obfd)) -@end example - -@findex bfd_merge_private_bfd_data -@subsubsection @code{bfd_merge_private_bfd_data} -@strong{Synopsis} -@example -boolean bfd_merge_private_bfd_data(bfd *ibfd, bfd *obfd); -@end example -@strong{Description}@* -Merge private BFD information from the BFD @var{ibfd} to the -the output file BFD @var{obfd} when linking. Return @code{true} -on success, @code{false} on error. Possible error returns are: - -@itemize @bullet - -@item -@code{bfd_error_no_memory} - -Not enough memory exists to create private data for @var{obfd}. -@end itemize -@example -#define bfd_merge_private_bfd_data(ibfd, obfd) \ - BFD_SEND (obfd, _bfd_merge_private_bfd_data, \ - (ibfd, obfd)) -@end example - -@findex bfd_set_private_flags -@subsubsection @code{bfd_set_private_flags} -@strong{Synopsis} -@example -boolean bfd_set_private_flags(bfd *abfd, flagword flags); -@end example -@strong{Description}@* -Set private BFD flag information in the BFD @var{abfd}. -Return @code{true} on success, @code{false} on error. Possible error -returns are: - -@itemize @bullet - -@item -@code{bfd_error_no_memory} - -Not enough memory exists to create private data for @var{obfd}. -@end itemize -@example -#define bfd_set_private_flags(abfd, flags) \ - BFD_SEND (abfd, _bfd_set_private_flags, \ - (abfd, flags)) -@end example - -@findex stuff -@subsubsection @code{stuff} -@strong{Description}@* -Stuff which should be documented: -@example -#define bfd_sizeof_headers(abfd, reloc) \ - BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) - -#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ - BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line)) - - /* Do these three do anything useful at all, for any back end? */ -#define bfd_debug_info_start(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) - -#define bfd_debug_info_end(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) - -#define bfd_debug_info_accumulate(abfd, section) \ - BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) - - -#define bfd_stat_arch_elt(abfd, stat) \ - BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) - -#define bfd_update_armap_timestamp(abfd) \ - BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd)) - -#define bfd_set_arch_mach(abfd, arch, mach)\ - BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) - -#define bfd_relax_section(abfd, section, link_info, again) \ - BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) - -#define bfd_link_hash_table_create(abfd) \ - BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) - -#define bfd_link_add_symbols(abfd, info) \ - BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) - -#define bfd_final_link(abfd, info) \ - BFD_SEND (abfd, _bfd_final_link, (abfd, info)) - -#define bfd_free_cached_info(abfd) \ - BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) - -#define bfd_get_dynamic_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) - -#define bfd_print_private_bfd_data(abfd, file)\ - BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file)) - -#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ - BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) - -#define bfd_get_dynamic_reloc_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) - -#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ - BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) - -extern bfd_byte *bfd_get_relocated_section_contents - PARAMS ((bfd *, struct bfd_link_info *, - struct bfd_link_order *, bfd_byte *, - boolean, asymbol **)); - -@end example - diff --git a/contrib/binutils/bfd/doc/cache.texi b/contrib/binutils/bfd/doc/cache.texi deleted file mode 100644 index 4aafb69ca7a5..000000000000 --- a/contrib/binutils/bfd/doc/cache.texi +++ /dev/null @@ -1,95 +0,0 @@ -@section File caching -The file caching mechanism is embedded within BFD and allows -the application to open as many BFDs as it wants without -regard to the underlying operating system's file descriptor -limit (often as low as 20 open files). The module in -@code{cache.c} maintains a least recently used list of -@code{BFD_CACHE_MAX_OPEN} files, and exports the name -@code{bfd_cache_lookup}, which runs around and makes sure that -the required BFD is open. If not, then it chooses a file to -close, closes it and opens the one wanted, returning its file -handle. - -@findex BFD_CACHE_MAX_OPEN macro -@subsubsection @code{BFD_CACHE_MAX_OPEN macro} -@strong{Description}@* -The maximum number of files which the cache will keep open at -one time. -@example -#define BFD_CACHE_MAX_OPEN 10 -@end example - -@findex bfd_last_cache -@subsubsection @code{bfd_last_cache} -@strong{Synopsis} -@example -extern bfd *bfd_last_cache; -@end example -@strong{Description}@* -Zero, or a pointer to the topmost BFD on the chain. This is -used by the @code{bfd_cache_lookup} macro in @file{libbfd.h} to -determine when it can avoid a function call. - -@findex bfd_cache_lookup -@subsubsection @code{bfd_cache_lookup} -@strong{Description}@* -Check to see if the required BFD is the same as the last one -looked up. If so, then it can use the stream in the BFD with -impunity, since it can't have changed since the last lookup; -otherwise, it has to perform the complicated lookup function. -@example -#define bfd_cache_lookup(x) \ - ((x)==bfd_last_cache? \ - (FILE*)(bfd_last_cache->iostream): \ - bfd_cache_lookup_worker(x)) -@end example - -@findex bfd_cache_init -@subsubsection @code{bfd_cache_init} -@strong{Synopsis} -@example -boolean bfd_cache_init (bfd *abfd); -@end example -@strong{Description}@* -Add a newly opened BFD to the cache. - -@findex bfd_cache_close -@subsubsection @code{bfd_cache_close} -@strong{Synopsis} -@example -boolean bfd_cache_close (bfd *abfd); -@end example -@strong{Description}@* -Remove the BFD @var{abfd} from the cache. If the attached file is open, -then close it too. - -@strong{Returns}@* -@code{false} is returned if closing the file fails, @code{true} is -returned if all is well. - -@findex bfd_open_file -@subsubsection @code{bfd_open_file} -@strong{Synopsis} -@example -FILE* bfd_open_file(bfd *abfd); -@end example -@strong{Description}@* -Call the OS to open a file for @var{abfd}. Return the @code{FILE *} -(possibly @code{NULL}) that results from this operation. Set up the -BFD so that future accesses know the file is open. If the @code{FILE *} -returned is @code{NULL}, then it won't have been put in the -cache, so it won't have to be removed from it. - -@findex bfd_cache_lookup_worker -@subsubsection @code{bfd_cache_lookup_worker} -@strong{Synopsis} -@example -FILE *bfd_cache_lookup_worker(bfd *abfd); -@end example -@strong{Description}@* -Called when the macro @code{bfd_cache_lookup} fails to find a -quick answer. Find a file descriptor for @var{abfd}. If -necessary, it open it. If there are already more than -@code{BFD_CACHE_MAX_OPEN} files open, it tries to close one first, to -avoid running out of file descriptors. - diff --git a/contrib/binutils/bfd/doc/coffcode.texi b/contrib/binutils/bfd/doc/coffcode.texi deleted file mode 100644 index d3bcfa079244..000000000000 --- a/contrib/binutils/bfd/doc/coffcode.texi +++ /dev/null @@ -1,639 +0,0 @@ -@section coff backends -BFD supports a number of different flavours of coff format. -The major differences between formats are the sizes and -alignments of fields in structures on disk, and the occasional -extra field. - -Coff in all its varieties is implemented with a few common -files and a number of implementation specific files. For -example, The 88k bcs coff format is implemented in the file -@file{coff-m88k.c}. This file @code{#include}s -@file{coff/m88k.h} which defines the external structure of the -coff format for the 88k, and @file{coff/internal.h} which -defines the internal structure. @file{coff-m88k.c} also -defines the relocations used by the 88k format -@xref{Relocations}. - -The Intel i960 processor version of coff is implemented in -@file{coff-i960.c}. This file has the same structure as -@file{coff-m88k.c}, except that it includes @file{coff/i960.h} -rather than @file{coff-m88k.h}. - -@subsection Porting to a new version of coff -The recommended method is to select from the existing -implementations the version of coff which is most like the one -you want to use. For example, we'll say that i386 coff is -the one you select, and that your coff flavour is called foo. -Copy @file{i386coff.c} to @file{foocoff.c}, copy -@file{../include/coff/i386.h} to @file{../include/coff/foo.h}, -and add the lines to @file{targets.c} and @file{Makefile.in} -so that your new back end is used. Alter the shapes of the -structures in @file{../include/coff/foo.h} so that they match -what you need. You will probably also have to add -@code{#ifdef}s to the code in @file{coff/internal.h} and -@file{coffcode.h} if your version of coff is too wild. - -You can verify that your new BFD backend works quite simply by -building @file{objdump} from the @file{binutils} directory, -and making sure that its version of what's going on and your -host system's idea (assuming it has the pretty standard coff -dump utility, usually called @code{att-dump} or just -@code{dump}) are the same. Then clean up your code, and send -what you've done to Cygnus. Then your stuff will be in the -next release, and you won't have to keep integrating it. - -@subsection How the coff backend works - - -@subsubsection File layout -The Coff backend is split into generic routines that are -applicable to any Coff target and routines that are specific -to a particular target. The target-specific routines are -further split into ones which are basically the same for all -Coff targets except that they use the external symbol format -or use different values for certain constants. - -The generic routines are in @file{coffgen.c}. These routines -work for any Coff target. They use some hooks into the target -specific code; the hooks are in a @code{bfd_coff_backend_data} -structure, one of which exists for each target. - -The essentially similar target-specific routines are in -@file{coffcode.h}. This header file includes executable C code. -The various Coff targets first include the appropriate Coff -header file, make any special defines that are needed, and -then include @file{coffcode.h}. - -Some of the Coff targets then also have additional routines in -the target source file itself. - -For example, @file{coff-i960.c} includes -@file{coff/internal.h} and @file{coff/i960.h}. It then -defines a few constants, such as @code{I960}, and includes -@file{coffcode.h}. Since the i960 has complex relocation -types, @file{coff-i960.c} also includes some code to -manipulate the i960 relocs. This code is not in -@file{coffcode.h} because it would not be used by any other -target. - -@subsubsection Bit twiddling -Each flavour of coff supported in BFD has its own header file -describing the external layout of the structures. There is also -an internal description of the coff layout, in -@file{coff/internal.h}. A major function of the -coff backend is swapping the bytes and twiddling the bits to -translate the external form of the structures into the normal -internal form. This is all performed in the -@code{bfd_swap}_@i{thing}_@i{direction} routines. Some -elements are different sizes between different versions of -coff; it is the duty of the coff version specific include file -to override the definitions of various packing routines in -@file{coffcode.h}. E.g., the size of line number entry in coff is -sometimes 16 bits, and sometimes 32 bits. @code{#define}ing -@code{PUT_LNSZ_LNNO} and @code{GET_LNSZ_LNNO} will select the -correct one. No doubt, some day someone will find a version of -coff which has a varying field size not catered to at the -moment. To port BFD, that person will have to add more @code{#defines}. -Three of the bit twiddling routines are exported to -@code{gdb}; @code{coff_swap_aux_in}, @code{coff_swap_sym_in} -and @code{coff_swap_linno_in}. @code{GDB} reads the symbol -table on its own, but uses BFD to fix things up. More of the -bit twiddlers are exported for @code{gas}; -@code{coff_swap_aux_out}, @code{coff_swap_sym_out}, -@code{coff_swap_lineno_out}, @code{coff_swap_reloc_out}, -@code{coff_swap_filehdr_out}, @code{coff_swap_aouthdr_out}, -@code{coff_swap_scnhdr_out}. @code{Gas} currently keeps track -of all the symbol table and reloc drudgery itself, thereby -saving the internal BFD overhead, but uses BFD to swap things -on the way out, making cross ports much safer. Doing so also -allows BFD (and thus the linker) to use the same header files -as @code{gas}, which makes one avenue to disaster disappear. - -@subsubsection Symbol reading -The simple canonical form for symbols used by BFD is not rich -enough to keep all the information available in a coff symbol -table. The back end gets around this problem by keeping the original -symbol table around, "behind the scenes". - -When a symbol table is requested (through a call to -@code{bfd_canonicalize_symtab}), a request gets through to -@code{coff_get_normalized_symtab}. This reads the symbol table from -the coff file and swaps all the structures inside into the -internal form. It also fixes up all the pointers in the table -(represented in the file by offsets from the first symbol in -the table) into physical pointers to elements in the new -internal table. This involves some work since the meanings of -fields change depending upon context: a field that is a -pointer to another structure in the symbol table at one moment -may be the size in bytes of a structure at the next. Another -pass is made over the table. All symbols which mark file names -(@code{C_FILE} symbols) are modified so that the internal -string points to the value in the auxent (the real filename) -rather than the normal text associated with the symbol -(@code{".file"}). - -At this time the symbol names are moved around. Coff stores -all symbols less than nine characters long physically -within the symbol table; longer strings are kept at the end of -the file in the string table. This pass moves all strings -into memory and replaces them with pointers to the strings. - -The symbol table is massaged once again, this time to create -the canonical table used by the BFD application. Each symbol -is inspected in turn, and a decision made (using the -@code{sclass} field) about the various flags to set in the -@code{asymbol}. @xref{Symbols}. The generated canonical table -shares strings with the hidden internal symbol table. - -Any linenumbers are read from the coff file too, and attached -to the symbols which own the functions the linenumbers belong to. - -@subsubsection Symbol writing -Writing a symbol to a coff file which didn't come from a coff -file will lose any debugging information. The @code{asymbol} -structure remembers the BFD from which the symbol was taken, and on -output the back end makes sure that the same destination target as -source target is present. - -When the symbols have come from a coff file then all the -debugging information is preserved. - -Symbol tables are provided for writing to the back end in a -vector of pointers to pointers. This allows applications like -the linker to accumulate and output large symbol tables -without having to do too much byte copying. - -This function runs through the provided symbol table and -patches each symbol marked as a file place holder -(@code{C_FILE}) to point to the next file place holder in the -list. It also marks each @code{offset} field in the list with -the offset from the first symbol of the current symbol. - -Another function of this procedure is to turn the canonical -value form of BFD into the form used by coff. Internally, BFD -expects symbol values to be offsets from a section base; so a -symbol physically at 0x120, but in a section starting at -0x100, would have the value 0x20. Coff expects symbols to -contain their final value, so symbols have their values -changed at this point to reflect their sum with their owning -section. This transformation uses the -@code{output_section} field of the @code{asymbol}'s -@code{asection} @xref{Sections}. - -@itemize @bullet - -@item -@code{coff_mangle_symbols} -@end itemize -This routine runs though the provided symbol table and uses -the offsets generated by the previous pass and the pointers -generated when the symbol table was read in to create the -structured hierachy required by coff. It changes each pointer -to a symbol into the index into the symbol table of the asymbol. - -@itemize @bullet - -@item -@code{coff_write_symbols} -@end itemize -This routine runs through the symbol table and patches up the -symbols from their internal form into the coff way, calls the -bit twiddlers, and writes out the table to the file. - -@findex coff_symbol_type -@subsubsection @code{coff_symbol_type} -@strong{Description}@* -The hidden information for an @code{asymbol} is described in a -@code{combined_entry_type}: - - -@example - -typedef struct coff_ptr_struct -@{ - - /* Remembers the offset from the first symbol in the file for - this symbol. Generated by coff_renumber_symbols. */ -unsigned int offset; - - /* Should the value of this symbol be renumbered. Used for - XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */ -unsigned int fix_value : 1; - - /* Should the tag field of this symbol be renumbered. - Created by coff_pointerize_aux. */ -unsigned int fix_tag : 1; - - /* Should the endidx field of this symbol be renumbered. - Created by coff_pointerize_aux. */ -unsigned int fix_end : 1; - - /* Should the x_csect.x_scnlen field be renumbered. - Created by coff_pointerize_aux. */ -unsigned int fix_scnlen : 1; - - /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the - index into the line number entries. Set by - coff_slurp_symbol_table. */ -unsigned int fix_line : 1; - - /* The container for the symbol structure as read and translated - from the file. */ - -union @{ - union internal_auxent auxent; - struct internal_syment syment; - @} u; -@} combined_entry_type; - - -/* Each canonical asymbol really looks like this: */ - -typedef struct coff_symbol_struct -@{ - /* The actual symbol which the rest of BFD works with */ -asymbol symbol; - - /* A pointer to the hidden information for this symbol */ -combined_entry_type *native; - - /* A pointer to the linenumber information for this symbol */ -struct lineno_cache_entry *lineno; - - /* Have the line numbers been relocated yet ? */ -boolean done_lineno; -@} coff_symbol_type; -@end example -@findex bfd_coff_backend_data -@subsubsection @code{bfd_coff_backend_data} -Special entry points for gdb to swap in coff symbol table parts: -@example -typedef struct -@{ - void (*_bfd_coff_swap_aux_in) PARAMS (( - bfd *abfd, - PTR ext, - int type, - int class, - int indaux, - int numaux, - PTR in)); - - void (*_bfd_coff_swap_sym_in) PARAMS (( - bfd *abfd , - PTR ext, - PTR in)); - - void (*_bfd_coff_swap_lineno_in) PARAMS (( - bfd *abfd, - PTR ext, - PTR in)); - -@end example -Special entry points for gas to swap out coff parts: -@example - unsigned int (*_bfd_coff_swap_aux_out) PARAMS (( - bfd *abfd, - PTR in, - int type, - int class, - int indaux, - int numaux, - PTR ext)); - - unsigned int (*_bfd_coff_swap_sym_out) PARAMS (( - bfd *abfd, - PTR in, - PTR ext)); - - unsigned int (*_bfd_coff_swap_lineno_out) PARAMS (( - bfd *abfd, - PTR in, - PTR ext)); - - unsigned int (*_bfd_coff_swap_reloc_out) PARAMS (( - bfd *abfd, - PTR src, - PTR dst)); - - unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS (( - bfd *abfd, - PTR in, - PTR out)); - - unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS (( - bfd *abfd, - PTR in, - PTR out)); - - unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS (( - bfd *abfd, - PTR in, - PTR out)); - -@end example -Special entry points for generic COFF routines to call target -dependent COFF routines: -@example - unsigned int _bfd_filhsz; - unsigned int _bfd_aoutsz; - unsigned int _bfd_scnhsz; - unsigned int _bfd_symesz; - unsigned int _bfd_auxesz; - unsigned int _bfd_relsz; - unsigned int _bfd_linesz; - boolean _bfd_coff_long_filenames; - boolean _bfd_coff_long_section_names; - unsigned int _bfd_coff_default_section_alignment_power; - void (*_bfd_coff_swap_filehdr_in) PARAMS (( - bfd *abfd, - PTR ext, - PTR in)); - void (*_bfd_coff_swap_aouthdr_in) PARAMS (( - bfd *abfd, - PTR ext, - PTR in)); - void (*_bfd_coff_swap_scnhdr_in) PARAMS (( - bfd *abfd, - PTR ext, - PTR in)); - void (*_bfd_coff_swap_reloc_in) PARAMS (( - bfd *abfd, - PTR ext, - PTR in)); - boolean (*_bfd_coff_bad_format_hook) PARAMS (( - bfd *abfd, - PTR internal_filehdr)); - boolean (*_bfd_coff_set_arch_mach_hook) PARAMS (( - bfd *abfd, - PTR internal_filehdr)); - PTR (*_bfd_coff_mkobject_hook) PARAMS (( - bfd *abfd, - PTR internal_filehdr, - PTR internal_aouthdr)); - flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( - bfd *abfd, - PTR internal_scnhdr, - const char *name)); - void (*_bfd_set_alignment_hook) PARAMS (( - bfd *abfd, - asection *sec, - PTR internal_scnhdr)); - boolean (*_bfd_coff_slurp_symbol_table) PARAMS (( - bfd *abfd)); - boolean (*_bfd_coff_symname_in_debug) PARAMS (( - bfd *abfd, - struct internal_syment *sym)); - boolean (*_bfd_coff_pointerize_aux_hook) PARAMS (( - bfd *abfd, - combined_entry_type *table_base, - combined_entry_type *symbol, - unsigned int indaux, - combined_entry_type *aux)); - boolean (*_bfd_coff_print_aux) PARAMS (( - bfd *abfd, - FILE *file, - combined_entry_type *table_base, - combined_entry_type *symbol, - combined_entry_type *aux, - unsigned int indaux)); - void (*_bfd_coff_reloc16_extra_cases) PARAMS (( - bfd *abfd, - struct bfd_link_info *link_info, - struct bfd_link_order *link_order, - arelent *reloc, - bfd_byte *data, - unsigned int *src_ptr, - unsigned int *dst_ptr)); - int (*_bfd_coff_reloc16_estimate) PARAMS (( - bfd *abfd, - asection *input_section, - arelent *r, - unsigned int shrink, - struct bfd_link_info *link_info)); - boolean (*_bfd_coff_sym_is_global) PARAMS (( - bfd *abfd, - struct internal_syment *)); - boolean (*_bfd_coff_compute_section_file_positions) PARAMS (( - bfd *abfd)); - boolean (*_bfd_coff_start_final_link) PARAMS (( - bfd *output_bfd, - struct bfd_link_info *info)); - boolean (*_bfd_coff_relocate_section) PARAMS (( - bfd *output_bfd, - struct bfd_link_info *info, - bfd *input_bfd, - asection *input_section, - bfd_byte *contents, - struct internal_reloc *relocs, - struct internal_syment *syms, - asection **sections)); - reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS (( - bfd *abfd, - asection *sec, - struct internal_reloc *rel, - struct coff_link_hash_entry *h, - struct internal_syment *sym, - bfd_vma *addendp)); - boolean (*_bfd_coff_adjust_symndx) PARAMS (( - bfd *obfd, - struct bfd_link_info *info, - bfd *ibfd, - asection *sec, - struct internal_reloc *reloc, - boolean *adjustedp)); - boolean (*_bfd_coff_link_add_one_symbol) PARAMS (( - struct bfd_link_info *info, - bfd *abfd, - const char *name, - flagword flags, - asection *section, - bfd_vma value, - const char *string, - boolean copy, - boolean collect, - struct bfd_link_hash_entry **hashp)); - - boolean (*_bfd_coff_link_output_has_begun) PARAMS (( - bfd * abfd )); - boolean (*_bfd_coff_final_link_postscript) PARAMS (( - bfd * abfd, - struct coff_final_link_info * pfinfo)); - -@} bfd_coff_backend_data; - -#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data) - -#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \ - ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i)) - -#define bfd_coff_swap_sym_in(a,e,i) \ - ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i)) - -#define bfd_coff_swap_lineno_in(a,e,i) \ - ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i)) - -#define bfd_coff_swap_reloc_out(abfd, i, o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o)) - -#define bfd_coff_swap_lineno_out(abfd, i, o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o)) - -#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \ - ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o)) - -#define bfd_coff_swap_sym_out(abfd, i,o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o)) - -#define bfd_coff_swap_scnhdr_out(abfd, i,o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o)) - -#define bfd_coff_swap_filehdr_out(abfd, i,o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o)) - -#define bfd_coff_swap_aouthdr_out(abfd, i,o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o)) - -#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz) -#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz) -#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz) -#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz) -#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz) -#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz) -#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz) -#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames) -#define bfd_coff_long_section_names(abfd) \ - (coff_backend_info (abfd)->_bfd_coff_long_section_names) -#define bfd_coff_default_section_alignment_power(abfd) \ - (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) -#define bfd_coff_swap_filehdr_in(abfd, i,o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) - -#define bfd_coff_swap_aouthdr_in(abfd, i,o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o)) - -#define bfd_coff_swap_scnhdr_in(abfd, i,o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o)) - -#define bfd_coff_swap_reloc_in(abfd, i, o) \ - ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o)) - -#define bfd_coff_bad_format_hook(abfd, filehdr) \ - ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr)) - -#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\ - ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr)) -#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ - ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr)) - -#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\ - ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name)) - -#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\ - ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr)) - -#define bfd_coff_slurp_symbol_table(abfd)\ - ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd)) - -#define bfd_coff_symname_in_debug(abfd, sym)\ - ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym)) - -#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\ - ((coff_backend_info (abfd)->_bfd_coff_print_aux)\ - (abfd, file, base, symbol, aux, indaux)) - -#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\ - ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\ - (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)) - -#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\ - ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\ - (abfd, section, reloc, shrink, link_info)) - -#define bfd_coff_sym_is_global(abfd, sym)\ - ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\ - (abfd, sym)) - -#define bfd_coff_compute_section_file_positions(abfd)\ - ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\ - (abfd)) - -#define bfd_coff_start_final_link(obfd, info)\ - ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\ - (obfd, info)) -#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\ - ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\ - (obfd, info, ibfd, o, con, rel, isyms, secs)) -#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\ - ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\ - (abfd, sec, rel, h, sym, addendp)) -#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ - ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ - (obfd, info, ibfd, sec, rel, adjustedp)) -#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\ - ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\ - (info, abfd, name, flags, section, value, string, cp, coll, hashp)) - -#define bfd_coff_link_output_has_begun(a) \ - ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a)) -#define bfd_coff_final_link_postscript(a,p) \ - ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p)) - -@end example -@subsubsection Writing relocations -To write relocations, the back end steps though the -canonical relocation table and create an -@code{internal_reloc}. The symbol index to use is removed from -the @code{offset} field in the symbol table supplied. The -address comes directly from the sum of the section base -address and the relocation offset; the type is dug directly -from the howto field. Then the @code{internal_reloc} is -swapped into the shape of an @code{external_reloc} and written -out to disk. - -@subsubsection Reading linenumbers -Creating the linenumber table is done by reading in the entire -coff linenumber table, and creating another table for internal use. - -A coff linenumber table is structured so that each function -is marked as having a line number of 0. Each line within the -function is an offset from the first line in the function. The -base of the line number information for the table is stored in -the symbol associated with the function. - -The information is copied from the external to the internal -table, and each symbol which marks a function is marked by -pointing its... - -How does this work ? - -@subsubsection Reading relocations -Coff relocations are easily transformed into the internal BFD form -(@code{arelent}). - -Reading a coff relocation table is done in the following stages: - -@itemize @bullet - -@item -Read the entire coff relocation table into memory. - -@item -Process each relocation in turn; first swap it from the -external to the internal form. - -@item -Turn the symbol referenced in the relocation's symbol index -into a pointer into the canonical symbol table. -This table is the same as the one returned by a call to -@code{bfd_canonicalize_symtab}. The back end will call that -routine and save the result if a canonicalization hasn't been done. - -@item -The reloc index is turned into a pointer to a howto -structure, in a back end specific way. For instance, the 386 -and 960 use the @code{r_type} to directly produce an index -into a howto table vector; the 88k subtracts a number from the -@code{r_type} field and creates an addend field. -@end itemize - diff --git a/contrib/binutils/bfd/doc/core.texi b/contrib/binutils/bfd/doc/core.texi deleted file mode 100644 index 55e369ab2ac6..000000000000 --- a/contrib/binutils/bfd/doc/core.texi +++ /dev/null @@ -1,38 +0,0 @@ -@section Core files - - -@strong{Description}@* -These are functions pertaining to core files. - -@findex bfd_core_file_failing_command -@subsubsection @code{bfd_core_file_failing_command} -@strong{Synopsis} -@example -CONST char *bfd_core_file_failing_command(bfd *abfd); -@end example -@strong{Description}@* -Return a read-only string explaining which program was running -when it failed and produced the core file @var{abfd}. - -@findex bfd_core_file_failing_signal -@subsubsection @code{bfd_core_file_failing_signal} -@strong{Synopsis} -@example -int bfd_core_file_failing_signal(bfd *abfd); -@end example -@strong{Description}@* -Returns the signal number which caused the core dump which -generated the file the BFD @var{abfd} is attached to. - -@findex core_file_matches_executable_p -@subsubsection @code{core_file_matches_executable_p} -@strong{Synopsis} -@example -boolean core_file_matches_executable_p - (bfd *core_bfd, bfd *exec_bfd); -@end example -@strong{Description}@* -Return @code{true} if the core file attached to @var{core_bfd} -was generated by a run of the executable file attached to -@var{exec_bfd}, @code{false} otherwise. - diff --git a/contrib/binutils/bfd/doc/elf.texi b/contrib/binutils/bfd/doc/elf.texi deleted file mode 100644 index 4f9434cf69d4..000000000000 --- a/contrib/binutils/bfd/doc/elf.texi +++ /dev/null @@ -1,22 +0,0 @@ -@section ELF backends -BFD support for ELF formats is being worked on. -Currently, the best supported back ends are for sparc and i386 -(running svr4 or Solaris 2). - -Documentation of the internals of the support code still needs -to be written. The code is changing quickly enough that we -haven't bothered yet. - -@findex bfd_elf_find_section -@subsubsection @code{bfd_elf_find_section} -@strong{Synopsis} -@example -struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name); -@end example -@strong{Description}@* -Helper functions for GDB to locate the string tables. -Since BFD hides string tables from callers, GDB needs to use an -internal hook to find them. Sun's .stabstr, in particular, -isn't even pointed to by the .stab section, so ordinary -mechanisms wouldn't work to find it, even if we had some. - diff --git a/contrib/binutils/bfd/doc/elfcode.texi b/contrib/binutils/bfd/doc/elfcode.texi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/contrib/binutils/bfd/doc/format.texi b/contrib/binutils/bfd/doc/format.texi deleted file mode 100644 index 3281c36eac8c..000000000000 --- a/contrib/binutils/bfd/doc/format.texi +++ /dev/null @@ -1,108 +0,0 @@ -@section File formats -A format is a BFD concept of high level file contents type. The -formats supported by BFD are: - -@itemize @bullet - -@item -@code{bfd_object} -@end itemize -The BFD may contain data, symbols, relocations and debug info. - -@itemize @bullet - -@item -@code{bfd_archive} -@end itemize -The BFD contains other BFDs and an optional index. - -@itemize @bullet - -@item -@code{bfd_core} -@end itemize -The BFD contains the result of an executable core dump. - -@findex bfd_check_format -@subsubsection @code{bfd_check_format} -@strong{Synopsis} -@example -boolean bfd_check_format(bfd *abfd, bfd_format format); -@end example -@strong{Description}@* -Verify if the file attached to the BFD @var{abfd} is compatible -with the format @var{format} (i.e., one of @code{bfd_object}, -@code{bfd_archive} or @code{bfd_core}). - -If the BFD has been set to a specific target before the -call, only the named target and format combination is -checked. If the target has not been set, or has been set to -@code{default}, then all the known target backends is -interrogated to determine a match. If the default target -matches, it is used. If not, exactly one target must recognize -the file, or an error results. - -The function returns @code{true} on success, otherwise @code{false} -with one of the following error codes: - -@itemize @bullet - -@item -@code{bfd_error_invalid_operation} - -if @code{format} is not one of @code{bfd_object}, @code{bfd_archive} or -@code{bfd_core}. - -@item -@code{bfd_error_system_call} - -if an error occured during a read - even some file mismatches -can cause bfd_error_system_calls. - -@item -@code{file_not_recognised} - -none of the backends recognised the file format. - -@item -@code{bfd_error_file_ambiguously_recognized} - -more than one backend recognised the file format. -@end itemize - -@findex bfd_check_format_matches -@subsubsection @code{bfd_check_format_matches} -@strong{Synopsis} -@example -boolean bfd_check_format_matches(bfd *abfd, bfd_format format, char ***matching); -@end example -@strong{Description}@* -Like @code{bfd_check_format}, except when it returns false with -@code{bfd_errno} set to @code{bfd_error_file_ambiguously_recognized}. In that -case, if @var{matching} is not NULL, it will be filled in with -a NULL-terminated list of the names of the formats that matched, -allocated with @code{malloc}. -Then the user may choose a format and try again. - -When done with the list that @var{matching} points to, the caller -should free it. - -@findex bfd_set_format -@subsubsection @code{bfd_set_format} -@strong{Synopsis} -@example -boolean bfd_set_format(bfd *abfd, bfd_format format); -@end example -@strong{Description}@* -This function sets the file format of the BFD @var{abfd} to the -format @var{format}. If the target set in the BFD does not -support the format requested, the format is invalid, or the BFD -is not open for writing, then an error occurs. - -@findex bfd_format_string -@subsubsection @code{bfd_format_string} -@strong{Synopsis} -@example -CONST char *bfd_format_string(bfd_format format); -@end example -@strong{Description}@* -Return a pointer to a const string -@code{invalid}, @code{object}, @code{archive}, @code{core}, or @code{unknown}, -depending upon the value of @var{format}. - diff --git a/contrib/binutils/bfd/doc/hash.texi b/contrib/binutils/bfd/doc/hash.texi deleted file mode 100644 index 45d63e0e6253..000000000000 --- a/contrib/binutils/bfd/doc/hash.texi +++ /dev/null @@ -1,245 +0,0 @@ -@section Hash Tables -@cindex Hash tables -BFD provides a simple set of hash table functions. Routines -are provided to initialize a hash table, to free a hash table, -to look up a string in a hash table and optionally create an -entry for it, and to traverse a hash table. There is -currently no routine to delete an string from a hash table. - -The basic hash table does not permit any data to be stored -with a string. However, a hash table is designed to present a -base class from which other types of hash tables may be -derived. These derived types may store additional information -with the string. Hash tables were implemented in this way, -rather than simply providing a data pointer in a hash table -entry, because they were designed for use by the linker back -ends. The linker may create thousands of hash table entries, -and the overhead of allocating private data and storing and -following pointers becomes noticeable. - -The basic hash table code is in @code{hash.c}. - -@menu -* Creating and Freeing a Hash Table:: -* Looking Up or Entering a String:: -* Traversing a Hash Table:: -* Deriving a New Hash Table Type:: -@end menu - -@node Creating and Freeing a Hash Table, Looking Up or Entering a String, Hash Tables, Hash Tables -@subsection Creating and freeing a hash table -@findex bfd_hash_table_init -@findex bfd_hash_table_init_n -To create a hash table, create an instance of a @code{struct -bfd_hash_table} (defined in @code{bfd.h}) and call -@code{bfd_hash_table_init} (if you know approximately how many -entries you will need, the function @code{bfd_hash_table_init_n}, -which takes a @var{size} argument, may be used). -@code{bfd_hash_table_init} returns @code{false} if some sort of -error occurs. - -@findex bfd_hash_newfunc -The function @code{bfd_hash_table_init} take as an argument a -function to use to create new entries. For a basic hash -table, use the function @code{bfd_hash_newfunc}. @xref{Deriving -a New Hash Table Type} for why you would want to use a -different value for this argument. - -@findex bfd_hash_allocate -@code{bfd_hash_table_init} will create an objalloc which will be -used to allocate new entries. You may allocate memory on this -objalloc using @code{bfd_hash_allocate}. - -@findex bfd_hash_table_free -Use @code{bfd_hash_table_free} to free up all the memory that has -been allocated for a hash table. This will not free up the -@code{struct bfd_hash_table} itself, which you must provide. - -@node Looking Up or Entering a String, Traversing a Hash Table, Creating and Freeing a Hash Table, Hash Tables -@subsection Looking up or entering a string -@findex bfd_hash_lookup -The function @code{bfd_hash_lookup} is used both to look up a -string in the hash table and to create a new entry. - -If the @var{create} argument is @code{false}, @code{bfd_hash_lookup} -will look up a string. If the string is found, it will -returns a pointer to a @code{struct bfd_hash_entry}. If the -string is not found in the table @code{bfd_hash_lookup} will -return @code{NULL}. You should not modify any of the fields in -the returns @code{struct bfd_hash_entry}. - -If the @var{create} argument is @code{true}, the string will be -entered into the hash table if it is not already there. -Either way a pointer to a @code{struct bfd_hash_entry} will be -returned, either to the existing structure or to a newly -created one. In this case, a @code{NULL} return means that an -error occurred. - -If the @var{create} argument is @code{true}, and a new entry is -created, the @var{copy} argument is used to decide whether to -copy the string onto the hash table objalloc or not. If -@var{copy} is passed as @code{false}, you must be careful not to -deallocate or modify the string as long as the hash table -exists. - -@node Traversing a Hash Table, Deriving a New Hash Table Type, Looking Up or Entering a String, Hash Tables -@subsection Traversing a hash table -@findex bfd_hash_traverse -The function @code{bfd_hash_traverse} may be used to traverse a -hash table, calling a function on each element. The traversal -is done in a random order. - -@code{bfd_hash_traverse} takes as arguments a function and a -generic @code{void *} pointer. The function is called with a -hash table entry (a @code{struct bfd_hash_entry *}) and the -generic pointer passed to @code{bfd_hash_traverse}. The function -must return a @code{boolean} value, which indicates whether to -continue traversing the hash table. If the function returns -@code{false}, @code{bfd_hash_traverse} will stop the traversal and -return immediately. - -@node Deriving a New Hash Table Type, , Traversing a Hash Table, Hash Tables -@subsection Deriving a new hash table type -Many uses of hash tables want to store additional information -which each entry in the hash table. Some also find it -convenient to store additional information with the hash table -itself. This may be done using a derived hash table. - -Since C is not an object oriented language, creating a derived -hash table requires sticking together some boilerplate -routines with a few differences specific to the type of hash -table you want to create. - -An example of a derived hash table is the linker hash table. -The structures for this are defined in @code{bfdlink.h}. The -functions are in @code{linker.c}. - -You may also derive a hash table from an already derived hash -table. For example, the a.out linker backend code uses a hash -table derived from the linker hash table. - -@menu -* Define the Derived Structures:: -* Write the Derived Creation Routine:: -* Write Other Derived Routines:: -@end menu - -@node Define the Derived Structures, Write the Derived Creation Routine, Deriving a New Hash Table Type, Deriving a New Hash Table Type -@subsubsection Define the derived structures -You must define a structure for an entry in the hash table, -and a structure for the hash table itself. - -The first field in the structure for an entry in the hash -table must be of the type used for an entry in the hash table -you are deriving from. If you are deriving from a basic hash -table this is @code{struct bfd_hash_entry}, which is defined in -@code{bfd.h}. The first field in the structure for the hash -table itself must be of the type of the hash table you are -deriving from itself. If you are deriving from a basic hash -table, this is @code{struct bfd_hash_table}. - -For example, the linker hash table defines @code{struct -bfd_link_hash_entry} (in @code{bfdlink.h}). The first field, -@code{root}, is of type @code{struct bfd_hash_entry}. Similarly, -the first field in @code{struct bfd_link_hash_table}, @code{table}, -is of type @code{struct bfd_hash_table}. - -@node Write the Derived Creation Routine, Write Other Derived Routines, Define the Derived Structures, Deriving a New Hash Table Type -@subsubsection Write the derived creation routine -You must write a routine which will create and initialize an -entry in the hash table. This routine is passed as the -function argument to @code{bfd_hash_table_init}. - -In order to permit other hash tables to be derived from the -hash table you are creating, this routine must be written in a -standard way. - -The first argument to the creation routine is a pointer to a -hash table entry. This may be @code{NULL}, in which case the -routine should allocate the right amount of space. Otherwise -the space has already been allocated by a hash table type -derived from this one. - -After allocating space, the creation routine must call the -creation routine of the hash table type it is derived from, -passing in a pointer to the space it just allocated. This -will initialize any fields used by the base hash table. - -Finally the creation routine must initialize any local fields -for the new hash table type. - -Here is a boilerplate example of a creation routine. -@var{function_name} is the name of the routine. -@var{entry_type} is the type of an entry in the hash table you -are creating. @var{base_newfunc} is the name of the creation -routine of the hash table type your hash table is derived -from. - - -@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; -@} -@end example -@strong{Description}@* -The creation routine for the linker hash table, which is in -@code{linker.c}, looks just like this example. -@var{function_name} is @code{_bfd_link_hash_newfunc}. -@var{entry_type} is @code{struct bfd_link_hash_entry}. -@var{base_newfunc} is @code{bfd_hash_newfunc}, the creation -routine for a basic hash table. - -@code{_bfd_link_hash_newfunc} also initializes the local fields -in a linker hash table entry: @code{type}, @code{written} and -@code{next}. - -@node Write Other Derived Routines, , Write the Derived Creation Routine, Deriving a New Hash Table Type -@subsubsection Write other derived routines -You will want to write other routines for your new hash table, -as well. - -You will want an initialization routine which calls the -initialization routine of the hash table you are deriving from -and initializes any other local fields. For the linker hash -table, this is @code{_bfd_link_hash_table_init} in @code{linker.c}. - -You will want a lookup routine which calls the lookup routine -of the hash table you are deriving from and casts the result. -The linker hash table uses @code{bfd_link_hash_lookup} in -@code{linker.c} (this actually takes an additional argument which -it uses to decide how to return the looked up value). - -You may want a traversal routine. This should just call the -traversal routine of the hash table you are deriving from with -appropriate casts. The linker hash table uses -@code{bfd_link_hash_traverse} in @code{linker.c}. - -These routines may simply be defined as macros. For example, -the a.out backend linker hash table, which is derived from the -linker hash table, uses macros for the lookup and traversal -routines. These are @code{aout_link_hash_lookup} and -@code{aout_link_hash_traverse} in aoutx.h. - diff --git a/contrib/binutils/bfd/doc/init.texi b/contrib/binutils/bfd/doc/init.texi deleted file mode 100644 index e561a7720f7d..000000000000 --- a/contrib/binutils/bfd/doc/init.texi +++ /dev/null @@ -1,13 +0,0 @@ -@section Initialization -These are the functions that handle initializing a BFD. - -@findex bfd_init -@subsubsection @code{bfd_init} -@strong{Synopsis} -@example -void bfd_init(void); -@end example -@strong{Description}@* -This routine must be called before any other BFD function to -initialize magical internal data structures. - diff --git a/contrib/binutils/bfd/doc/libbfd.texi b/contrib/binutils/bfd/doc/libbfd.texi deleted file mode 100644 index 6bee5b50c9cf..000000000000 --- a/contrib/binutils/bfd/doc/libbfd.texi +++ /dev/null @@ -1,142 +0,0 @@ -@section Internal functions - - -@strong{Description}@* -These routines are used within BFD. -They are not intended for export, but are documented here for -completeness. - -@findex bfd_write_bigendian_4byte_int -@subsubsection @code{bfd_write_bigendian_4byte_int} -@strong{Synopsis} -@example -void bfd_write_bigendian_4byte_int(bfd *abfd, int i); -@end example -@strong{Description}@* -Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big -endian order regardless of what else is going on. This is useful in -archives. - -@findex bfd_put_size -@subsubsection @code{bfd_put_size} -@findex bfd_get_size -@subsubsection @code{bfd_get_size} -@strong{Description}@* -These macros as used for reading and writing raw data in -sections; each access (except for bytes) is vectored through -the target format of the BFD and mangled accordingly. The -mangling performs any necessary endian translations and -removes alignment restrictions. Note that types accepted and -returned by these macros are identical so they can be swapped -around in macros---for example, @file{libaout.h} defines @code{GET_WORD} -to either @code{bfd_get_32} or @code{bfd_get_64}. - -In the put routines, @var{val} must be a @code{bfd_vma}. If we are on a -system without prototypes, the caller is responsible for making -sure that is true, with a cast if necessary. We don't cast -them in the macro definitions because that would prevent @code{lint} -or @code{gcc -Wall} from detecting sins such as passing a pointer. -To detect calling these with less than a @code{bfd_vma}, use -@code{gcc -Wconversion} on a host with 64 bit @code{bfd_vma}'s. -@example - - /* Byte swapping macros for user section data. */ - -#define bfd_put_8(abfd, val, ptr) \ - (*((unsigned char *)(ptr)) = (unsigned char)(val)) -#define bfd_put_signed_8 \ - bfd_put_8 -#define bfd_get_8(abfd, ptr) \ - (*(unsigned char *)(ptr)) -#define bfd_get_signed_8(abfd, ptr) \ - ((*(unsigned char *)(ptr) ^ 0x80) - 0x80) - -#define bfd_put_16(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx16, ((val),(ptr))) -#define bfd_put_signed_16 \ - bfd_put_16 -#define bfd_get_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx16, (ptr)) -#define bfd_get_signed_16(abfd, ptr) \ - BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) - -#define bfd_put_32(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx32, ((val),(ptr))) -#define bfd_put_signed_32 \ - bfd_put_32 -#define bfd_get_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx32, (ptr)) -#define bfd_get_signed_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx_signed_32, (ptr)) - -#define bfd_put_64(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx64, ((val), (ptr))) -#define bfd_put_signed_64 \ - bfd_put_64 -#define bfd_get_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx64, (ptr)) -#define bfd_get_signed_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx_signed_64, (ptr)) - -@end example - -@findex bfd_h_put_size -@subsubsection @code{bfd_h_put_size} -@strong{Description}@* -These macros have the same function as their @code{bfd_get_x} -bretheren, except that they are used for removing information -for the header records of object files. Believe it or not, -some object files keep their header records in big endian -order and their data in little endian order. -@example - - /* Byte swapping macros for file header data. */ - -#define bfd_h_put_8(abfd, val, ptr) \ - bfd_put_8 (abfd, val, ptr) -#define bfd_h_put_signed_8(abfd, val, ptr) \ - bfd_put_8 (abfd, val, ptr) -#define bfd_h_get_8(abfd, ptr) \ - bfd_get_8 (abfd, ptr) -#define bfd_h_get_signed_8(abfd, ptr) \ - bfd_get_signed_8 (abfd, ptr) - -#define bfd_h_put_16(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx16,(val,ptr)) -#define bfd_h_put_signed_16 \ - bfd_h_put_16 -#define bfd_h_get_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx16,(ptr)) -#define bfd_h_get_signed_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr)) - -#define bfd_h_put_32(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx32,(val,ptr)) -#define bfd_h_put_signed_32 \ - bfd_h_put_32 -#define bfd_h_get_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx32,(ptr)) -#define bfd_h_get_signed_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr)) - -#define bfd_h_put_64(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx64,(val, ptr)) -#define bfd_h_put_signed_64 \ - bfd_h_put_64 -#define bfd_h_get_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx64,(ptr)) -#define bfd_h_get_signed_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr)) - -@end example - -@findex bfd_log2 -@subsubsection @code{bfd_log2} -@strong{Synopsis} -@example -unsigned int bfd_log2(bfd_vma x); -@end example -@strong{Description}@* -Return the log base 2 of the value supplied, rounded up. E.g., an -@var{x} of 1025 returns 11. - diff --git a/contrib/binutils/bfd/doc/linker.texi b/contrib/binutils/bfd/doc/linker.texi deleted file mode 100644 index 0de907dfe6d7..000000000000 --- a/contrib/binutils/bfd/doc/linker.texi +++ /dev/null @@ -1,365 +0,0 @@ -@section Linker Functions -@cindex Linker -The linker uses three special entry points in the BFD target -vector. It is not necessary to write special routines for -these entry points when creating a new BFD back end, since -generic versions are provided. However, writing them can -speed up linking and make it use significantly less runtime -memory. - -The first routine creates a hash table used by the other -routines. The second routine adds the symbols from an object -file to the hash table. The third routine takes all the -object files and links them together to create the output -file. These routines are designed so that the linker proper -does not need to know anything about the symbols in the object -files that it is linking. The linker merely arranges the -sections as directed by the linker script and lets BFD handle -the details of symbols and relocs. - -The second routine and third routines are passed a pointer to -a @code{struct bfd_link_info} structure (defined in -@code{bfdlink.h}) which holds information relevant to the link, -including the linker hash table (which was created by the -first routine) and a set of callback functions to the linker -proper. - -The generic linker routines are in @code{linker.c}, and use the -header file @code{genlink.h}. As of this writing, the only back -ends which have implemented versions of these routines are -a.out (in @code{aoutx.h}) and ECOFF (in @code{ecoff.c}). The a.out -routines are used as examples throughout this section. - -@menu -* Creating a Linker Hash Table:: -* Adding Symbols to the Hash Table:: -* Performing the Final Link:: -@end menu - -@node Creating a Linker Hash Table, Adding Symbols to the Hash Table, Linker Functions, Linker Functions -@subsection Creating a linker hash table -@cindex _bfd_link_hash_table_create in target vector -@cindex target vector (_bfd_link_hash_table_create) -The linker routines must create a hash table, which must be -derived from @code{struct bfd_link_hash_table} described in -@code{bfdlink.c}. @xref{Hash Tables} for information on how to -create a derived hash table. This entry point is called using -the target vector of the linker output file. - -The @code{_bfd_link_hash_table_create} entry point must allocate -and initialize an instance of the desired hash table. If the -back end does not require any additional information to be -stored with the entries in the hash table, the entry point may -simply create a @code{struct bfd_link_hash_table}. Most likely, -however, some additional information will be needed. - -For example, with each entry in the hash table the a.out -linker keeps the index the symbol has in the final output file -(this index number is used so that when doing a relocateable -link the symbol index used in the output file can be quickly -filled in when copying over a reloc). The a.out linker code -defines the required structures and functions for a hash table -derived from @code{struct bfd_link_hash_table}. The a.out linker -hash table is created by the function -@code{NAME(aout,link_hash_table_create)}; it simply allocates -space for the hash table, initializes it, and returns a -pointer to it. - -When writing the linker routines for a new back end, you will -generally not know exactly which fields will be required until -you have finished. You should simply create a new hash table -which defines no additional fields, and then simply add fields -as they become necessary. - -@node Adding Symbols to the Hash Table, Performing the Final Link, Creating a Linker Hash Table, Linker Functions -@subsection Adding symbols to the hash table -@cindex _bfd_link_add_symbols in target vector -@cindex target vector (_bfd_link_add_symbols) -The linker proper will call the @code{_bfd_link_add_symbols} -entry point for each object file or archive which is to be -linked (typically these are the files named on the command -line, but some may also come from the linker script). The -entry point is responsible for examining the file. For an -object file, BFD must add any relevant symbol information to -the hash table. For an archive, BFD must determine which -elements of the archive should be used and adding them to the -link. - -The a.out version of this entry point is -@code{NAME(aout,link_add_symbols)}. - -@menu -* Differing file formats:: -* Adding symbols from an object file:: -* Adding symbols from an archive:: -@end menu - -@node Differing file formats, Adding symbols from an object file, Adding Symbols to the Hash Table, Adding Symbols to the Hash Table -@subsubsection Differing file formats -Normally all the files involved in a link will be of the same -format, but it is also possible to link together different -format object files, and the back end must support that. The -@code{_bfd_link_add_symbols} entry point is called via the target -vector of the file to be added. This has an important -consequence: the function may not assume that the hash table -is the type created by the corresponding -@code{_bfd_link_hash_table_create} vector. All the -@code{_bfd_link_add_symbols} function can assume about the hash -table is that it is derived from @code{struct -bfd_link_hash_table}. - -Sometimes the @code{_bfd_link_add_symbols} function must store -some information in the hash table entry to be used by the -@code{_bfd_final_link} function. In such a case the @code{creator} -field of the hash table must be checked to make sure that the -hash table was created by an object file of the same format. - -The @code{_bfd_final_link} routine must be prepared to handle a -hash entry without any extra information added by the -@code{_bfd_link_add_symbols} function. A hash entry without -extra information will also occur when the linker script -directs the linker to create a symbol. Note that, regardless -of how a hash table entry is added, all the fields will be -initialized to some sort of null value by the hash table entry -initialization function. - -See @code{ecoff_link_add_externals} for an example of how to -check the @code{creator} field before saving information (in this -case, the ECOFF external symbol debugging information) in a -hash table entry. - -@node Adding symbols from an object file, Adding symbols from an archive, Differing file formats, Adding Symbols to the Hash Table -@subsubsection Adding symbols from an object file -When the @code{_bfd_link_add_symbols} routine is passed an object -file, it must add all externally visible symbols in that -object file to the hash table. The actual work of adding the -symbol to the hash table is normally handled by the function -@code{_bfd_generic_link_add_one_symbol}. The -@code{_bfd_link_add_symbols} routine is responsible for reading -all the symbols from the object file and passing the correct -information to @code{_bfd_generic_link_add_one_symbol}. - -The @code{_bfd_link_add_symbols} routine should not use -@code{bfd_canonicalize_symtab} to read the symbols. The point of -providing this routine is to avoid the overhead of converting -the symbols into generic @code{asymbol} structures. - -@findex _bfd_generic_link_add_one_symbol -@code{_bfd_generic_link_add_one_symbol} handles the details of -combining common symbols, warning about multiple definitions, -and so forth. It takes arguments which describe the symbol to -add, notably symbol flags, a section, and an offset. The -symbol flags include such things as @code{BSF_WEAK} or -@code{BSF_INDIRECT}. The section is a section in the object -file, or something like @code{bfd_und_section_ptr} for an undefined -symbol or @code{bfd_com_section_ptr} for a common symbol. - -If the @code{_bfd_final_link} routine is also going to need to -read the symbol information, the @code{_bfd_link_add_symbols} -routine should save it somewhere attached to the object file -BFD. However, the information should only be saved if the -@code{keep_memory} field of the @code{info} argument is true, so -that the @code{-no-keep-memory} linker switch is effective. - -The a.out function which adds symbols from an object file is -@code{aout_link_add_object_symbols}, and most of the interesting -work is in @code{aout_link_add_symbols}. The latter saves -pointers to the hash tables entries created by -@code{_bfd_generic_link_add_one_symbol} indexed by symbol number, -so that the @code{_bfd_final_link} routine does not have to call -the hash table lookup routine to locate the entry. - -@node Adding symbols from an archive, , Adding symbols from an object file, Adding Symbols to the Hash Table -@subsubsection Adding symbols from an archive -When the @code{_bfd_link_add_symbols} routine is passed an -archive, it must look through the symbols defined by the -archive and decide which elements of the archive should be -included in the link. For each such element it must call the -@code{add_archive_element} linker callback, and it must add the -symbols from the object file to the linker hash table. - -@findex _bfd_generic_link_add_archive_symbols -In most cases the work of looking through the symbols in the -archive should be done by the -@code{_bfd_generic_link_add_archive_symbols} function. This -function builds a hash table from the archive symbol table and -looks through the list of undefined symbols to see which -elements should be included. -@code{_bfd_generic_link_add_archive_symbols} is passed a function -to call to make the final decision about adding an archive -element to the link and to do the actual work of adding the -symbols to the linker hash table. - -The function passed to -@code{_bfd_generic_link_add_archive_symbols} must read the -symbols of the archive element and decide whether the archive -element should be included in the link. If the element is to -be included, the @code{add_archive_element} linker callback -routine must be called with the element as an argument, and -the elements symbols must be added to the linker hash table -just as though the element had itself been passed to the -@code{_bfd_link_add_symbols} function. - -When the a.out @code{_bfd_link_add_symbols} function receives an -archive, it calls @code{_bfd_generic_link_add_archive_symbols} -passing @code{aout_link_check_archive_element} as the function -argument. @code{aout_link_check_archive_element} calls -@code{aout_link_check_ar_symbols}. If the latter decides to add -the element (an element is only added if it provides a real, -non-common, definition for a previously undefined or common -symbol) it calls the @code{add_archive_element} callback and then -@code{aout_link_check_archive_element} calls -@code{aout_link_add_symbols} to actually add the symbols to the -linker hash table. - -The ECOFF back end is unusual in that it does not normally -call @code{_bfd_generic_link_add_archive_symbols}, because ECOFF -archives already contain a hash table of symbols. The ECOFF -back end searches the archive itself to avoid the overhead of -creating a new hash table. - -@node Performing the Final Link, , Adding Symbols to the Hash Table, Linker Functions -@subsection Performing the final link -@cindex _bfd_link_final_link in target vector -@cindex target vector (_bfd_final_link) -When all the input files have been processed, the linker calls -the @code{_bfd_final_link} entry point of the output BFD. This -routine is responsible for producing the final output file, -which has several aspects. It must relocate the contents of -the input sections and copy the data into the output sections. -It must build an output symbol table including any local -symbols from the input files and the global symbols from the -hash table. When producing relocateable output, it must -modify the input relocs and write them into the output file. -There may also be object format dependent work to be done. - -The linker will also call the @code{write_object_contents} entry -point when the BFD is closed. The two entry points must work -together in order to produce the correct output file. - -The details of how this works are inevitably dependent upon -the specific object file format. The a.out -@code{_bfd_final_link} routine is @code{NAME(aout,final_link)}. - -@menu -* Information provided by the linker:: -* Relocating the section contents:: -* Writing the symbol table:: -@end menu - -@node Information provided by the linker, Relocating the section contents, Performing the Final Link, Performing the Final Link -@subsubsection Information provided by the linker -Before the linker calls the @code{_bfd_final_link} entry point, -it sets up some data structures for the function to use. - -The @code{input_bfds} field of the @code{bfd_link_info} structure -will point to a list of all the input files included in the -link. These files are linked through the @code{link_next} field -of the @code{bfd} structure. - -Each section in the output file will have a list of -@code{link_order} structures attached to the @code{link_order_head} -field (the @code{link_order} structure is defined in -@code{bfdlink.h}). These structures describe how to create the -contents of the output section in terms of the contents of -various input sections, fill constants, and, eventually, other -types of information. They also describe relocs that must be -created by the BFD backend, but do not correspond to any input -file; this is used to support -Ur, which builds constructors -while generating a relocateable object file. - -@node Relocating the section contents, Writing the symbol table, Information provided by the linker, Performing the Final Link -@subsubsection Relocating the section contents -The @code{_bfd_final_link} function should look through the -@code{link_order} structures attached to each section of the -output file. Each @code{link_order} structure should either be -handled specially, or it should be passed to the function -@code{_bfd_default_link_order} which will do the right thing -(@code{_bfd_default_link_order} is defined in @code{linker.c}). - -For efficiency, a @code{link_order} of type -@code{bfd_indirect_link_order} whose associated section belongs -to a BFD of the same format as the output BFD must be handled -specially. This type of @code{link_order} describes part of an -output section in terms of a section belonging to one of the -input files. The @code{_bfd_final_link} function should read the -contents of the section and any associated relocs, apply the -relocs to the section contents, and write out the modified -section contents. If performing a relocateable link, the -relocs themselves must also be modified and written out. - -@findex _bfd_relocate_contents -@findex _bfd_final_link_relocate -The functions @code{_bfd_relocate_contents} and -@code{_bfd_final_link_relocate} provide some general support for -performing the actual relocations, notably overflow checking. -Their arguments include information about the symbol the -relocation is against and a @code{reloc_howto_type} argument -which describes the relocation to perform. These functions -are defined in @code{reloc.c}. - -The a.out function which handles reading, relocating, and -writing section contents is @code{aout_link_input_section}. The -actual relocation is done in @code{aout_link_input_section_std} -and @code{aout_link_input_section_ext}. - -@node Writing the symbol table, , Relocating the section contents, Performing the Final Link -@subsubsection Writing the symbol table -The @code{_bfd_final_link} function must gather all the symbols -in the input files and write them out. It must also write out -all the symbols in the global hash table. This must be -controlled by the @code{strip} and @code{discard} fields of the -@code{bfd_link_info} structure. - -The local symbols of the input files will not have been -entered into the linker hash table. The @code{_bfd_final_link} -routine must consider each input file and include the symbols -in the output file. It may be convenient to do this when -looking through the @code{link_order} structures, or it may be -done by stepping through the @code{input_bfds} list. - -The @code{_bfd_final_link} routine must also traverse the global -hash table to gather all the externally visible symbols. It -is possible that most of the externally visible symbols may be -written out when considering the symbols of each input file, -but it is still necessary to traverse the hash table since the -linker script may have defined some symbols that are not in -any of the input files. - -The @code{strip} field of the @code{bfd_link_info} structure -controls which symbols are written out. The possible values -are listed in @code{bfdlink.h}. If the value is @code{strip_some}, -then the @code{keep_hash} field of the @code{bfd_link_info} -structure is a hash table of symbols to keep; each symbol -should be looked up in this hash table, and only symbols which -are present should be included in the output file. - -If the @code{strip} field of the @code{bfd_link_info} structure -permits local symbols to be written out, the @code{discard} field -is used to further controls which local symbols are included -in the output file. If the value is @code{discard_l}, then all -local symbols which begin with a certain prefix are discarded; -this is controlled by the @code{bfd_is_local_label_name} entry point. - -The a.out backend handles symbols by calling -@code{aout_link_write_symbols} on each input BFD and then -traversing the global hash table with the function -@code{aout_link_write_other_symbol}. It builds a string table -while writing out the symbols, which is written to the output -file at the end of @code{NAME(aout,final_link)}. - -@findex bfd_link_split_section -@subsubsection @code{bfd_link_split_section} -@strong{Synopsis} -@example -boolean bfd_link_split_section(bfd *abfd, asection *sec); -@end example -@strong{Description}@* -Return nonzero if @var{sec} should be split during a -reloceatable or final link. -@example -#define bfd_link_split_section(abfd, sec) \ - BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec)) - -@end example - diff --git a/contrib/binutils/bfd/doc/opncls.texi b/contrib/binutils/bfd/doc/opncls.texi deleted file mode 100644 index 4fbb0a70b130..000000000000 --- a/contrib/binutils/bfd/doc/opncls.texi +++ /dev/null @@ -1,128 +0,0 @@ -@section Opening and closing BFDs - - -@findex bfd_openr -@subsubsection @code{bfd_openr} -@strong{Synopsis} -@example -bfd *bfd_openr(CONST char *filename, CONST char *target); -@end example -@strong{Description}@* -Open the file @var{filename} (using @code{fopen}) with the target -@var{target}. Return a pointer to the created BFD. - -Calls @code{bfd_find_target}, so @var{target} is interpreted as by -that function. - -If @code{NULL} is returned then an error has occured. Possible errors -are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} or @code{system_call} error. - -@findex bfd_fdopenr -@subsubsection @code{bfd_fdopenr} -@strong{Synopsis} -@example -bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd); -@end example -@strong{Description}@* -@code{bfd_fdopenr} is to @code{bfd_fopenr} much like @code{fdopen} is to @code{fopen}. -It opens a BFD on a file already described by the @var{fd} -supplied. - -When the file is later @code{bfd_close}d, the file descriptor will be closed. - -If the caller desires that this file descriptor be cached by BFD -(opened as needed, closed as needed to free descriptors for -other opens), with the supplied @var{fd} used as an initial -file descriptor (but subject to closure at any time), call -bfd_set_cacheable(bfd, 1) on the returned BFD. The default is to -assume no cacheing; the file descriptor will remain open until -@code{bfd_close}, and will not be affected by BFD operations on other -files. - -Possible errors are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} and @code{bfd_error_system_call}. - -@findex bfd_openstreamr -@subsubsection @code{bfd_openstreamr} -@strong{Synopsis} -@example -bfd *bfd_openstreamr(const char *, const char *, PTR); -@end example -@strong{Description}@* -Open a BFD for read access on an existing stdio stream. When -the BFD is passed to @code{bfd_close}, the stream will be closed. - -@findex bfd_openw -@subsubsection @code{bfd_openw} -@strong{Synopsis} -@example -bfd *bfd_openw(CONST char *filename, CONST char *target); -@end example -@strong{Description}@* -Create a BFD, associated with file @var{filename}, using the -file format @var{target}, and return a pointer to it. - -Possible errors are @code{bfd_error_system_call}, @code{bfd_error_no_memory}, -@code{bfd_error_invalid_target}. - -@findex bfd_close -@subsubsection @code{bfd_close} -@strong{Synopsis} -@example -boolean bfd_close(bfd *abfd); -@end example -@strong{Description}@* -Close a BFD. If the BFD was open for writing, -then pending operations are completed and the file written out -and closed. If the created file is executable, then -@code{chmod} is called to mark it as such. - -All memory attached to the BFD is released. - -The file descriptor associated with the BFD is closed (even -if it was passed in to BFD by @code{bfd_fdopenr}). - -@strong{Returns}@* -@code{true} is returned if all is ok, otherwise @code{false}. - -@findex bfd_close_all_done -@subsubsection @code{bfd_close_all_done} -@strong{Synopsis} -@example -boolean bfd_close_all_done(bfd *); -@end example -@strong{Description}@* -Close a BFD. Differs from @code{bfd_close} -since it does not complete any pending operations. This -routine would be used if the application had just used BFD for -swapping and didn't want to use any of the writing code. - -If the created file is executable, then @code{chmod} is called -to mark it as such. - -All memory attached to the BFD is released. - -@strong{Returns}@* -@code{true} is returned if all is ok, otherwise @code{false}. - -@findex bfd_create -@subsubsection @code{bfd_create} -@strong{Synopsis} -@example -bfd *bfd_create(CONST char *filename, bfd *templ); -@end example -@strong{Description}@* -Create a new BFD in the manner of -@code{bfd_openw}, but without opening a file. The new BFD -takes the target from the target used by @var{template}. The -format is always set to @code{bfd_object}. - -@findex bfd_alloc -@subsubsection @code{bfd_alloc} -@strong{Synopsis} -@example -PTR bfd_alloc (bfd *abfd, size_t wanted); -@end example -@strong{Description}@* -Allocate a block of @var{wanted} bytes of memory attached to -@code{abfd} and return a pointer to it. - diff --git a/contrib/binutils/bfd/doc/reloc.texi b/contrib/binutils/bfd/doc/reloc.texi deleted file mode 100644 index fc4970d11fa4..000000000000 --- a/contrib/binutils/bfd/doc/reloc.texi +++ /dev/null @@ -1,998 +0,0 @@ -@section Relocations -BFD maintains relocations in much the same way it maintains -symbols: they are left alone until required, then read in -en-mass and translated into an internal form. A common -routine @code{bfd_perform_relocation} acts upon the -canonical form to do the fixup. - -Relocations are maintained on a per section basis, -while symbols are maintained on a per BFD basis. - -All that a back end has to do to fit the BFD interface is to create -a @code{struct reloc_cache_entry} for each relocation -in a particular section, and fill in the right bits of the structures. - -@menu -* typedef arelent:: -* howto manager:: -@end menu - - -@node typedef arelent, howto manager, Relocations, Relocations -@subsection typedef arelent -This is the structure of a relocation entry: - - -@example - -typedef enum bfd_reloc_status -@{ - /* No errors detected */ - bfd_reloc_ok, - - /* The relocation was performed, but there was an overflow. */ - bfd_reloc_overflow, - - /* The address to relocate was not within the section supplied. */ - bfd_reloc_outofrange, - - /* Used by special functions */ - bfd_reloc_continue, - - /* Unsupported relocation size requested. */ - bfd_reloc_notsupported, - - /* Unused */ - bfd_reloc_other, - - /* The symbol to relocate against was undefined. */ - bfd_reloc_undefined, - - /* The relocation was performed, but may not be ok - presently - generated only when linking i960 coff files with i960 b.out - symbols. If this type is returned, the error_message argument - to bfd_perform_relocation will be set. */ - bfd_reloc_dangerous - @} - bfd_reloc_status_type; - - -typedef struct reloc_cache_entry -@{ - /* A pointer into the canonical table of pointers */ - struct symbol_cache_entry **sym_ptr_ptr; - - /* offset in section */ - bfd_size_type address; - - /* addend for relocation value */ - bfd_vma addend; - - /* Pointer to how to perform the required relocation */ - reloc_howto_type *howto; - -@} arelent; -@end example -@strong{Description}@* -Here is a description of each of the fields within an @code{arelent}: - -@itemize @bullet - -@item -@code{sym_ptr_ptr} -@end itemize -The symbol table pointer points to a pointer to the symbol -associated with the relocation request. It is -the pointer into the table returned by the back end's -@code{get_symtab} action. @xref{Symbols}. The symbol is referenced -through a pointer to a pointer so that tools like the linker -can fix up all the symbols of the same name by modifying only -one pointer. The relocation routine looks in the symbol and -uses the base of the section the symbol is attached to and the -value of the symbol as the initial relocation offset. If the -symbol pointer is zero, then the section provided is looked up. - -@itemize @bullet - -@item -@code{address} -@end itemize -The @code{address} field gives the offset in bytes from the base of -the section data which owns the relocation record to the first -byte of relocatable information. The actual data relocated -will be relative to this point; for example, a relocation -type which modifies the bottom two bytes of a four byte word -would not touch the first byte pointed to in a big endian -world. - -@itemize @bullet - -@item -@code{addend} -@end itemize -The @code{addend} is a value provided by the back end to be added (!) -to the relocation offset. Its interpretation is dependent upon -the howto. For example, on the 68k the code: - -@example - char foo[]; - main() - @{ - return foo[0x12345678]; - @} -@end example - -Could be compiled into: - -@example - linkw fp,#-4 - moveb @@#12345678,d0 - extbl d0 - unlk fp - rts -@end example - -This could create a reloc pointing to @code{foo}, but leave the -offset in the data, something like: - -@example -RELOCATION RECORDS FOR [.text]: -offset type value -00000006 32 _foo - -00000000 4e56 fffc ; linkw fp,#-4 -00000004 1039 1234 5678 ; moveb @@#12345678,d0 -0000000a 49c0 ; extbl d0 -0000000c 4e5e ; unlk fp -0000000e 4e75 ; rts -@end example - -Using coff and an 88k, some instructions don't have enough -space in them to represent the full address range, and -pointers have to be loaded in two parts. So you'd get something like: - -@example - or.u r13,r0,hi16(_foo+0x12345678) - ld.b r2,r13,lo16(_foo+0x12345678) - jmp r1 -@end example - -This should create two relocs, both pointing to @code{_foo}, and with -0x12340000 in their addend field. The data would consist of: - -@example -RELOCATION RECORDS FOR [.text]: -offset type value -00000002 HVRT16 _foo+0x12340000 -00000006 LVRT16 _foo+0x12340000 - -00000000 5da05678 ; or.u r13,r0,0x5678 -00000004 1c4d5678 ; ld.b r2,r13,0x5678 -00000008 f400c001 ; jmp r1 -@end example - -The relocation routine digs out the value from the data, adds -it to the addend to get the original offset, and then adds the -value of @code{_foo}. Note that all 32 bits have to be kept around -somewhere, to cope with carry from bit 15 to bit 16. - -One further example is the sparc and the a.out format. The -sparc has a similar problem to the 88k, in that some -instructions don't have room for an entire offset, but on the -sparc the parts are created in odd sized lumps. The designers of -the a.out format chose to not use the data within the section -for storing part of the offset; all the offset is kept within -the reloc. Anything in the data should be ignored. - -@example - save %sp,-112,%sp - sethi %hi(_foo+0x12345678),%g2 - ldsb [%g2+%lo(_foo+0x12345678)],%i0 - ret - restore -@end example - -Both relocs contain a pointer to @code{foo}, and the offsets -contain junk. - -@example -RELOCATION RECORDS FOR [.text]: -offset type value -00000004 HI22 _foo+0x12345678 -00000008 LO10 _foo+0x12345678 - -00000000 9de3bf90 ; save %sp,-112,%sp -00000004 05000000 ; sethi %hi(_foo+0),%g2 -00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0 -0000000c 81c7e008 ; ret -00000010 81e80000 ; restore -@end example - -@itemize @bullet - -@item -@code{howto} -@end itemize -The @code{howto} field can be imagined as a -relocation instruction. It is a pointer to a structure which -contains information on what to do with all of the other -information in the reloc record and data section. A back end -would normally have a relocation instruction set and turn -relocations into pointers to the correct structure on input - -but it would be possible to create each howto field on demand. - -@subsubsection @code{enum complain_overflow} -Indicates what sort of overflow checking should be done when -performing a relocation. - - -@example - -enum complain_overflow -@{ - /* Do not complain on overflow. */ - complain_overflow_dont, - - /* Complain if the bitfield overflows, whether it is considered - as signed or unsigned. */ - complain_overflow_bitfield, - - /* Complain if the value overflows when considered as signed - number. */ - complain_overflow_signed, - - /* Complain if the value overflows when considered as an - unsigned number. */ - complain_overflow_unsigned -@}; -@end example -@subsubsection @code{reloc_howto_type} -The @code{reloc_howto_type} is a structure which contains all the -information that libbfd needs to know to tie up a back end's data. - - -@example -struct symbol_cache_entry; /* Forward declaration */ - -struct reloc_howto_struct -@{ - /* The type field has mainly a documentary use - the back end can - do what it wants with it, though normally the back end's - external idea of what a reloc number is stored - in this field. For example, a PC relative word relocation - in a coff environment has the type 023 - because that's - what the outside world calls a R_PCRWORD reloc. */ - unsigned int type; - - /* The value the final relocation is shifted right by. This drops - unwanted data from the relocation. */ - unsigned int rightshift; - - /* The size of the item to be relocated. This is *not* a - power-of-two measure. To get the number of bytes operated - on by a type of relocation, use bfd_get_reloc_size. */ - int size; - - /* The number of bits in the item to be relocated. This is used - when doing overflow checking. */ - unsigned int bitsize; - - /* Notes that the relocation is relative to the location in the - data section of the addend. The relocation function will - subtract from the relocation value the address of the location - being relocated. */ - boolean pc_relative; - - /* The bit position of the reloc value in the destination. - The relocated value is left shifted by this amount. */ - unsigned int bitpos; - - /* What type of overflow error should be checked for when - relocating. */ - enum complain_overflow complain_on_overflow; - - /* If this field is non null, then the supplied function is - called rather than the normal function. This allows really - strange relocation methods to be accomodated (e.g., i960 callj - instructions). */ - bfd_reloc_status_type (*special_function) - PARAMS ((bfd *abfd, - arelent *reloc_entry, - struct symbol_cache_entry *symbol, - PTR data, - asection *input_section, - bfd *output_bfd, - char **error_message)); - - /* The textual name of the relocation type. */ - char *name; - - /* When performing a partial link, some formats must modify the - relocations rather than the data - this flag signals this.*/ - boolean partial_inplace; - - /* The src_mask selects which parts of the read in data - are to be used in the relocation sum. E.g., if this was an 8 bit - bit of data which we read and relocated, this would be - 0x000000ff. When we have relocs which have an addend, such as - sun4 extended relocs, the value in the offset part of a - relocating field is garbage so we never use it. In this case - the mask would be 0x00000000. */ - bfd_vma src_mask; - - /* The dst_mask selects which parts of the instruction are replaced - into the instruction. In most cases src_mask == dst_mask, - except in the above special case, where dst_mask would be - 0x000000ff, and src_mask would be 0x00000000. */ - bfd_vma dst_mask; - - /* When some formats create PC relative instructions, they leave - the value of the pc of the place being relocated in the offset - slot of the instruction, so that a PC relative relocation can - be made just by adding in an ordinary offset (e.g., sun3 a.out). - Some formats leave the displacement part of an instruction - empty (e.g., m88k bcs); this flag signals the fact.*/ - boolean pcrel_offset; - -@}; -@end example -@findex The HOWTO Macro -@subsubsection @code{The HOWTO Macro} -@strong{Description}@* -The HOWTO define is horrible and will go away. -@example -#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ - @{(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC@} -@end example - -@strong{Description}@* -And will be replaced with the totally magic way. But for the -moment, we are compatible, so do it this way. -@example -#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN) - -@end example - -@strong{Description}@* -Helper routine to turn a symbol into a relocation value. -@example -#define HOWTO_PREPARE(relocation, symbol) \ - @{ \ - if (symbol != (asymbol *)NULL) @{ \ - if (bfd_is_com_section (symbol->section)) @{ \ - relocation = 0; \ - @} \ - else @{ \ - relocation = symbol->value; \ - @} \ - @} \ -@} -@end example - -@findex bfd_get_reloc_size -@subsubsection @code{bfd_get_reloc_size} -@strong{Synopsis} -@example -unsigned int bfd_get_reloc_size (reloc_howto_type *); -@end example -@strong{Description}@* -For a reloc_howto_type that operates on a fixed number of bytes, -this returns the number of bytes operated on. - -@findex arelent_chain -@subsubsection @code{arelent_chain} -@strong{Description}@* -How relocs are tied together in an @code{asection}: -@example -typedef struct relent_chain @{ - arelent relent; - struct relent_chain *next; -@} arelent_chain; -@end example - -@findex bfd_check_overflow -@subsubsection @code{bfd_check_overflow} -@strong{Synopsis} -@example -bfd_reloc_status_type -bfd_check_overflow - (enum complain_overflow how, - unsigned int bitsize, - unsigned int rightshift, - bfd_vma relocation); -@end example -@strong{Description}@* -Perform overflow checking on @var{relocation} which has @var{bitsize} -significant bits and will be shifted right by @var{rightshift} bits. -The result is either of @code{bfd_reloc_ok} or -@code{bfd_reloc_overflow}. - -@findex bfd_perform_relocation -@subsubsection @code{bfd_perform_relocation} -@strong{Synopsis} -@example -bfd_reloc_status_type -bfd_perform_relocation - (bfd *abfd, - arelent *reloc_entry, - PTR data, - asection *input_section, - bfd *output_bfd, - char **error_message); -@end example -@strong{Description}@* -If @var{output_bfd} is supplied to this function, the -generated image will be relocatable; the relocations are -copied to the output file after they have been changed to -reflect the new state of the world. There are two ways of -reflecting the results of partial linkage in an output file: -by modifying the output data in place, and by modifying the -relocation record. Some native formats (e.g., basic a.out and -basic coff) have no way of specifying an addend in the -relocation type, so the addend has to go in the output data. -This is no big deal since in these formats the output data -slot will always be big enough for the addend. Complex reloc -types with addends were invented to solve just this problem. -The @var{error_message} argument is set to an error message if -this return @code{bfd_reloc_dangerous}. - -@findex bfd_install_relocation -@subsubsection @code{bfd_install_relocation} -@strong{Synopsis} -@example -bfd_reloc_status_type -bfd_install_relocation - (bfd *abfd, - arelent *reloc_entry, - PTR data, bfd_vma data_start, - asection *input_section, - char **error_message); -@end example -@strong{Description}@* -This looks remarkably like @code{bfd_perform_relocation}, except it -does not expect that the section contents have been filled in. -I.e., it's suitable for use when creating, rather than applying -a relocation. - -For now, this function should be considered reserved for the -assembler. - - -@node howto manager, , typedef arelent, Relocations -@section The howto manager -When an application wants to create a relocation, but doesn't -know what the target machine might call it, it can find out by -using this bit of code. - -@findex bfd_reloc_code_type -@subsubsection @code{bfd_reloc_code_type} -@strong{Description}@* -The insides of a reloc code. The idea is that, eventually, there -will be one enumerator for every type of relocation we ever do. -Pass one of these values to @code{bfd_reloc_type_lookup}, and it'll -return a howto pointer. - -This does mean that the application must determine the correct -enumerator value; you can't get a howto pointer from a random set -of attributes. - -Here are the possible values for @code{enum bfd_reloc_code_real}: - -@deffn {} BFD_RELOC_64 -@deffnx {} BFD_RELOC_32 -@deffnx {} BFD_RELOC_26 -@deffnx {} BFD_RELOC_24 -@deffnx {} BFD_RELOC_16 -@deffnx {} BFD_RELOC_14 -@deffnx {} BFD_RELOC_8 -Basic absolute relocations of N bits. -@end deffn -@deffn {} BFD_RELOC_64_PCREL -@deffnx {} BFD_RELOC_32_PCREL -@deffnx {} BFD_RELOC_24_PCREL -@deffnx {} BFD_RELOC_16_PCREL -@deffnx {} BFD_RELOC_12_PCREL -@deffnx {} BFD_RELOC_8_PCREL -PC-relative relocations. Sometimes these are relative to the address -of the relocation itself; sometimes they are relative to the start of -the section containing the relocation. It depends on the specific target. - -The 24-bit relocation is used in some Intel 960 configurations. -@end deffn -@deffn {} BFD_RELOC_32_GOT_PCREL -@deffnx {} BFD_RELOC_16_GOT_PCREL -@deffnx {} BFD_RELOC_8_GOT_PCREL -@deffnx {} BFD_RELOC_32_GOTOFF -@deffnx {} BFD_RELOC_16_GOTOFF -@deffnx {} BFD_RELOC_LO16_GOTOFF -@deffnx {} BFD_RELOC_HI16_GOTOFF -@deffnx {} BFD_RELOC_HI16_S_GOTOFF -@deffnx {} BFD_RELOC_8_GOTOFF -@deffnx {} BFD_RELOC_32_PLT_PCREL -@deffnx {} BFD_RELOC_24_PLT_PCREL -@deffnx {} BFD_RELOC_16_PLT_PCREL -@deffnx {} BFD_RELOC_8_PLT_PCREL -@deffnx {} BFD_RELOC_32_PLTOFF -@deffnx {} BFD_RELOC_16_PLTOFF -@deffnx {} BFD_RELOC_LO16_PLTOFF -@deffnx {} BFD_RELOC_HI16_PLTOFF -@deffnx {} BFD_RELOC_HI16_S_PLTOFF -@deffnx {} BFD_RELOC_8_PLTOFF -For ELF. -@end deffn -@deffn {} BFD_RELOC_68K_GLOB_DAT -@deffnx {} BFD_RELOC_68K_JMP_SLOT -@deffnx {} BFD_RELOC_68K_RELATIVE -Relocations used by 68K ELF. -@end deffn -@deffn {} BFD_RELOC_32_BASEREL -@deffnx {} BFD_RELOC_16_BASEREL -@deffnx {} BFD_RELOC_LO16_BASEREL -@deffnx {} BFD_RELOC_HI16_BASEREL -@deffnx {} BFD_RELOC_HI16_S_BASEREL -@deffnx {} BFD_RELOC_8_BASEREL -@deffnx {} BFD_RELOC_RVA -Linkage-table relative. -@end deffn -@deffn {} BFD_RELOC_8_FFnn -Absolute 8-bit relocation, but used to form an address like 0xFFnn. -@end deffn -@deffn {} BFD_RELOC_32_PCREL_S2 -@deffnx {} BFD_RELOC_16_PCREL_S2 -@deffnx {} BFD_RELOC_23_PCREL_S2 -These PC-relative relocations are stored as word displacements -- -i.e., byte displacements shifted right two bits. The 30-bit word -displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the -SPARC. (SPARC tools generally refer to this as <>.) The -signed 16-bit displacement is used on the MIPS, and the 23-bit -displacement is used on the Alpha. -@end deffn -@deffn {} BFD_RELOC_HI22 -@deffnx {} BFD_RELOC_LO10 -High 22 bits and low 10 bits of 32-bit value, placed into lower bits of -the target word. These are used on the SPARC. -@end deffn -@deffn {} BFD_RELOC_GPREL16 -@deffnx {} BFD_RELOC_GPREL32 -For systems that allocate a Global Pointer register, these are -displacements off that register. These relocation types are -handled specially, because the value the register will have is -decided relatively late. -@end deffn -@deffn {} BFD_RELOC_I960_CALLJ -Reloc types used for i960/b.out. -@end deffn -@deffn {} BFD_RELOC_NONE -@deffnx {} BFD_RELOC_SPARC_WDISP22 -@deffnx {} BFD_RELOC_SPARC22 -@deffnx {} BFD_RELOC_SPARC13 -@deffnx {} BFD_RELOC_SPARC_GOT10 -@deffnx {} BFD_RELOC_SPARC_GOT13 -@deffnx {} BFD_RELOC_SPARC_GOT22 -@deffnx {} BFD_RELOC_SPARC_PC10 -@deffnx {} BFD_RELOC_SPARC_PC22 -@deffnx {} BFD_RELOC_SPARC_WPLT30 -@deffnx {} BFD_RELOC_SPARC_COPY -@deffnx {} BFD_RELOC_SPARC_GLOB_DAT -@deffnx {} BFD_RELOC_SPARC_JMP_SLOT -@deffnx {} BFD_RELOC_SPARC_RELATIVE -@deffnx {} BFD_RELOC_SPARC_UA32 -SPARC ELF relocations. There is probably some overlap with other -relocation types already defined. -@end deffn -@deffn {} BFD_RELOC_SPARC_BASE13 -@deffnx {} BFD_RELOC_SPARC_BASE22 -I think these are specific to SPARC a.out (e.g., Sun 4). -@end deffn -@deffn {} BFD_RELOC_SPARC_64 -@deffnx {} BFD_RELOC_SPARC_10 -@deffnx {} BFD_RELOC_SPARC_11 -@deffnx {} BFD_RELOC_SPARC_OLO10 -@deffnx {} BFD_RELOC_SPARC_HH22 -@deffnx {} BFD_RELOC_SPARC_HM10 -@deffnx {} BFD_RELOC_SPARC_LM22 -@deffnx {} BFD_RELOC_SPARC_PC_HH22 -@deffnx {} BFD_RELOC_SPARC_PC_HM10 -@deffnx {} BFD_RELOC_SPARC_PC_LM22 -@deffnx {} BFD_RELOC_SPARC_WDISP16 -@deffnx {} BFD_RELOC_SPARC_WDISP19 -@deffnx {} BFD_RELOC_SPARC_7 -@deffnx {} BFD_RELOC_SPARC_6 -@deffnx {} BFD_RELOC_SPARC_5 -@deffnx {} BFD_RELOC_SPARC_DISP64 -@deffnx {} BFD_RELOC_SPARC_PLT64 -@deffnx {} BFD_RELOC_SPARC_HIX22 -@deffnx {} BFD_RELOC_SPARC_LOX10 -@deffnx {} BFD_RELOC_SPARC_H44 -@deffnx {} BFD_RELOC_SPARC_M44 -@deffnx {} BFD_RELOC_SPARC_L44 -@deffnx {} BFD_RELOC_SPARC_REGISTER -SPARC64 relocations -@end deffn -@deffn {} BFD_RELOC_ALPHA_GPDISP_HI16 -Alpha ECOFF and ELF relocations. Some of these treat the symbol or -"addend" in some special way. -For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when -writing; when reading, it will be the absolute section symbol. The -addend is the displacement in bytes of the "lda" instruction from -the "ldah" instruction (which is at the address of this reloc). -@end deffn -@deffn {} BFD_RELOC_ALPHA_GPDISP_LO16 -For GPDISP_LO16 ("ignore") relocations, the symbol is handled as -with GPDISP_HI16 relocs. The addend is ignored when writing the -relocations out, and is filled in with the file's GP value on -reading, for convenience. -@end deffn -@deffn {} BFD_RELOC_ALPHA_GPDISP -The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 -relocation except that there is no accompanying GPDISP_LO16 -relocation. -@end deffn -@deffn {} BFD_RELOC_ALPHA_LITERAL -@deffnx {} BFD_RELOC_ALPHA_ELF_LITERAL -@deffnx {} BFD_RELOC_ALPHA_LITUSE -The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; -the assembler turns it into a LDQ instruction to load the address of -the symbol, and then fills in a register in the real instruction. - -The LITERAL reloc, at the LDQ instruction, refers to the .lita -section symbol. The addend is ignored when writing, but is filled -in with the file's GP value on reading, for convenience, as with the -GPDISP_LO16 reloc. - -The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. -It should refer to the symbol to be referenced, as with 16_GOTOFF, -but it generates output not based on the position within the .got -section, but relative to the GP value chosen for the file during the -final link stage. - -The LITUSE reloc, on the instruction using the loaded address, gives -information to the linker that it might be able to use to optimize -away some literal section references. The symbol is ignored (read -as the absolute section symbol), and the "addend" indicates the type -of instruction using the register: -1 - "memory" fmt insn -2 - byte-manipulation (byte offset reg) -3 - jsr (target of branch) - -The GNU linker currently doesn't do any of this optimizing. -@end deffn -@deffn {} BFD_RELOC_ALPHA_HINT -The HINT relocation indicates a value that should be filled into the -"hint" field of a jmp/jsr/ret instruction, for possible branch- -prediction logic which may be provided on some processors. -@end deffn -@deffn {} BFD_RELOC_ALPHA_LINKAGE -The LINKAGE relocation outputs a linkage pair in the object file, -which is filled by the linker. -@end deffn -@deffn {} BFD_RELOC_ALPHA_CODEADDR -The CODEADDR relocation outputs a STO_CA in the object file, -which is filled by the linker. -@end deffn -@deffn {} BFD_RELOC_MIPS_JMP -Bits 27..2 of the relocation address shifted right 2 bits; -simple reloc otherwise. -@end deffn -@deffn {} BFD_RELOC_MIPS16_JMP -The MIPS16 jump instruction. -@end deffn -@deffn {} BFD_RELOC_MIPS16_GPREL -MIPS16 GP relative reloc. -@end deffn -@deffn {} BFD_RELOC_HI16 -High 16 bits of 32-bit value; simple reloc. -@end deffn -@deffn {} BFD_RELOC_HI16_S -High 16 bits of 32-bit value but the low 16 bits will be sign -extended and added to form the final result. If the low 16 -bits form a negative number, we need to add one to the high value -to compensate for the borrow when the low bits are added. -@end deffn -@deffn {} BFD_RELOC_LO16 -Low 16 bits. -@end deffn -@deffn {} BFD_RELOC_PCREL_HI16_S -Like BFD_RELOC_HI16_S, but PC relative. -@end deffn -@deffn {} BFD_RELOC_PCREL_LO16 -Like BFD_RELOC_LO16, but PC relative. -@end deffn -@deffn {} BFD_RELOC_MIPS_GPREL -Relocation relative to the global pointer. -@end deffn -@deffn {} BFD_RELOC_MIPS_LITERAL -Relocation against a MIPS literal section. -@end deffn -@deffn {} BFD_RELOC_MIPS_GOT16 -@deffnx {} BFD_RELOC_MIPS_CALL16 -@deffnx {} BFD_RELOC_MIPS_GPREL32 -@deffnx {} BFD_RELOC_MIPS_GOT_HI16 -@deffnx {} BFD_RELOC_MIPS_GOT_LO16 -@deffnx {} BFD_RELOC_MIPS_CALL_HI16 -@deffnx {} BFD_RELOC_MIPS_CALL_LO16 -MIPS ELF relocations. -@end deffn -@deffn {} BFD_RELOC_386_GOT32 -@deffnx {} BFD_RELOC_386_PLT32 -@deffnx {} BFD_RELOC_386_COPY -@deffnx {} BFD_RELOC_386_GLOB_DAT -@deffnx {} BFD_RELOC_386_JUMP_SLOT -@deffnx {} BFD_RELOC_386_RELATIVE -@deffnx {} BFD_RELOC_386_GOTOFF -@deffnx {} BFD_RELOC_386_GOTPC -i386/elf relocations -@end deffn -@deffn {} BFD_RELOC_NS32K_IMM_8 -@deffnx {} BFD_RELOC_NS32K_IMM_16 -@deffnx {} BFD_RELOC_NS32K_IMM_32 -@deffnx {} BFD_RELOC_NS32K_IMM_8_PCREL -@deffnx {} BFD_RELOC_NS32K_IMM_16_PCREL -@deffnx {} BFD_RELOC_NS32K_IMM_32_PCREL -@deffnx {} BFD_RELOC_NS32K_DISP_8 -@deffnx {} BFD_RELOC_NS32K_DISP_16 -@deffnx {} BFD_RELOC_NS32K_DISP_32 -@deffnx {} BFD_RELOC_NS32K_DISP_8_PCREL -@deffnx {} BFD_RELOC_NS32K_DISP_16_PCREL -@deffnx {} BFD_RELOC_NS32K_DISP_32_PCREL -ns32k relocations -@end deffn -@deffn {} BFD_RELOC_PPC_B26 -@deffnx {} BFD_RELOC_PPC_BA26 -@deffnx {} BFD_RELOC_PPC_TOC16 -@deffnx {} BFD_RELOC_PPC_B16 -@deffnx {} BFD_RELOC_PPC_B16_BRTAKEN -@deffnx {} BFD_RELOC_PPC_B16_BRNTAKEN -@deffnx {} BFD_RELOC_PPC_BA16 -@deffnx {} BFD_RELOC_PPC_BA16_BRTAKEN -@deffnx {} BFD_RELOC_PPC_BA16_BRNTAKEN -@deffnx {} BFD_RELOC_PPC_COPY -@deffnx {} BFD_RELOC_PPC_GLOB_DAT -@deffnx {} BFD_RELOC_PPC_JMP_SLOT -@deffnx {} BFD_RELOC_PPC_RELATIVE -@deffnx {} BFD_RELOC_PPC_LOCAL24PC -@deffnx {} BFD_RELOC_PPC_EMB_NADDR32 -@deffnx {} BFD_RELOC_PPC_EMB_NADDR16 -@deffnx {} BFD_RELOC_PPC_EMB_NADDR16_LO -@deffnx {} BFD_RELOC_PPC_EMB_NADDR16_HI -@deffnx {} BFD_RELOC_PPC_EMB_NADDR16_HA -@deffnx {} BFD_RELOC_PPC_EMB_SDAI16 -@deffnx {} BFD_RELOC_PPC_EMB_SDA2I16 -@deffnx {} BFD_RELOC_PPC_EMB_SDA2REL -@deffnx {} BFD_RELOC_PPC_EMB_SDA21 -@deffnx {} BFD_RELOC_PPC_EMB_MRKREF -@deffnx {} BFD_RELOC_PPC_EMB_RELSEC16 -@deffnx {} BFD_RELOC_PPC_EMB_RELST_LO -@deffnx {} BFD_RELOC_PPC_EMB_RELST_HI -@deffnx {} BFD_RELOC_PPC_EMB_RELST_HA -@deffnx {} BFD_RELOC_PPC_EMB_BIT_FLD -@deffnx {} BFD_RELOC_PPC_EMB_RELSDA -Power(rs6000) and PowerPC relocations. -@end deffn -@deffn {} BFD_RELOC_CTOR -The type of reloc used to build a contructor table - at the moment -probably a 32 bit wide absolute relocation, but the target can choose. -It generally does map to one of the other relocation types. -@end deffn -@deffn {} BFD_RELOC_ARM_PCREL_BRANCH -ARM 26 bit pc-relative branch. The lowest two bits must be zero and are -not stored in the instruction. -@end deffn -@deffn {} BFD_RELOC_ARM_IMMEDIATE -@deffnx {} BFD_RELOC_ARM_OFFSET_IMM -@deffnx {} BFD_RELOC_ARM_SHIFT_IMM -@deffnx {} BFD_RELOC_ARM_SWI -@deffnx {} BFD_RELOC_ARM_MULTI -@deffnx {} BFD_RELOC_ARM_CP_OFF_IMM -@deffnx {} BFD_RELOC_ARM_ADR_IMM -@deffnx {} BFD_RELOC_ARM_LDR_IMM -@deffnx {} BFD_RELOC_ARM_LITERAL -@deffnx {} BFD_RELOC_ARM_IN_POOL -@deffnx {} BFD_RELOC_ARM_OFFSET_IMM8 -@deffnx {} BFD_RELOC_ARM_HWLITERAL -@deffnx {} BFD_RELOC_ARM_THUMB_ADD -@deffnx {} BFD_RELOC_ARM_THUMB_IMM -@deffnx {} BFD_RELOC_ARM_THUMB_SHIFT -@deffnx {} BFD_RELOC_ARM_THUMB_OFFSET -These relocs are only used within the ARM assembler. They are not -(at present) written to any object files. -@end deffn -@deffn {} BFD_RELOC_SH_PCDISP8BY2 -@deffnx {} BFD_RELOC_SH_PCDISP12BY2 -@deffnx {} BFD_RELOC_SH_IMM4 -@deffnx {} BFD_RELOC_SH_IMM4BY2 -@deffnx {} BFD_RELOC_SH_IMM4BY4 -@deffnx {} BFD_RELOC_SH_IMM8 -@deffnx {} BFD_RELOC_SH_IMM8BY2 -@deffnx {} BFD_RELOC_SH_IMM8BY4 -@deffnx {} BFD_RELOC_SH_PCRELIMM8BY2 -@deffnx {} BFD_RELOC_SH_PCRELIMM8BY4 -@deffnx {} BFD_RELOC_SH_SWITCH16 -@deffnx {} BFD_RELOC_SH_SWITCH32 -@deffnx {} BFD_RELOC_SH_USES -@deffnx {} BFD_RELOC_SH_COUNT -@deffnx {} BFD_RELOC_SH_ALIGN -@deffnx {} BFD_RELOC_SH_CODE -@deffnx {} BFD_RELOC_SH_DATA -@deffnx {} BFD_RELOC_SH_LABEL -Hitachi SH relocs. Not all of these appear in object files. -@end deffn -@deffn {} BFD_RELOC_THUMB_PCREL_BRANCH9 -@deffnx {} BFD_RELOC_THUMB_PCREL_BRANCH12 -@deffnx {} BFD_RELOC_THUMB_PCREL_BRANCH23 -Thumb 23-, 12- and 9-bit pc-relative branches. The lowest bit must -be zero and is not stored in the instruction. -@end deffn -@deffn {} BFD_RELOC_ARC_B22_PCREL -Argonaut RISC Core (ARC) relocs. -ARC 22 bit pc-relative branch. The lowest two bits must be zero and are -not stored in the instruction. The high 20 bits are installed in bits 26 -through 7 of the instruction. -@end deffn -@deffn {} BFD_RELOC_ARC_B26 -ARC 26 bit absolute branch. The lowest two bits must be zero and are not -stored in the instruction. The high 24 bits are installed in bits 23 -through 0. -@end deffn -@deffn {} BFD_RELOC_D10V_10_PCREL_R -Mitsubishi D10V relocs. -This is a 10-bit reloc with the right 2 bits -assumed to be 0. -@end deffn -@deffn {} BFD_RELOC_D10V_10_PCREL_L -Mitsubishi D10V relocs. -This is a 10-bit reloc with the right 2 bits -assumed to be 0. This is the same as the previous reloc -except it is in the left container, i.e., -shifted left 15 bits. -@end deffn -@deffn {} BFD_RELOC_D10V_18 -This is an 18-bit reloc with the right 2 bits -assumed to be 0. -@end deffn -@deffn {} BFD_RELOC_D10V_18_PCREL -This is an 18-bit reloc with the right 2 bits -assumed to be 0. -@end deffn -@deffn {} BFD_RELOC_M32R_24 -Mitsubishi M32R relocs. -This is a 24 bit absolute address. -@end deffn -@deffn {} BFD_RELOC_M32R_10_PCREL -This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. -@end deffn -@deffn {} BFD_RELOC_M32R_18_PCREL -This is an 18-bit reloc with the right 2 bits assumed to be 0. -@end deffn -@deffn {} BFD_RELOC_M32R_26_PCREL -This is a 26-bit reloc with the right 2 bits assumed to be 0. -@end deffn -@deffn {} BFD_RELOC_M32R_HI16_ULO -This is a 16-bit reloc containing the high 16 bits of an address -used when the lower 16 bits are treated as unsigned. -@end deffn -@deffn {} BFD_RELOC_M32R_HI16_SLO -This is a 16-bit reloc containing the high 16 bits of an address -used when the lower 16 bits are treated as signed. -@end deffn -@deffn {} BFD_RELOC_M32R_LO16 -This is a 16-bit reloc containing the lower 16 bits of an address. -@end deffn -@deffn {} BFD_RELOC_M32R_SDA16 -This is a 16-bit reloc containing the small data area offset for use in -add3, load, and store instructions. -@end deffn -@deffn {} BFD_RELOC_V850_9_PCREL -This is a 9-bit reloc -@end deffn -@deffn {} BFD_RELOC_V850_22_PCREL -This is a 22-bit reloc -@end deffn -@deffn {} BFD_RELOC_V850_SDA_16_16_OFFSET -This is a 16 bit offset from the short data area pointer. -@end deffn -@deffn {} BFD_RELOC_V850_SDA_15_16_OFFSET -This is a 16 bit offset (of which only 15 bits are used) from the -short data area pointer. -@end deffn -@deffn {} BFD_RELOC_V850_ZDA_16_16_OFFSET -This is a 16 bit offset from the zero data area pointer. -@end deffn -@deffn {} BFD_RELOC_V850_ZDA_15_16_OFFSET -This is a 16 bit offset (of which only 15 bits are used) from the -zero data area pointer. -@end deffn -@deffn {} BFD_RELOC_V850_TDA_6_8_OFFSET -This is an 8 bit offset (of which only 6 bits are used) from the -tiny data area pointer. -@end deffn -@deffn {} BFD_RELOC_V850_TDA_7_8_OFFSET -This is an 8bit offset (of which only 7 bits are used) from the tiny -data area pointer. -@end deffn -@deffn {} BFD_RELOC_V850_TDA_7_7_OFFSET -This is a 7 bit offset from the tiny data area pointer. -@end deffn -@deffn {} BFD_RELOC_V850_TDA_16_16_OFFSET -This is a 16 bit offset from the tiny data area pointer. -@end deffn -@deffn {} BFD_RELOC_MN10300_32_PCREL -This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the -instruction. -@end deffn -@deffn {} BFD_RELOC_MN10300_16_PCREL -This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the -instruction. -@end deffn -@deffn {} BFD_RELOC_TIC30_LDP -This is a 8bit DP reloc for the tms320c30, where the most -significant 8 bits of a 24 bit word are placed into the least -significant 8 bits of the opcode. -@end deffn - -@example - -typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; -@end example -@findex bfd_reloc_type_lookup -@subsubsection @code{bfd_reloc_type_lookup} -@strong{Synopsis} -@example -reloc_howto_type * -bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code); -@end example -@strong{Description}@* -Return a pointer to a howto structure which, when -invoked, will perform the relocation @var{code} on data from the -architecture noted. - -@findex bfd_default_reloc_type_lookup -@subsubsection @code{bfd_default_reloc_type_lookup} -@strong{Synopsis} -@example -reloc_howto_type *bfd_default_reloc_type_lookup - (bfd *abfd, bfd_reloc_code_real_type code); -@end example -@strong{Description}@* -Provides a default relocation lookup routine for any architecture. - -@findex bfd_get_reloc_code_name -@subsubsection @code{bfd_get_reloc_code_name} -@strong{Synopsis} -@example -const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code); -@end example -@strong{Description}@* -Provides a printable name for the supplied relocation code. -Useful mainly for printing error messages. - -@findex bfd_generic_relax_section -@subsubsection @code{bfd_generic_relax_section} -@strong{Synopsis} -@example -boolean bfd_generic_relax_section - (bfd *abfd, - asection *section, - struct bfd_link_info *, - boolean *); -@end example -@strong{Description}@* -Provides default handling for relaxing for back ends which -don't do relaxing -- i.e., does nothing. - -@findex bfd_generic_get_relocated_section_contents -@subsubsection @code{bfd_generic_get_relocated_section_contents} -@strong{Synopsis} -@example -bfd_byte * -bfd_generic_get_relocated_section_contents (bfd *abfd, - struct bfd_link_info *link_info, - struct bfd_link_order *link_order, - bfd_byte *data, - boolean relocateable, - asymbol **symbols); -@end example -@strong{Description}@* -Provides default handling of relocation effort for back ends -which can't be bothered to do it efficiently. - diff --git a/contrib/binutils/bfd/doc/section.texi b/contrib/binutils/bfd/doc/section.texi deleted file mode 100644 index 24625c2c57b1..000000000000 --- a/contrib/binutils/bfd/doc/section.texi +++ /dev/null @@ -1,650 +0,0 @@ -@section Sections -The raw data contained within a BFD is maintained through the -section abstraction. A single BFD may have any number of -sections. It keeps hold of them by pointing to the first; -each one points to the next in the list. - -Sections are supported in BFD in @code{section.c}. - -@menu -* Section Input:: -* Section Output:: -* typedef asection:: -* section prototypes:: -@end menu - -@node Section Input, Section Output, Sections, Sections -@subsection Section input -When a BFD is opened for reading, the section structures are -created and attached to the BFD. - -Each section has a name which describes the section in the -outside world---for example, @code{a.out} would contain at least -three sections, called @code{.text}, @code{.data} and @code{.bss}. - -Names need not be unique; for example a COFF file may have several -sections named @code{.data}. - -Sometimes a BFD will contain more than the ``natural'' number of -sections. A back end may attach other sections containing -constructor data, or an application may add a section (using -@code{bfd_make_section}) to the sections attached to an already open -BFD. For example, the linker creates an extra section -@code{COMMON} for each input file's BFD to hold information about -common storage. - -The raw data is not necessarily read in when -the section descriptor is created. Some targets may leave the -data in place until a @code{bfd_get_section_contents} call is -made. Other back ends may read in all the data at once. For -example, an S-record file has to be read once to determine the -size of the data. An IEEE-695 file doesn't contain raw data in -sections, but data and relocation expressions intermixed, so -the data area has to be parsed to get out the data and -relocations. - -@node Section Output, typedef asection, Section Input, Sections -@subsection Section output -To write a new object style BFD, the various sections to be -written have to be created. They are attached to the BFD in -the same way as input sections; data is written to the -sections using @code{bfd_set_section_contents}. - -Any program that creates or combines sections (e.g., the assembler -and linker) must use the @code{asection} fields @code{output_section} and -@code{output_offset} to indicate the file sections to which each -section must be written. (If the section is being created from -scratch, @code{output_section} should probably point to the section -itself and @code{output_offset} should probably be zero.) - -The data to be written comes from input sections attached -(via @code{output_section} pointers) to -the output sections. The output section structure can be -considered a filter for the input section: the output section -determines the vma of the output data and the name, but the -input section determines the offset into the output section of -the data to be written. - -E.g., to create a section "O", starting at 0x100, 0x123 long, -containing two subsections, "A" at offset 0x0 (i.e., at vma -0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the @code{asection} -structures would look like: - -@example - section name "A" - output_offset 0x00 - size 0x20 - output_section -----------> section name "O" - | vma 0x100 - section name "B" | size 0x123 - output_offset 0x20 | - size 0x103 | - output_section --------| -@end example - -@subsection Link orders -The data within a section is stored in a @dfn{link_order}. -These are much like the fixups in @code{gas}. The link_order -abstraction allows a section to grow and shrink within itself. - -A link_order knows how big it is, and which is the next -link_order and where the raw data for it is; it also points to -a list of relocations which apply to it. - -The link_order is used by the linker to perform relaxing on -final code. The compiler creates code which is as big as -necessary to make it work without relaxing, and the user can -select whether to relax. Sometimes relaxing takes a lot of -time. The linker runs around the relocations to see if any -are attached to data which can be shrunk, if so it does it on -a link_order by link_order basis. - - -@node typedef asection, section prototypes, Section Output, Sections -@subsection typedef asection -Here is the section structure: - - -@example - -typedef struct sec -@{ - /* The name of the section; the name isn't a copy, the pointer is - the same as that passed to bfd_make_section. */ - - CONST char *name; - - /* Which section is it; 0..nth. */ - - int index; - - /* The next section in the list belonging to the BFD, or NULL. */ - - struct sec *next; - - /* The field flags contains attributes of the section. Some - flags are read in from the object file, and some are - synthesized from other information. */ - - flagword flags; - -#define SEC_NO_FLAGS 0x000 - - /* Tells the OS to allocate space for this section when loading. - This is clear for a section containing debug information - only. */ -#define SEC_ALLOC 0x001 - - /* Tells the OS to load the section from the file when loading. - This is clear for a .bss section. */ -#define SEC_LOAD 0x002 - - /* The section contains data still to be relocated, so there is - some relocation information too. */ -#define SEC_RELOC 0x004 - -#if 0 /* Obsolete ? */ -#define SEC_BALIGN 0x008 -#endif - - /* A signal to the OS that the section contains read only - data. */ -#define SEC_READONLY 0x010 - - /* The section contains code only. */ -#define SEC_CODE 0x020 - - /* The section contains data only. */ -#define SEC_DATA 0x040 - - /* The section will reside in ROM. */ -#define SEC_ROM 0x080 - - /* The section contains constructor information. This section - type is used by the linker to create lists of constructors and - destructors used by @code{g++}. When a back end sees a symbol - which should be used in a constructor list, it creates a new - section for the type of name (e.g., @code{__CTOR_LIST__}), attaches - the symbol to it, and builds a relocation. To build the lists - of constructors, all the linker has to do is catenate all the - sections called @code{__CTOR_LIST__} and relocate the data - contained within - exactly the operations it would peform on - standard data. */ -#define SEC_CONSTRUCTOR 0x100 - - /* The section is a constuctor, and should be placed at the - end of the text, data, or bss section(?). */ -#define SEC_CONSTRUCTOR_TEXT 0x1100 -#define SEC_CONSTRUCTOR_DATA 0x2100 -#define SEC_CONSTRUCTOR_BSS 0x3100 - - /* The section has contents - a data section could be - @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}; a debug section could be - @code{SEC_HAS_CONTENTS} */ -#define SEC_HAS_CONTENTS 0x200 - - /* An instruction to the linker to not output the section - even if it has information which would normally be written. */ -#define SEC_NEVER_LOAD 0x400 - - /* The section is a COFF shared library section. This flag is - only for the linker. If this type of section appears in - the input file, the linker must copy it to the output file - without changing the vma or size. FIXME: Although this - was originally intended to be general, it really is COFF - specific (and the flag was renamed to indicate this). It - might be cleaner to have some more general mechanism to - allow the back end to control what the linker does with - sections. */ -#define SEC_COFF_SHARED_LIBRARY 0x800 - - /* The section contains common symbols (symbols may be defined - multiple times, the value of a symbol is the amount of - space it requires, and the largest symbol value is the one - used). Most targets have exactly one of these (which we - translate to bfd_com_section_ptr), but ECOFF has two. */ -#define SEC_IS_COMMON 0x8000 - - /* The section contains only debugging information. For - example, this is set for ELF .debug and .stab sections. - strip tests this flag to see if a section can be - discarded. */ -#define SEC_DEBUGGING 0x10000 - - /* The contents of this section are held in memory pointed to - by the contents field. This is checked by - bfd_get_section_contents, and the data is retrieved from - memory if appropriate. */ -#define SEC_IN_MEMORY 0x20000 - - /* The contents of this section are to be excluded by the - linker for executable and shared objects unless those - objects are to be further relocated. */ -#define SEC_EXCLUDE 0x40000 - - /* The contents of this section are to be sorted by the - based on the address specified in the associated symbol - table. */ -#define SEC_SORT_ENTRIES 0x80000 - - /* When linking, duplicate sections of the same name should be - discarded, rather than being combined into a single section as - is usually done. This is similar to how common symbols are - handled. See SEC_LINK_DUPLICATES below. */ -#define SEC_LINK_ONCE 0x100000 - - /* If SEC_LINK_ONCE is set, this bitfield describes how the linker - should handle duplicate sections. */ -#define SEC_LINK_DUPLICATES 0x600000 - - /* This value for SEC_LINK_DUPLICATES means that duplicate - sections with the same name should simply be discarded. */ -#define SEC_LINK_DUPLICATES_DISCARD 0x0 - - /* This value for SEC_LINK_DUPLICATES means that the linker - should warn if there are any duplicate sections, although - it should still only link one copy. */ -#define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000 - - /* This value for SEC_LINK_DUPLICATES means that the linker - should warn if any duplicate sections are a different size. */ -#define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000 - - /* This value for SEC_LINK_DUPLICATES means that the linker - should warn if any duplicate sections contain different - contents. */ -#define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000 - - /* This section was created by the linker as part of dynamic - relocation or other arcane processing. It is skipped when - going through the first-pass output, trusting that someone - else up the line will take care of it later. */ -#define SEC_LINKER_CREATED 0x800000 - - /* End of section flags. */ - - /* Some internal packed boolean fields. */ - - /* See the vma field. */ - unsigned int user_set_vma : 1; - - /* Whether relocations have been processed. */ - unsigned int reloc_done : 1; - - /* A mark flag used by some of the linker backends. */ - unsigned int linker_mark : 1; - - /* End of internal packed boolean fields. */ - - /* The virtual memory address of the section - where it will be - at run time. The symbols are relocated against this. The - user_set_vma flag is maintained by bfd; if it's not set, the - backend can assign addresses (for example, in @code{a.out}, where - the default address for @code{.data} is dependent on the specific - target and various flags). */ - - bfd_vma vma; - - /* The load address of the section - where it would be in a - rom image; really only used for writing section header - information. */ - - bfd_vma lma; - - /* The size of the section in bytes, as it will be output. - contains a value even if the section has no contents (e.g., the - size of @code{.bss}). This will be filled in after relocation */ - - bfd_size_type _cooked_size; - - /* The original size on disk of the section, in bytes. Normally this - value is the same as the size, but if some relaxing has - been done, then this value will be bigger. */ - - bfd_size_type _raw_size; - - /* If this section is going to be output, then this value is the - offset into the output section of the first byte in the input - section. E.g., if this was going to start at the 100th byte in - the output section, this value would be 100. */ - - bfd_vma output_offset; - - /* The output section through which to map on output. */ - - struct sec *output_section; - - /* The alignment requirement of the section, as an exponent of 2 - - e.g., 3 aligns to 2^3 (or 8). */ - - unsigned int alignment_power; - - /* If an input section, a pointer to a vector of relocation - records for the data in this section. */ - - struct reloc_cache_entry *relocation; - - /* If an output section, a pointer to a vector of pointers to - relocation records for the data in this section. */ - - struct reloc_cache_entry **orelocation; - - /* The number of relocation records in one of the above */ - - unsigned reloc_count; - - /* Information below is back end specific - and not always used - or updated. */ - - /* File position of section data */ - - file_ptr filepos; - - /* File position of relocation info */ - - file_ptr rel_filepos; - - /* File position of line data */ - - file_ptr line_filepos; - - /* Pointer to data for applications */ - - PTR userdata; - - /* If the SEC_IN_MEMORY flag is set, this points to the actual - contents. */ - unsigned char *contents; - - /* Attached line number information */ - - alent *lineno; - - /* Number of line number records */ - - unsigned int lineno_count; - - /* When a section is being output, this value changes as more - linenumbers are written out */ - - file_ptr moving_line_filepos; - - /* What the section number is in the target world */ - - int target_index; - - PTR used_by_bfd; - - /* If this is a constructor section then here is a list of the - relocations created to relocate items within it. */ - - struct relent_chain *constructor_chain; - - /* The BFD which owns the section. */ - - bfd *owner; - - /* A symbol which points at this section only */ - struct symbol_cache_entry *symbol; - struct symbol_cache_entry **symbol_ptr_ptr; - - struct bfd_link_order *link_order_head; - struct bfd_link_order *link_order_tail; -@} asection ; - - /* These sections are global, and are managed by BFD. The application - and target back end are not permitted to change the values in - these sections. New code should use the section_ptr macros rather - than referring directly to the const sections. The const sections - may eventually vanish. */ -#define BFD_ABS_SECTION_NAME "*ABS*" -#define BFD_UND_SECTION_NAME "*UND*" -#define BFD_COM_SECTION_NAME "*COM*" -#define BFD_IND_SECTION_NAME "*IND*" - - /* the absolute section */ -extern const asection bfd_abs_section; -#define bfd_abs_section_ptr ((asection *) &bfd_abs_section) -#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) - /* Pointer to the undefined section */ -extern const asection bfd_und_section; -#define bfd_und_section_ptr ((asection *) &bfd_und_section) -#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) - /* Pointer to the common section */ -extern const asection bfd_com_section; -#define bfd_com_section_ptr ((asection *) &bfd_com_section) - /* Pointer to the indirect section */ -extern const asection bfd_ind_section; -#define bfd_ind_section_ptr ((asection *) &bfd_ind_section) -#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) - -extern const struct symbol_cache_entry * const bfd_abs_symbol; -extern const struct symbol_cache_entry * const bfd_com_symbol; -extern const struct symbol_cache_entry * const bfd_und_symbol; -extern const struct symbol_cache_entry * const bfd_ind_symbol; -#define bfd_get_section_size_before_reloc(section) \ - (section->reloc_done ? (abort(),1): (section)->_raw_size) -#define bfd_get_section_size_after_reloc(section) \ - ((section->reloc_done) ? (section)->_cooked_size: (abort(),1)) -@end example - -@node section prototypes, , typedef asection, Sections -@subsection Section prototypes -These are the functions exported by the section handling part of BFD. - -@findex bfd_get_section_by_name -@subsubsection @code{bfd_get_section_by_name} -@strong{Synopsis} -@example -asection *bfd_get_section_by_name(bfd *abfd, CONST char *name); -@end example -@strong{Description}@* -Run through @var{abfd} and return the one of the -@code{asection}s whose name matches @var{name}, otherwise @code{NULL}. -@xref{Sections}, for more information. - -This should only be used in special cases; the normal way to process -all sections of a given name is to use @code{bfd_map_over_sections} and -@code{strcmp} on the name (or better yet, base it on the section flags -or something else) for each section. - -@findex bfd_make_section_old_way -@subsubsection @code{bfd_make_section_old_way} -@strong{Synopsis} -@example -asection *bfd_make_section_old_way(bfd *abfd, CONST char *name); -@end example -@strong{Description}@* -Create a new empty section called @var{name} -and attach it to the end of the chain of sections for the -BFD @var{abfd}. An attempt to create a section with a name which -is already in use returns its pointer without changing the -section chain. - -It has the funny name since this is the way it used to be -before it was rewritten.... - -Possible errors are: -@itemize @bullet - -@item -@code{bfd_error_invalid_operation} - -If output has already started for this BFD. -@item -@code{bfd_error_no_memory} - -If memory allocation fails. -@end itemize - -@findex bfd_make_section_anyway -@subsubsection @code{bfd_make_section_anyway} -@strong{Synopsis} -@example -asection *bfd_make_section_anyway(bfd *abfd, CONST char *name); -@end example -@strong{Description}@* -Create a new empty section called @var{name} and attach it to the end of -the chain of sections for @var{abfd}. Create a new section even if there -is already a section with that name. - -Return @code{NULL} and set @code{bfd_error} on error; possible errors are: -@itemize @bullet - -@item -@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}. -@item -@code{bfd_error_no_memory} - If memory allocation fails. -@end itemize - -@findex bfd_make_section -@subsubsection @code{bfd_make_section} -@strong{Synopsis} -@example -asection *bfd_make_section(bfd *, CONST char *name); -@end example -@strong{Description}@* -Like @code{bfd_make_section_anyway}, but return @code{NULL} (without calling -bfd_set_error ()) without changing the section chain if there is already a -section named @var{name}. If there is an error, return @code{NULL} and set -@code{bfd_error}. - -@findex bfd_set_section_flags -@subsubsection @code{bfd_set_section_flags} -@strong{Synopsis} -@example -boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags); -@end example -@strong{Description}@* -Set the attributes of the section @var{sec} in the BFD -@var{abfd} to the value @var{flags}. Return @code{true} on success, -@code{false} on error. Possible error returns are: - -@itemize @bullet - -@item -@code{bfd_error_invalid_operation} - -The section cannot have one or more of the attributes -requested. For example, a .bss section in @code{a.out} may not -have the @code{SEC_HAS_CONTENTS} field set. -@end itemize - -@findex bfd_map_over_sections -@subsubsection @code{bfd_map_over_sections} -@strong{Synopsis} -@example -void bfd_map_over_sections(bfd *abfd, - void (*func)(bfd *abfd, - asection *sect, - PTR obj), - PTR obj); -@end example -@strong{Description}@* -Call the provided function @var{func} for each section -attached to the BFD @var{abfd}, passing @var{obj} as an -argument. The function will be called as if by - -@example - func(abfd, the_section, obj); -@end example - -This is the prefered method for iterating over sections; an -alternative would be to use a loop: - -@example - section *p; - for (p = abfd->sections; p != NULL; p = p->next) - func(abfd, p, ...) -@end example - -@findex bfd_set_section_size -@subsubsection @code{bfd_set_section_size} -@strong{Synopsis} -@example -boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val); -@end example -@strong{Description}@* -Set @var{sec} to the size @var{val}. If the operation is -ok, then @code{true} is returned, else @code{false}. - -Possible error returns: -@itemize @bullet - -@item -@code{bfd_error_invalid_operation} - -Writing has started to the BFD, so setting the size is invalid. -@end itemize - -@findex bfd_set_section_contents -@subsubsection @code{bfd_set_section_contents} -@strong{Synopsis} -@example -boolean bfd_set_section_contents - (bfd *abfd, - asection *section, - PTR data, - file_ptr offset, - bfd_size_type count); -@end example -@strong{Description}@* -Sets the contents of the section @var{section} in BFD -@var{abfd} to the data starting in memory at @var{data}. The -data is written to the output section starting at offset -@var{offset} for @var{count} bytes. - -Normally @code{true} is returned, else @code{false}. Possible error -returns are: -@itemize @bullet - -@item -@code{bfd_error_no_contents} - -The output section does not have the @code{SEC_HAS_CONTENTS} -attribute, so nothing can be written to it. -@item -and some more too -@end itemize -This routine is front end to the back end function -@code{_bfd_set_section_contents}. - -@findex bfd_get_section_contents -@subsubsection @code{bfd_get_section_contents} -@strong{Synopsis} -@example -boolean bfd_get_section_contents - (bfd *abfd, asection *section, PTR location, - file_ptr offset, bfd_size_type count); -@end example -@strong{Description}@* -Read data from @var{section} in BFD @var{abfd} -into memory starting at @var{location}. The data is read at an -offset of @var{offset} from the start of the input section, -and is read for @var{count} bytes. - -If the contents of a constructor with the @code{SEC_CONSTRUCTOR} -flag set are requested or if the section does not have the -@code{SEC_HAS_CONTENTS} flag set, then the @var{location} is filled -with zeroes. If no errors occur, @code{true} is returned, else -@code{false}. - -@findex bfd_copy_private_section_data -@subsubsection @code{bfd_copy_private_section_data} -@strong{Synopsis} -@example -boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec); -@end example -@strong{Description}@* -Copy private section information from @var{isec} in the BFD -@var{ibfd} to the section @var{osec} in the BFD @var{obfd}. -Return @code{true} on success, @code{false} on error. Possible error -returns are: - -@itemize @bullet - -@item -@code{bfd_error_no_memory} - -Not enough memory exists to create private data for @var{osec}. -@end itemize -@example -#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ - BFD_SEND (obfd, _bfd_copy_private_section_data, \ - (ibfd, isection, obfd, osection)) -@end example - diff --git a/contrib/binutils/bfd/doc/syms.texi b/contrib/binutils/bfd/doc/syms.texi deleted file mode 100644 index 48593f4c8238..000000000000 --- a/contrib/binutils/bfd/doc/syms.texi +++ /dev/null @@ -1,408 +0,0 @@ -@section Symbols -BFD tries to maintain as much symbol information as it can when -it moves information from file to file. BFD passes information -to applications though the @code{asymbol} structure. When the -application requests the symbol table, BFD reads the table in -the native form and translates parts of it into the internal -format. To maintain more than the information passed to -applications, some targets keep some information ``behind the -scenes'' in a structure only the particular back end knows -about. For example, the coff back end keeps the original -symbol table structure as well as the canonical structure when -a BFD is read in. On output, the coff back end can reconstruct -the output symbol table so that no information is lost, even -information unique to coff which BFD doesn't know or -understand. If a coff symbol table were read, but were written -through an a.out back end, all the coff specific information -would be lost. The symbol table of a BFD -is not necessarily read in until a canonicalize request is -made. Then the BFD back end fills in a table provided by the -application with pointers to the canonical information. To -output symbols, the application provides BFD with a table of -pointers to pointers to @code{asymbol}s. This allows applications -like the linker to output a symbol as it was read, since the ``behind -the scenes'' information will be still available. -@menu -* Reading Symbols:: -* Writing Symbols:: -* Mini Symbols:: -* typedef asymbol:: -* symbol handling functions:: -@end menu - -@node Reading Symbols, Writing Symbols, Symbols, Symbols -@subsection Reading symbols -There are two stages to reading a symbol table from a BFD: -allocating storage, and the actual reading process. This is an -excerpt from an application which reads the symbol table: - -@example - long storage_needed; - asymbol **symbol_table; - long number_of_symbols; - long i; - - storage_needed = bfd_get_symtab_upper_bound (abfd); - - if (storage_needed < 0) - FAIL - - if (storage_needed == 0) @{ - return ; - @} - symbol_table = (asymbol **) xmalloc (storage_needed); - ... - number_of_symbols = - bfd_canonicalize_symtab (abfd, symbol_table); - - if (number_of_symbols < 0) - FAIL - - for (i = 0; i < number_of_symbols; i++) @{ - process_symbol (symbol_table[i]); - @} -@end example - -All storage for the symbols themselves is in an objalloc -connected to the BFD; it is freed when the BFD is closed. - -@node Writing Symbols, Mini Symbols, Reading Symbols, Symbols -@subsection Writing symbols -Writing of a symbol table is automatic when a BFD open for -writing is closed. The application attaches a vector of -pointers to pointers to symbols to the BFD being written, and -fills in the symbol count. The close and cleanup code reads -through the table provided and performs all the necessary -operations. The BFD output code must always be provided with an -``owned'' symbol: one which has come from another BFD, or one -which has been created using @code{bfd_make_empty_symbol}. Here is an -example showing the creation of a symbol table with only one element: - -@example - #include "bfd.h" - main() - @{ - bfd *abfd; - asymbol *ptrs[2]; - asymbol *new; - - abfd = bfd_openw("foo","a.out-sunos-big"); - bfd_set_format(abfd, bfd_object); - new = bfd_make_empty_symbol(abfd); - new->name = "dummy_symbol"; - new->section = bfd_make_section_old_way(abfd, ".text"); - new->flags = BSF_GLOBAL; - new->value = 0x12345; - - ptrs[0] = new; - ptrs[1] = (asymbol *)0; - - bfd_set_symtab(abfd, ptrs, 1); - bfd_close(abfd); - @} - - ./makesym - nm foo - 00012345 A dummy_symbol -@end example - -Many formats cannot represent arbitary symbol information; for -instance, the @code{a.out} object format does not allow an -arbitary number of sections. A symbol pointing to a section -which is not one of @code{.text}, @code{.data} or @code{.bss} cannot -be described. - -@node Mini Symbols, typedef asymbol, Writing Symbols, Symbols -@subsection Mini Symbols -Mini symbols provide read-only access to the symbol table. -They use less memory space, but require more time to access. -They can be useful for tools like nm or objdump, which may -have to handle symbol tables of extremely large executables. - -The @code{bfd_read_minisymbols} function will read the symbols -into memory in an internal form. It will return a @code{void *} -pointer to a block of memory, a symbol count, and the size of -each symbol. The pointer is allocated using @code{malloc}, and -should be freed by the caller when it is no longer needed. - -The function @code{bfd_minisymbol_to_symbol} will take a pointer -to a minisymbol, and a pointer to a structure returned by -@code{bfd_make_empty_symbol}, and return a @code{asymbol} structure. -The return value may or may not be the same as the value from -@code{bfd_make_empty_symbol} which was passed in. - - -@node typedef asymbol, symbol handling functions, Mini Symbols, Symbols -@subsection typedef asymbol -An @code{asymbol} has the form: - - -@example - -typedef struct symbol_cache_entry -@{ - /* A pointer to the BFD which owns the symbol. This information - is necessary so that a back end can work out what additional - information (invisible to the application writer) is carried - with the symbol. - - This field is *almost* redundant, since you can use section->owner - instead, except that some symbols point to the global sections - bfd_@{abs,com,und@}_section. This could be fixed by making - these globals be per-bfd (or per-target-flavor). FIXME. */ - - struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */ - - /* The text of the symbol. The name is left alone, and not copied; the - application may not alter it. */ - CONST char *name; - - /* The value of the symbol. This really should be a union of a - numeric value with a pointer, since some flags indicate that - a pointer to another symbol is stored here. */ - symvalue value; - - /* Attributes of a symbol: */ - -#define BSF_NO_FLAGS 0x00 - - /* The symbol has local scope; @code{static} in @code{C}. The value - is the offset into the section of the data. */ -#define BSF_LOCAL 0x01 - - /* The symbol has global scope; initialized data in @code{C}. The - value is the offset into the section of the data. */ -#define BSF_GLOBAL 0x02 - - /* The symbol has global scope and is exported. The value is - the offset into the section of the data. */ -#define BSF_EXPORT BSF_GLOBAL /* no real difference */ - - /* A normal C symbol would be one of: - @code{BSF_LOCAL}, @code{BSF_FORT_COMM}, @code{BSF_UNDEFINED} or - @code{BSF_GLOBAL} */ - - /* The symbol is a debugging record. The value has an arbitary - meaning. */ -#define BSF_DEBUGGING 0x08 - - /* The symbol denotes a function entry point. Used in ELF, - perhaps others someday. */ -#define BSF_FUNCTION 0x10 - - /* Used by the linker. */ -#define BSF_KEEP 0x20 -#define BSF_KEEP_G 0x40 - - /* A weak global symbol, overridable without warnings by - a regular global symbol of the same name. */ -#define BSF_WEAK 0x80 - - /* This symbol was created to point to a section, e.g. ELF's - STT_SECTION symbols. */ -#define BSF_SECTION_SYM 0x100 - - /* The symbol used to be a common symbol, but now it is - allocated. */ -#define BSF_OLD_COMMON 0x200 - - /* The default value for common data. */ -#define BFD_FORT_COMM_DEFAULT_VALUE 0 - - /* In some files the type of a symbol sometimes alters its - location in an output file - ie in coff a @code{ISFCN} symbol - which is also @code{C_EXT} symbol appears where it was - declared and not at the end of a section. This bit is set - by the target BFD part to convey this information. */ - -#define BSF_NOT_AT_END 0x400 - - /* Signal that the symbol is the label of constructor section. */ -#define BSF_CONSTRUCTOR 0x800 - - /* Signal that the symbol is a warning symbol. The name is a - warning. The name of the next symbol is the one to warn about; - if a reference is made to a symbol with the same name as the next - symbol, a warning is issued by the linker. */ -#define BSF_WARNING 0x1000 - - /* Signal that the symbol is indirect. This symbol is an indirect - pointer to the symbol with the same name as the next symbol. */ -#define BSF_INDIRECT 0x2000 - - /* BSF_FILE marks symbols that contain a file name. This is used - for ELF STT_FILE symbols. */ -#define BSF_FILE 0x4000 - - /* Symbol is from dynamic linking information. */ -#define BSF_DYNAMIC 0x8000 - - /* The symbol denotes a data object. Used in ELF, and perhaps - others someday. */ -#define BSF_OBJECT 0x10000 - - flagword flags; - - /* A pointer to the section to which this symbol is - relative. This will always be non NULL, there are special - sections for undefined and absolute symbols. */ - struct sec *section; - - /* Back end special data. */ - union - @{ - PTR p; - bfd_vma i; - @} udata; - -@} asymbol; -@end example - -@node symbol handling functions, , typedef asymbol, Symbols -@subsection Symbol handling functions - - -@findex bfd_get_symtab_upper_bound -@subsubsection @code{bfd_get_symtab_upper_bound} -@strong{Description}@* -Return the number of bytes required to store a vector of pointers -to @code{asymbols} for all the symbols in the BFD @var{abfd}, -including a terminal NULL pointer. If there are no symbols in -the BFD, then return 0. If an error occurs, return -1. -@example -#define bfd_get_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) -@end example - -@findex bfd_is_local_label -@subsubsection @code{bfd_is_local_label} -@strong{Synopsis} -@example -boolean bfd_is_local_label(bfd *abfd, asymbol *sym); -@end example -@strong{Description}@* -Return true if the given symbol @var{sym} in the BFD @var{abfd} is -a compiler generated local label, else return false. - -@findex bfd_is_local_label_name -@subsubsection @code{bfd_is_local_label_name} -@strong{Synopsis} -@example -boolean bfd_is_local_label_name(bfd *abfd, const char *name); -@end example -@strong{Description}@* -Return true if a symbol with the name @var{name} in the BFD -@var{abfd} is a compiler generated local label, else return -false. This just checks whether the name has the form of a -local label. -@example -#define bfd_is_local_label_name(abfd, name) \ - BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) -@end example - -@findex bfd_canonicalize_symtab -@subsubsection @code{bfd_canonicalize_symtab} -@strong{Description}@* -Read the symbols from the BFD @var{abfd}, and fills in -the vector @var{location} with pointers to the symbols and -a trailing NULL. -Return the actual number of symbol pointers, not -including the NULL. -@example -#define bfd_canonicalize_symtab(abfd, location) \ - BFD_SEND (abfd, _bfd_canonicalize_symtab,\ - (abfd, location)) -@end example - -@findex bfd_set_symtab -@subsubsection @code{bfd_set_symtab} -@strong{Synopsis} -@example -boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count); -@end example -@strong{Description}@* -Arrange that when the output BFD @var{abfd} is closed, -the table @var{location} of @var{count} pointers to symbols -will be written. - -@findex bfd_print_symbol_vandf -@subsubsection @code{bfd_print_symbol_vandf} -@strong{Synopsis} -@example -void bfd_print_symbol_vandf(PTR file, asymbol *symbol); -@end example -@strong{Description}@* -Print the value and flags of the @var{symbol} supplied to the -stream @var{file}. - -@findex bfd_make_empty_symbol -@subsubsection @code{bfd_make_empty_symbol} -@strong{Description}@* -Create a new @code{asymbol} structure for the BFD @var{abfd} -and return a pointer to it. - -This routine is necessary because each back end has private -information surrounding the @code{asymbol}. Building your own -@code{asymbol} and pointing to it will not create the private -information, and will cause problems later on. -@example -#define bfd_make_empty_symbol(abfd) \ - BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) -@end example - -@findex bfd_make_debug_symbol -@subsubsection @code{bfd_make_debug_symbol} -@strong{Description}@* -Create a new @code{asymbol} structure for the BFD @var{abfd}, -to be used as a debugging symbol. Further details of its use have -yet to be worked out. -@example -#define bfd_make_debug_symbol(abfd,ptr,size) \ - BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size)) -@end example - -@findex bfd_decode_symclass -@subsubsection @code{bfd_decode_symclass} -@strong{Description}@* -Return a character corresponding to the symbol -class of @var{symbol}, or '?' for an unknown class. - -@strong{Synopsis} -@example -int bfd_decode_symclass(asymbol *symbol); -@end example -@findex bfd_symbol_info -@subsubsection @code{bfd_symbol_info} -@strong{Description}@* -Fill in the basic info about symbol that nm needs. -Additional info may be added by the back-ends after -calling this function. - -@strong{Synopsis} -@example -void bfd_symbol_info(asymbol *symbol, symbol_info *ret); -@end example -@findex bfd_copy_private_symbol_data -@subsubsection @code{bfd_copy_private_symbol_data} -@strong{Synopsis} -@example -boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym); -@end example -@strong{Description}@* -Copy private symbol information from @var{isym} in the BFD -@var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}. -Return @code{true} on success, @code{false} on error. Possible error -returns are: - -@itemize @bullet - -@item -@code{bfd_error_no_memory} - -Not enough memory exists to create private data for @var{osec}. -@end itemize -@example -#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \ - BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ - (ibfd, isymbol, obfd, osymbol)) -@end example - diff --git a/contrib/binutils/bfd/doc/targets.texi b/contrib/binutils/bfd/doc/targets.texi deleted file mode 100644 index ccaaf400730f..000000000000 --- a/contrib/binutils/bfd/doc/targets.texi +++ /dev/null @@ -1,478 +0,0 @@ -@section Targets - - -@strong{Description}@* -Each port of BFD to a different machine requries the creation -of a target back end. All the back end provides to the root -part of BFD is a structure containing pointers to functions -which perform certain low level operations on files. BFD -translates the applications's requests through a pointer into -calls to the back end routines. - -When a file is opened with @code{bfd_openr}, its format and -target are unknown. BFD uses various mechanisms to determine -how to interpret the file. The operations performed are: - -@itemize @bullet - -@item -Create a BFD by calling the internal routine -@code{_bfd_new_bfd}, then call @code{bfd_find_target} with the -target string supplied to @code{bfd_openr} and the new BFD pointer. - -@item -If a null target string was provided to @code{bfd_find_target}, -look up the environment variable @code{GNUTARGET} and use -that as the target string. - -@item -If the target string is still @code{NULL}, or the target string is -@code{default}, then use the first item in the target vector -as the target type, and set @code{target_defaulted} in the BFD to -cause @code{bfd_check_format} to loop through all the targets. -@xref{bfd_target}. @xref{Formats}. - -@item -Otherwise, inspect the elements in the target vector -one by one, until a match on target name is found. When found, -use it. - -@item -Otherwise return the error @code{bfd_error_invalid_target} to -@code{bfd_openr}. - -@item -@code{bfd_openr} attempts to open the file using -@code{bfd_open_file}, and returns the BFD. -@end itemize -Once the BFD has been opened and the target selected, the file -format may be determined. This is done by calling -@code{bfd_check_format} on the BFD with a suggested format. -If @code{target_defaulted} has been set, each possible target -type is tried to see if it recognizes the specified format. -@code{bfd_check_format} returns @code{true} when the caller guesses right. -@menu -* bfd_target:: -@end menu - -@node bfd_target, , Targets, Targets - -@subsection bfd_target - - -@strong{Description}@* -This structure contains everything that BFD knows about a -target. It includes things like its byte order, name, and which -routines to call to do various operations. - -Every BFD points to a target structure with its @code{xvec} -member. - -The macros below are used to dispatch to functions through the -@code{bfd_target} vector. They are used in a number of macros further -down in @file{bfd.h}, and are also used when calling various -routines by hand inside the BFD implementation. The @var{arglist} -argument must be parenthesized; it contains all the arguments -to the called function. - -They make the documentation (more) unpleasant to read, so if -someone wants to fix this and not break the above, please do. -@example -#define BFD_SEND(bfd, message, arglist) \ - ((*((bfd)->xvec->message)) arglist) - -#ifdef DEBUG_BFD_SEND -#undef BFD_SEND -#define BFD_SEND(bfd, message, arglist) \ - (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ - ((*((bfd)->xvec->message)) arglist) : \ - (bfd_assert (__FILE__,__LINE__), NULL)) -#endif -@end example -For operations which index on the BFD format: -@example -#define BFD_SEND_FMT(bfd, message, arglist) \ - (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) - -#ifdef DEBUG_BFD_SEND -#undef BFD_SEND_FMT -#define BFD_SEND_FMT(bfd, message, arglist) \ - (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ - (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \ - (bfd_assert (__FILE__,__LINE__), NULL)) -#endif -@end example -This is the structure which defines the type of BFD this is. The -@code{xvec} member of the struct @code{bfd} itself points here. Each -module that implements access to a different target under BFD, -defines one of these. - -FIXME, these names should be rationalised with the names of -the entry points which call them. Too bad we can't have one -macro to define them both! -@example -enum bfd_flavour @{ - bfd_target_unknown_flavour, - bfd_target_aout_flavour, - bfd_target_coff_flavour, - bfd_target_ecoff_flavour, - bfd_target_elf_flavour, - bfd_target_ieee_flavour, - bfd_target_nlm_flavour, - bfd_target_oasys_flavour, - bfd_target_tekhex_flavour, - bfd_target_srec_flavour, - bfd_target_ihex_flavour, - bfd_target_som_flavour, - bfd_target_os9k_flavour, - bfd_target_versados_flavour, - bfd_target_msdos_flavour, - bfd_target_evax_flavour -@}; - -enum bfd_endian @{ BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN @}; - - /* Forward declaration. */ -typedef struct bfd_link_info _bfd_link_info; - -typedef struct bfd_target -@{ -@end example -Identifies the kind of target, e.g., SunOS4, Ultrix, etc. -@example - char *name; -@end example -The "flavour" of a back end is a general indication about the contents -of a file. -@example - enum bfd_flavour flavour; -@end example -The order of bytes within the data area of a file. -@example - enum bfd_endian byteorder; -@end example -The order of bytes within the header parts of a file. -@example - enum bfd_endian header_byteorder; -@end example -A mask of all the flags which an executable may have set - -from the set @code{BFD_NO_FLAGS}, @code{HAS_RELOC}, ...@code{D_PAGED}. -@example - flagword object_flags; -@end example -A mask of all the flags which a section may have set - from -the set @code{SEC_NO_FLAGS}, @code{SEC_ALLOC}, ...@code{SET_NEVER_LOAD}. -@example - flagword section_flags; -@end example -The character normally found at the front of a symbol -(if any), perhaps `_'. -@example - char symbol_leading_char; -@end example -The pad character for file names within an archive header. -@example - char ar_pad_char; -@end example -The maximum number of characters in an archive header. -@example - unsigned short ar_max_namelen; -@end example -Entries for byte swapping for data. These are different from the other -entry points, since they don't take a BFD asthe first argument. -Certain other handlers could do the same. -@example - bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *)); - void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *)); - bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *)); - void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *)); - bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *)); - void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *)); -@end example -Byte swapping for the headers -@example - bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *)); - void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *)); - bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *)); - void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *)); - bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *)); - void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *)); -@end example -Format dependent routines: these are vectors of entry points -within the target vector structure, one for each format to check. - -Check the format of a file being read. Return a @code{bfd_target *} or zero. -@example - const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *)); -@end example -Set the format of a file being written. -@example - boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *)); -@end example -Write cached information into a file being written, at @code{bfd_close}. -@example - boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *)); -@end example -The general target vector. -@example - - /* Generic entry points. */ -#define BFD_JUMP_TABLE_GENERIC(NAME)\ -CAT(NAME,_close_and_cleanup),\ -CAT(NAME,_bfd_free_cached_info),\ -CAT(NAME,_new_section_hook),\ -CAT(NAME,_get_section_contents),\ -CAT(NAME,_get_section_contents_in_window) - - /* Called when the BFD is being closed to do any necessary cleanup. */ - boolean (*_close_and_cleanup) PARAMS ((bfd *)); - /* Ask the BFD to free all cached information. */ - boolean (*_bfd_free_cached_info) PARAMS ((bfd *)); - /* Called when a new section is created. */ - boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr)); - /* Read the contents of a section. */ - boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); - boolean (*_bfd_get_section_contents_in_window) - PARAMS ((bfd *, sec_ptr, bfd_window *, - file_ptr, bfd_size_type)); - - /* Entry points to copy private data. */ -#define BFD_JUMP_TABLE_COPY(NAME)\ -CAT(NAME,_bfd_copy_private_bfd_data),\ -CAT(NAME,_bfd_merge_private_bfd_data),\ -CAT(NAME,_bfd_copy_private_section_data),\ -CAT(NAME,_bfd_copy_private_symbol_data),\ -CAT(NAME,_bfd_set_private_flags),\ -CAT(NAME,_bfd_print_private_bfd_data)\ - /* Called to copy BFD general private data from one object file - to another. */ - boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *)); - /* Called to merge BFD general private data from one object file - to a common output file when linking. */ - boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *)); - /* Called to copy BFD private section data from one object file - to another. */ - boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr, - bfd *, sec_ptr)); - /* Called to copy BFD private symbol data from one symbol - to another. */ - boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *, - bfd *, asymbol *)); - /* Called to set private backend flags */ - boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword)); - - /* Called to print private BFD data */ - boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR)); - - /* Core file entry points. */ -#define BFD_JUMP_TABLE_CORE(NAME)\ -CAT(NAME,_core_file_failing_command),\ -CAT(NAME,_core_file_failing_signal),\ -CAT(NAME,_core_file_matches_executable_p) - char * (*_core_file_failing_command) PARAMS ((bfd *)); - int (*_core_file_failing_signal) PARAMS ((bfd *)); - boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *)); - - /* Archive entry points. */ -#define BFD_JUMP_TABLE_ARCHIVE(NAME)\ -CAT(NAME,_slurp_armap),\ -CAT(NAME,_slurp_extended_name_table),\ -CAT(NAME,_construct_extended_name_table),\ -CAT(NAME,_truncate_arname),\ -CAT(NAME,_write_armap),\ -CAT(NAME,_read_ar_hdr),\ -CAT(NAME,_openr_next_archived_file),\ -CAT(NAME,_get_elt_at_index),\ -CAT(NAME,_generic_stat_arch_elt),\ -CAT(NAME,_update_armap_timestamp) - boolean (*_bfd_slurp_armap) PARAMS ((bfd *)); - boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *)); - boolean (*_bfd_construct_extended_name_table) - PARAMS ((bfd *, char **, bfd_size_type *, const char **)); - void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *)); - boolean (*write_armap) PARAMS ((bfd *arch, - unsigned int elength, - struct orl *map, - unsigned int orl_count, - int stridx)); - PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *)); - bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev)); -#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i)) - bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex)); - int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *)); - boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *)); - - /* Entry points used for symbols. */ -#define BFD_JUMP_TABLE_SYMBOLS(NAME)\ -CAT(NAME,_get_symtab_upper_bound),\ -CAT(NAME,_get_symtab),\ -CAT(NAME,_make_empty_symbol),\ -CAT(NAME,_print_symbol),\ -CAT(NAME,_get_symbol_info),\ -CAT(NAME,_bfd_is_local_label_name),\ -CAT(NAME,_get_lineno),\ -CAT(NAME,_find_nearest_line),\ -CAT(NAME,_bfd_make_debug_symbol),\ -CAT(NAME,_read_minisymbols),\ -CAT(NAME,_minisymbol_to_symbol) - long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *)); - long (*_bfd_canonicalize_symtab) PARAMS ((bfd *, - struct symbol_cache_entry **)); - struct symbol_cache_entry * - (*_bfd_make_empty_symbol) PARAMS ((bfd *)); - void (*_bfd_print_symbol) PARAMS ((bfd *, PTR, - struct symbol_cache_entry *, - bfd_print_symbol_type)); -#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e)) - void (*_bfd_get_symbol_info) PARAMS ((bfd *, - struct symbol_cache_entry *, - symbol_info *)); -#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e)) - boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *)); - - alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *)); - boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd, - struct sec *section, struct symbol_cache_entry **symbols, - bfd_vma offset, CONST char **file, CONST char **func, - unsigned int *line)); - /* Back-door to allow format-aware applications to create debug symbols - while using BFD for everything else. Currently used by the assembler - when creating COFF files. */ - asymbol * (*_bfd_make_debug_symbol) PARAMS (( - bfd *abfd, - void *ptr, - unsigned long size)); -#define bfd_read_minisymbols(b, d, m, s) \ - BFD_SEND (b, _read_minisymbols, (b, d, m, s)) - long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *, - unsigned int *)); -#define bfd_minisymbol_to_symbol(b, d, m, f) \ - BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f)) - asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR, - asymbol *)); - - /* Routines for relocs. */ -#define BFD_JUMP_TABLE_RELOCS(NAME)\ -CAT(NAME,_get_reloc_upper_bound),\ -CAT(NAME,_canonicalize_reloc),\ -CAT(NAME,_bfd_reloc_type_lookup) - long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr)); - long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, - struct symbol_cache_entry **)); - /* See documentation on reloc types. */ - reloc_howto_type * - (*reloc_type_lookup) PARAMS ((bfd *abfd, - bfd_reloc_code_real_type code)); - - /* Routines used when writing an object file. */ -#define BFD_JUMP_TABLE_WRITE(NAME)\ -CAT(NAME,_set_arch_mach),\ -CAT(NAME,_set_section_contents) - boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture, - unsigned long)); - boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); - - /* Routines used by the linker. */ -#define BFD_JUMP_TABLE_LINK(NAME)\ -CAT(NAME,_sizeof_headers),\ -CAT(NAME,_bfd_get_relocated_section_contents),\ -CAT(NAME,_bfd_relax_section),\ -CAT(NAME,_bfd_link_hash_table_create),\ -CAT(NAME,_bfd_link_add_symbols),\ -CAT(NAME,_bfd_final_link),\ -CAT(NAME,_bfd_link_split_section) - int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean)); - bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *, - struct bfd_link_info *, struct bfd_link_order *, - bfd_byte *data, boolean relocateable, - struct symbol_cache_entry **)); - - boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *, - struct bfd_link_info *, boolean *again)); - - /* Create a hash table for the linker. Different backends store - different information in this table. */ - struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *)); - - /* Add symbols from this object file into the hash table. */ - boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *)); - - /* Do a link based on the link_order structures attached to each - section of the BFD. */ - boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *)); - - /* Should this section be split up into smaller pieces during linking. */ - boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *)); - - /* Routines to handle dynamic symbols and relocs. */ -#define BFD_JUMP_TABLE_DYNAMIC(NAME)\ -CAT(NAME,_get_dynamic_symtab_upper_bound),\ -CAT(NAME,_canonicalize_dynamic_symtab),\ -CAT(NAME,_get_dynamic_reloc_upper_bound),\ -CAT(NAME,_canonicalize_dynamic_reloc) - /* Get the amount of memory required to hold the dynamic symbols. */ - long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *)); - /* Read in the dynamic symbols. */ - long (*_bfd_canonicalize_dynamic_symtab) - PARAMS ((bfd *, struct symbol_cache_entry **)); - /* Get the amount of memory required to hold the dynamic relocs. */ - long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *)); - /* Read in the dynamic relocs. */ - long (*_bfd_canonicalize_dynamic_reloc) - PARAMS ((bfd *, arelent **, struct symbol_cache_entry **)); - -@end example -Data for use by back-end routines, which isn't generic enough to belong -in this structure. -@example - PTR backend_data; -@} bfd_target; -@end example - -@findex bfd_set_default_target -@subsubsection @code{bfd_set_default_target} -@strong{Synopsis} -@example -boolean bfd_set_default_target (const char *name); -@end example -@strong{Description}@* -Set the default target vector to use when recognizing a BFD. -This takes the name of the target, which may be a BFD target -name or a configuration triplet. - -@findex bfd_find_target -@subsubsection @code{bfd_find_target} -@strong{Synopsis} -@example -const bfd_target *bfd_find_target(CONST char *target_name, bfd *abfd); -@end example -@strong{Description}@* -Return a pointer to the transfer vector for the object target -named @var{target_name}. If @var{target_name} is @code{NULL}, choose the -one in the environment variable @code{GNUTARGET}; if that is null or not -defined, then choose the first entry in the target list. -Passing in the string "default" or setting the environment -variable to "default" will cause the first entry in the target -list to be returned, and "target_defaulted" will be set in the -BFD. This causes @code{bfd_check_format} to loop over all the -targets to find the one that matches the file being read. - -@findex bfd_target_list -@subsubsection @code{bfd_target_list} -@strong{Synopsis} -@example -const char **bfd_target_list(void); -@end example -@strong{Description}@* -Return a freshly malloced NULL-terminated -vector of the names of all the valid BFD targets. Do not -modify the names. - diff --git a/contrib/binutils/bfd/elf32-sh.c b/contrib/binutils/bfd/elf32-sh.c deleted file mode 100644 index 71538036453e..000000000000 --- a/contrib/binutils/bfd/elf32-sh.c +++ /dev/null @@ -1,1909 +0,0 @@ -/* Hitachi SH specific support for 32-bit ELF - Copyright 1996, 1997, 1998 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 "bfdlink.h" -#include "libbfd.h" -#include "elf-bfd.h" - -static bfd_reloc_status_type sh_elf_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static bfd_reloc_status_type sh_elf_ignore_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static reloc_howto_type *sh_elf_reloc_type_lookup - PARAMS ((bfd *, bfd_reloc_code_real_type)); -static void sh_elf_info_to_howto - PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); -static boolean sh_elf_relax_section - PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); -static boolean sh_elf_relax_delete_bytes - PARAMS ((bfd *, asection *, bfd_vma, int)); -static boolean sh_elf_align_loads - PARAMS ((bfd *, asection *, Elf_Internal_Rela *, bfd_byte *, boolean *)); -static boolean sh_elf_swap_insns - PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma)); -static boolean sh_elf_relocate_section - PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, - Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); -static bfd_byte *sh_elf_get_relocated_section_contents - PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, - bfd_byte *, boolean, asymbol **)); - -enum sh_reloc_type -{ - R_SH_NONE = 0, - R_SH_DIR32, - R_SH_REL32, - R_SH_DIR8WPN, - R_SH_IND12W, - R_SH_DIR8WPL, - R_SH_DIR8WPZ, - R_SH_DIR8BP, - R_SH_DIR8W, - R_SH_DIR8L, - FIRST_INVALID_RELOC, - LAST_INVALID_RELOC = 24, - /* The remaining relocs are a GNU extension used for relaxation. We - use the same constants as COFF uses, not that it really matters. */ - R_SH_SWITCH16 = 25, - R_SH_SWITCH32, - R_SH_USES, - R_SH_COUNT, - R_SH_ALIGN, - R_SH_CODE, - R_SH_DATA, - R_SH_LABEL, - R_SH_max -}; - -static reloc_howto_type sh_elf_howto_table[] = -{ - /* No relocation. */ - HOWTO (R_SH_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 */ - sh_elf_reloc, /* special_function */ - "R_SH_NONE", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - false), /* pcrel_offset */ - - /* 32 bit absolute relocation. Setting partial_inplace to true and - src_mask to a non-zero value is similar to the COFF toolchain. */ - HOWTO (R_SH_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 */ - sh_elf_reloc, /* special_function */ - "R_SH_DIR32", /* name */ - true, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ - - /* 32 bit PC relative relocation. */ - HOWTO (R_SH_REL32, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - true, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - sh_elf_reloc, /* special_function */ - "R_SH_REL32", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0xffffffff, /* dst_mask */ - true), /* pcrel_offset */ - - /* 8 bit PC relative branch divided by 2. */ - HOWTO (R_SH_DIR8WPN, /* 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_elf_reloc, /* special_function */ - "R_SH_DIR8WPN", /* name */ - true, /* partial_inplace */ - 0xff, /* src_mask */ - 0xff, /* dst_mask */ - true), /* pcrel_offset */ - - /* 12 bit PC relative branch divided by 2. */ - HOWTO (R_SH_IND12W, /* 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_elf_reloc, /* special_function */ - "R_SH_IND12W", /* name */ - true, /* partial_inplace */ - 0xfff, /* src_mask */ - 0xfff, /* dst_mask */ - true), /* pcrel_offset */ - - /* 8 bit unsigned PC relative divided by 4. */ - HOWTO (R_SH_DIR8WPL, /* 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_elf_reloc, /* special_function */ - "R_SH_DIR8WPL", /* name */ - true, /* partial_inplace */ - 0xff, /* src_mask */ - 0xff, /* dst_mask */ - true), /* pcrel_offset */ - - /* 8 bit unsigned PC relative divided by 2. */ - HOWTO (R_SH_DIR8WPZ, /* 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_elf_reloc, /* special_function */ - "R_SH_DIR8WPZ", /* name */ - true, /* partial_inplace */ - 0xff, /* src_mask */ - 0xff, /* dst_mask */ - true), /* pcrel_offset */ - - /* 8 bit GBR relative. FIXME: This only makes sense if we have some - special symbol for the GBR relative area, and that is not - implemented. */ - HOWTO (R_SH_DIR8BP, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_reloc, /* special_function */ - "R_SH_DIR8BP", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0xff, /* dst_mask */ - true), /* pcrel_offset */ - - /* 8 bit GBR relative divided by 2. FIXME: This only makes sense if - we have some special symbol for the GBR relative area, and that - is not implemented. */ - HOWTO (R_SH_DIR8W, /* type */ - 1, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_reloc, /* special_function */ - "R_SH_DIR8W", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0xff, /* dst_mask */ - true), /* pcrel_offset */ - - /* 8 bit GBR relative divided by 4. FIXME: This only makes sense if - we have some special symbol for the GBR relative area, and that - is not implemented. */ - HOWTO (R_SH_DIR8L, /* type */ - 2, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_reloc, /* special_function */ - "R_SH_DIR8L", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0xff, /* dst_mask */ - true), /* pcrel_offset */ - - { 10 }, - { 11 }, - { 12 }, - { 13 }, - { 14 }, - { 15 }, - { 16 }, - { 17 }, - { 18 }, - { 19 }, - { 20 }, - { 21 }, - { 22 }, - { 23 }, - { 24 }, - - /* The remaining relocs are a GNU extension used for relaxing. The - final pass of the linker never needs to do anything with any of - these relocs. Any required operations are handled by the - relaxation code. */ - - /* A 16 bit switch table entry. This is generated for an expression - such as ``.word L1 - L2''. The offset holds the difference - between the reloc address and L2. */ - HOWTO (R_SH_SWITCH16, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_ignore_reloc, /* special_function */ - "R_SH_SWITCH16", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ - - /* A 32 bit switch table entry. This is generated for an expression - such as ``.long L1 - L2''. The offset holds the difference - between the reloc address and L2. */ - HOWTO (R_SH_SWITCH32, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_ignore_reloc, /* special_function */ - "R_SH_SWITCH32", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ - - /* Indicates a .uses pseudo-op. The compiler will generate .uses - pseudo-ops when it finds a function call which can be relaxed. - The offset field holds the PC relative offset to the instruction - which loads the register used in the function call. */ - HOWTO (R_SH_USES, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_ignore_reloc, /* special_function */ - "R_SH_USES", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ - - /* The assembler will generate this reloc for addresses referred to - by the register loads associated with USES relocs. The offset - field holds the number of times the address is referenced in the - object file. */ - HOWTO (R_SH_COUNT, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_ignore_reloc, /* special_function */ - "R_SH_COUNT", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ - - /* Indicates an alignment statement. The offset field is the power - of 2 to which subsequent portions of the object file must be - aligned. */ - HOWTO (R_SH_ALIGN, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_ignore_reloc, /* special_function */ - "R_SH_ALIGN", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ - - /* The assembler will generate this reloc before a block of - instructions. A section should be processed as assumining it - contains data, unless this reloc is seen. */ - HOWTO (R_SH_CODE, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_ignore_reloc, /* special_function */ - "R_SH_CODE", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ - - /* The assembler will generate this reloc after a block of - instructions when it sees data that is not instructions. */ - HOWTO (R_SH_DATA, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_ignore_reloc, /* special_function */ - "R_SH_DATA", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ - - /* The assembler generates this reloc for each label within a block - of instructions. This permits the linker to avoid swapping - instructions which are the targets of branches. */ - HOWTO (R_SH_LABEL, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - false, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - sh_elf_ignore_reloc, /* special_function */ - "R_SH_LABEL", /* name */ - false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - true) /* pcrel_offset */ -}; - -/* This function is used for normal relocs. This is like the COFF - function, and is almost certainly incorrect for other ELF targets. */ - -static bfd_reloc_status_type -sh_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; -{ - unsigned long insn; - bfd_vma sym_value; - enum sh_reloc_type r_type; - bfd_vma addr = reloc_entry->address; - bfd_byte *hit_data = addr + (bfd_byte *) data; - - r_type = (enum sh_reloc_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_DIR32 - && (r_type != R_SH_IND12W - || (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; - - if (bfd_is_com_section (symbol_in->section)) - sym_value = 0; - else - sym_value = (symbol_in->value + - symbol_in->section->output_section->vma + - symbol_in->section->output_offset); - - switch (r_type) - { - case R_SH_DIR32: - insn = bfd_get_32 (abfd, hit_data); - insn += sym_value + reloc_entry->addend; - bfd_put_32 (abfd, insn, hit_data); - break; - case R_SH_IND12W: - 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; -} - -/* This function is used for relocs which are only used for relaxing, - which the linker should otherwise ignore. */ - -static bfd_reloc_status_type -sh_elf_ignore_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 != NULL) - reloc_entry->address += input_section->output_offset; - return bfd_reloc_ok; -} - -/* This structure is used to map BFD reloc codes to SH ELF relocs. */ - -struct elf_reloc_map -{ - unsigned char bfd_reloc_val; - unsigned char elf_reloc_val; -}; - -/* An array mapping BFD reloc codes to SH ELF relocs. */ - -static const struct elf_reloc_map sh_reloc_map[] = -{ - { BFD_RELOC_NONE, R_SH_NONE }, - { BFD_RELOC_32, R_SH_DIR32 }, - { BFD_RELOC_CTOR, R_SH_DIR32 }, - { BFD_RELOC_32_PCREL, R_SH_REL32 }, - { BFD_RELOC_SH_PCDISP8BY2, R_SH_DIR8WPN }, - { BFD_RELOC_SH_PCDISP12BY2, R_SH_IND12W }, - { BFD_RELOC_SH_PCRELIMM8BY2, R_SH_DIR8WPZ }, - { BFD_RELOC_SH_PCRELIMM8BY4, R_SH_DIR8WPL }, - { BFD_RELOC_SH_SWITCH16, R_SH_SWITCH16 }, - { BFD_RELOC_SH_SWITCH32, R_SH_SWITCH32 }, - { BFD_RELOC_SH_USES, R_SH_USES }, - { BFD_RELOC_SH_COUNT, R_SH_COUNT }, - { BFD_RELOC_SH_ALIGN, R_SH_ALIGN }, - { BFD_RELOC_SH_CODE, R_SH_CODE }, - { BFD_RELOC_SH_DATA, R_SH_DATA }, - { BFD_RELOC_SH_LABEL, R_SH_LABEL } -}; - -/* Given a BFD reloc code, return the howto structure for the - corresponding SH ELf reloc. */ - -static reloc_howto_type * -sh_elf_reloc_type_lookup (abfd, code) - bfd *abfd; - bfd_reloc_code_real_type code; -{ - unsigned int i; - - for (i = 0; i < sizeof (sh_reloc_map) / sizeof (struct elf_reloc_map); i++) - { - if (sh_reloc_map[i].bfd_reloc_val == code) - return &sh_elf_howto_table[(int) sh_reloc_map[i].elf_reloc_val]; - } - - return NULL; -} - -/* Given an ELF reloc, fill in the howto field of a relent. */ - -static void -sh_elf_info_to_howto (abfd, cache_ptr, dst) - bfd *abfd; - arelent *cache_ptr; - Elf_Internal_Rela *dst; -{ - unsigned int r; - - r = ELF32_R_TYPE (dst->r_info); - - BFD_ASSERT (r < (unsigned int) R_SH_max); - BFD_ASSERT (r < FIRST_INVALID_RELOC || r > LAST_INVALID_RELOC); - - cache_ptr->howto = &sh_elf_howto_table[r]; -} - -/* This function handles relaxing for SH ELF. See the corresponding - function in coff-sh.c for a description of what this does. FIXME: - There is a lot of duplication here between this code and the COFF - specific code. The format of relocs and symbols is wound deeply - into this code, but it would still be better if the duplication - could be eliminated somehow. Note in particular that although both - functions use symbols like R_SH_CODE, those symbols have different - values; in coff-sh.c they come from include/coff/sh.h, whereas here - they come from enum sh_reloc_type in this file. */ - -static boolean -sh_elf_relax_section (abfd, sec, link_info, again) - bfd *abfd; - asection *sec; - struct bfd_link_info *link_info; - boolean *again; -{ - Elf_Internal_Shdr *symtab_hdr; - Elf_Internal_Rela *internal_relocs; - Elf_Internal_Rela *free_relocs = NULL; - boolean have_code; - Elf_Internal_Rela *irel, *irelend; - bfd_byte *contents = NULL; - bfd_byte *free_contents = NULL; - Elf32_External_Sym *extsyms = NULL; - Elf32_External_Sym *free_extsyms = NULL; - - *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; - - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; - - internal_relocs = (_bfd_elf32_link_read_relocs - (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL, - link_info->keep_memory)); - if (internal_relocs == NULL) - goto error_return; - if (! link_info->keep_memory) - free_relocs = internal_relocs; - - have_code = false; - - irelend = internal_relocs + sec->reloc_count; - for (irel = internal_relocs; irel < irelend; irel++) - { - bfd_vma laddr, paddr, symval; - unsigned short insn; - Elf_Internal_Rela *irelfn, *irelscan, *irelcount; - bfd_signed_vma foff; - - if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_CODE) - have_code = true; - - if (ELF32_R_TYPE (irel->r_info) != (int) R_SH_USES) - continue; - - /* Get the section contents. */ - if (contents == NULL) - { - if (elf_section_data (sec)->this_hdr.contents != NULL) - contents = elf_section_data (sec)->this_hdr.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_addend field of the R_SH_USES reloc will point us to - the register load. The 4 is because the r_addend field is - computed as though it were a jump offset, which are based - from 4 bytes after the jump instruction. */ - laddr = irel->r_offset + 4 + irel->r_addend; - 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_offset); - 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_offset, 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_offset)); - 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. */ - for (irelfn = internal_relocs; irelfn < irelend; irelfn++) - if (irelfn->r_offset == paddr - && ELF32_R_TYPE (irelfn->r_info) == (int) R_SH_DIR32) - break; - if (irelfn >= irelend) - { - ((*_bfd_error_handler) - ("%s: 0x%lx: warning: could not find expected reloc", - bfd_get_filename (abfd), (unsigned long) paddr)); - continue; - } - - /* Read this BFD's symbols if we haven't done so already. */ - if (extsyms == NULL) - { - if (symtab_hdr->contents != NULL) - extsyms = (Elf32_External_Sym *) symtab_hdr->contents; - else - { - extsyms = ((Elf32_External_Sym *) - bfd_malloc (symtab_hdr->sh_size)); - if (extsyms == NULL) - goto error_return; - free_extsyms = extsyms; - if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd) - != symtab_hdr->sh_size)) - goto error_return; - } - } - - /* Get the value of the symbol referred to by the reloc. */ - if (ELF32_R_SYM (irelfn->r_info) < symtab_hdr->sh_info) - { - Elf_Internal_Sym isym; - - /* A local symbol. */ - bfd_elf32_swap_symbol_in (abfd, - extsyms + ELF32_R_SYM (irelfn->r_info), - &isym); - - if (isym.st_shndx != _bfd_elf_section_from_bfd_section (abfd, sec)) - { - ((*_bfd_error_handler) - ("%s: 0x%lx: warning: symbol in unexpected section", - bfd_get_filename (abfd), (unsigned long) paddr)); - continue; - } - - symval = (isym.st_value - + sec->output_section->vma - + sec->output_offset); - } - else - { - unsigned long indx; - struct elf_link_hash_entry *h; - - indx = ELF32_R_SYM (irelfn->r_info) - symtab_hdr->sh_info; - h = elf_sym_hashes (abfd)[indx]; - BFD_ASSERT (h != NULL); - if (h->root.type != bfd_link_hash_defined - && h->root.type != bfd_link_hash_defweak) - { - /* This appears to be a reference to an undefined - symbol. Just ignore it--it will be caught by the - regular reloc processing. */ - continue; - } - - symval = (h->root.u.def.value - + h->root.u.def.section->output_section->vma - + h->root.u.def.section->output_offset); - } - - symval += bfd_get_32 (abfd, contents + paddr); - - /* See if this function call can be shortened. */ - foff = (symval - - (irel->r_offset - + 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. */ - - elf_section_data (sec)->relocs = internal_relocs; - free_relocs = NULL; - - elf_section_data (sec)->this_hdr.contents = contents; - free_contents = NULL; - - symtab_hdr->contents = (bfd_byte *) extsyms; - free_extsyms = NULL; - - /* Replace the jsr with a bsr. */ - - /* Change the R_SH_USES reloc into an R_SH_IND12W reloc, and - replace the jsr with a bsr. */ - irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irelfn->r_info), R_SH_IND12W); - if (ELF32_R_SYM (irelfn->r_info) < symtab_hdr->sh_info) - { - /* If this needs to be changed because of future relaxing, - it will be handled here like other internal IND12W - relocs. */ - bfd_put_16 (abfd, - 0xb000 | ((foff >> 1) & 0xfff), - contents + irel->r_offset); - } - 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_offset); - } - - /* See if there is another R_SH_USES reloc referring to the same - register load. */ - for (irelscan = internal_relocs; irelscan < irelend; irelscan++) - if (ELF32_R_TYPE (irelscan->r_info) == (int) R_SH_USES - && laddr == irelscan->r_offset + 4 + irelscan->r_addend) - 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_offset == paddr - && ELF32_R_TYPE (irelcount->r_info) == (int) R_SH_COUNT) - break; - - /* Delete the register load. */ - if (! sh_elf_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_addend field. We've - just deleted one. */ - if (irelcount->r_addend == 0) - { - ((*_bfd_error_handler) ("%s: 0x%lx: warning: bad count", - bfd_get_filename (abfd), - (unsigned long) paddr)); - continue; - } - - --irelcount->r_addend; - - /* 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_elf_relax_delete_bytes. */ - if (irelcount->r_addend == 0) - { - if (! sh_elf_relax_delete_bytes (abfd, sec, irelfn->r_offset, 4)) - goto error_return; - } - - /* We've done all we can with that function call. */ - } - - /* Look for load and store instructions that we can align on four - byte boundaries. */ - if (have_code) - { - boolean swapped; - - /* Get the section contents. */ - if (contents == NULL) - { - if (elf_section_data (sec)->this_hdr.contents != NULL) - contents = elf_section_data (sec)->this_hdr.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; - } - } - - if (! sh_elf_align_loads (abfd, sec, internal_relocs, contents, - &swapped)) - goto error_return; - - if (swapped) - { - elf_section_data (sec)->relocs = internal_relocs; - free_relocs = NULL; - - elf_section_data (sec)->this_hdr.contents = contents; - free_contents = NULL; - - symtab_hdr->contents = (bfd_byte *) extsyms; - free_extsyms = NULL; - } - } - - if (free_relocs != NULL) - { - free (free_relocs); - free_relocs = NULL; - } - - if (free_contents != NULL) - { - if (! link_info->keep_memory) - free (free_contents); - else - { - /* Cache the section contents for elf_link_input_bfd. */ - elf_section_data (sec)->this_hdr.contents = contents; - } - free_contents = NULL; - } - - if (free_extsyms != NULL) - { - if (! link_info->keep_memory) - free (free_extsyms); - else - { - /* Cache the symbols for elf_link_input_bfd. */ - symtab_hdr->contents = extsyms; - } - free_extsyms = NULL; - } - - return true; - - error_return: - if (free_relocs != NULL) - free (free_relocs); - if (free_contents != NULL) - free (free_contents); - if (free_extsyms != NULL) - free (free_extsyms); - return false; -} - -/* Delete some bytes from a section while relaxing. FIXME: There is a - lot of duplication between this function and sh_relax_delete_bytes - in coff-sh.c. */ - -static boolean -sh_elf_relax_delete_bytes (abfd, sec, addr, count) - bfd *abfd; - asection *sec; - bfd_vma addr; - int count; -{ - Elf_Internal_Shdr *symtab_hdr; - Elf32_External_Sym *extsyms; - int shndx, index; - bfd_byte *contents; - Elf_Internal_Rela *irel, *irelend; - Elf_Internal_Rela *irelalign; - bfd_vma toaddr; - Elf32_External_Sym *esym, *esymend; - struct elf_link_hash_entry *sym_hash; - asection *o; - - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; - extsyms = (Elf32_External_Sym *) symtab_hdr->contents; - - shndx = _bfd_elf_section_from_bfd_section (abfd, sec); - - contents = elf_section_data (sec)->this_hdr.contents; - - /* The deletion must stop at the next ALIGN reloc for an aligment - power larger than the number of bytes we are deleting. */ - - irelalign = NULL; - toaddr = sec->_cooked_size; - - irel = elf_section_data (sec)->relocs; - irelend = irel + sec->reloc_count; - for (; irel < irelend; irel++) - { - if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_ALIGN - && irel->r_offset > addr - && count < (1 << irel->r_addend)) - { - irelalign = irel; - toaddr = irel->r_offset; - break; - } - } - - /* Actually delete the bytes. */ - memmove (contents + addr, contents + addr + count, toaddr - addr - count); - if (irelalign == NULL) - sec->_cooked_size -= count; - else - { - int i; - -#define NOP_OPCODE (0x0009) - - BFD_ASSERT ((count & 1) == 0); - for (i = 0; i < count; i += 2) - bfd_put_16 (abfd, NOP_OPCODE, contents + toaddr - count + i); - } - - /* Adjust all the relocs. */ - for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++) - { - bfd_vma nraddr, stop; - bfd_vma start = 0; - int insn = 0; - Elf_Internal_Sym sym; - int off, adjust, oinsn; - bfd_signed_vma voff = 0; - boolean overflow; - - /* Get the new reloc address. */ - nraddr = irel->r_offset; - if ((irel->r_offset > addr - && irel->r_offset < toaddr) - || (ELF32_R_TYPE (irel->r_info) == (int) R_SH_ALIGN - && irel->r_offset == toaddr)) - nraddr -= count; - - /* See if this reloc was for the bytes we have deleted, in which - case we no longer care about it. Don't delete relocs which - represent addresses, though. */ - if (irel->r_offset >= addr - && irel->r_offset < addr + count - && ELF32_R_TYPE (irel->r_info) != (int) R_SH_ALIGN - && ELF32_R_TYPE (irel->r_info) != (int) R_SH_CODE - && ELF32_R_TYPE (irel->r_info) != (int) R_SH_DATA - && ELF32_R_TYPE (irel->r_info) != (int) R_SH_LABEL) - irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), - (int) R_SH_NONE); - - /* If this is a PC relative reloc, see if the range it covers - includes the bytes we have deleted. */ - switch ((enum sh_reloc_type) ELF32_R_TYPE (irel->r_info)) - { - default: - break; - - case R_SH_DIR8WPN: - case R_SH_IND12W: - case R_SH_DIR8WPZ: - case R_SH_DIR8WPL: - start = irel->r_offset; - insn = bfd_get_16 (abfd, contents + nraddr); - break; - } - - switch ((enum sh_reloc_type) ELF32_R_TYPE (irel->r_info)) - { - default: - start = stop = addr; - break; - - case R_SH_DIR32: - /* 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. */ - if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info) - { - bfd_elf32_swap_symbol_in (abfd, - extsyms + ELF32_R_SYM (irel->r_info), - &sym); - if (sym.st_shndx == shndx - && (sym.st_value <= addr - || sym.st_value >= toaddr)) - { - bfd_vma val; - - val = bfd_get_32 (abfd, contents + nraddr); - val += sym.st_value; - if (val >= addr && val < toaddr) - bfd_put_32 (abfd, val - count, contents + nraddr); - } - } - start = stop = addr; - break; - - case R_SH_DIR8WPN: - off = insn & 0xff; - if (off & 0x80) - off -= 0x100; - stop = (bfd_vma) ((bfd_signed_vma) start + 4 + off * 2); - break; - - case R_SH_IND12W: - if (ELF32_R_SYM (irel->r_info) >= symtab_hdr->sh_info) - 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_DIR8WPZ: - off = insn & 0xff; - stop = start + 4 + off * 2; - break; - - case R_SH_DIR8WPL: - 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_offset; - stop = (bfd_vma) ((bfd_signed_vma) start - (long) irel->r_addend); - - if (start > addr - && start < toaddr - && (stop <= addr || stop >= toaddr)) - irel->r_addend += count; - else if (stop > addr - && stop < toaddr - && (start <= addr || start >= toaddr)) - irel->r_addend -= count; - - start = stop; - - if (ELF32_R_TYPE (irel->r_info) == (int) 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_offset; - stop = (bfd_vma) ((bfd_signed_vma) start - + (long) irel->r_addend - + 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 ((enum sh_reloc_type) ELF32_R_TYPE (irel->r_info)) - { - default: - abort (); - break; - - case R_SH_DIR8WPN: - case R_SH_DIR8WPZ: - insn += adjust / 2; - if ((oinsn & 0xff00) != (insn & 0xff00)) - overflow = true; - bfd_put_16 (abfd, insn, contents + nraddr); - break; - - case R_SH_IND12W: - insn += adjust / 2; - if ((oinsn & 0xf000) != (insn & 0xf000)) - overflow = true; - bfd_put_16 (abfd, insn, contents + nraddr); - break; - - case R_SH_DIR8WPL: - BFD_ASSERT (adjust == count || count >= 4); - if (count >= 4) - insn += adjust / 4; - else - { - if ((irel->r_offset & 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_addend += adjust; - break; - } - - if (overflow) - { - ((*_bfd_error_handler) - ("%s: 0x%lx: fatal: reloc overflow while relaxing", - bfd_get_filename (abfd), (unsigned long) irel->r_offset)); - bfd_set_error (bfd_error_bad_value); - return false; - } - } - - irel->r_offset = nraddr; - } - - /* 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) - { - Elf_Internal_Rela *internal_relocs; - Elf_Internal_Rela *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_elf32_link_read_relocs - (abfd, o, (PTR) NULL, (Elf_Internal_Rela *) NULL, - true)); - if (internal_relocs == NULL) - return false; - - ocontents = NULL; - irelscanend = internal_relocs + o->reloc_count; - for (irelscan = internal_relocs; irelscan < irelscanend; irelscan++) - { - Elf_Internal_Sym sym; - - if (ELF32_R_TYPE (irelscan->r_info) != (int) R_SH_DIR32) - continue; - - if (ELF32_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info) - continue; - - bfd_elf32_swap_symbol_in (abfd, - extsyms + ELF32_R_SYM (irelscan->r_info), - &sym); - - if (sym.st_shndx == shndx - && (sym.st_value <= addr - || sym.st_value >= toaddr)) - { - bfd_vma val; - - if (ocontents == NULL) - { - if (elf_section_data (o)->this_hdr.contents != NULL) - ocontents = elf_section_data (o)->this_hdr.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; - elf_section_data (o)->this_hdr.contents = ocontents; - } - } - - val = bfd_get_32 (abfd, ocontents + irelscan->r_offset); - val += sym.st_value; - if (val >= addr && val < toaddr) - bfd_put_32 (abfd, val - count, - ocontents + irelscan->r_offset); - } - } - } - - /* Adjust the local symbols defined in this section. */ - esym = extsyms; - esymend = esym + symtab_hdr->sh_info; - for (; esym < esymend; esym++) - { - Elf_Internal_Sym isym; - - bfd_elf32_swap_symbol_in (abfd, esym, &isym); - - if (isym.st_shndx == shndx - && isym.st_value > addr - && isym.st_value < toaddr) - { - isym.st_value -= count; - bfd_elf32_swap_symbol_out (abfd, &isym, esym); - } - } - - /* Now adjust the global symbols defined in this section. */ - esym = extsyms + symtab_hdr->sh_info; - esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)); - for (index = 0; esym < esymend; esym++, index++) - { - Elf_Internal_Sym isym; - - bfd_elf32_swap_symbol_in (abfd, esym, &isym); - sym_hash = elf_sym_hashes (abfd)[index]; - if (isym.st_shndx == shndx - && ((sym_hash)->root.type == bfd_link_hash_defined - || (sym_hash)->root.type == bfd_link_hash_defweak) - && (sym_hash)->root.u.def.section == sec - && (sym_hash)->root.u.def.value > addr - && (sym_hash)->root.u.def.value < toaddr) - { - (sym_hash)->root.u.def.value -= count; - } - } - - /* See if we can move the ALIGN reloc forward. We have adjusted - r_offset for it already. */ - if (irelalign != NULL) - { - bfd_vma alignto, alignaddr; - - alignto = BFD_ALIGN (toaddr, 1 << irelalign->r_addend); - alignaddr = BFD_ALIGN (irelalign->r_offset, - 1 << irelalign->r_addend); - if (alignto != alignaddr) - { - /* Tail recursion. */ - return sh_elf_relax_delete_bytes (abfd, sec, alignaddr, - alignto - alignaddr); - } - } - - return true; -} - -/* Look for loads and stores which we can align to four byte - boundaries. This is like sh_align_loads in coff-sh.c. */ - -static boolean -sh_elf_align_loads (abfd, sec, internal_relocs, contents, pswapped) - bfd *abfd; - asection *sec; - Elf_Internal_Rela *internal_relocs; - bfd_byte *contents; - boolean *pswapped; -{ - Elf_Internal_Rela *irel, *irelend; - bfd_vma *labels = NULL; - bfd_vma *label, *label_end; - - *pswapped = false; - - irelend = internal_relocs + sec->reloc_count; - - /* Get all the addresses with labels on them. */ - labels = (bfd_vma *) bfd_malloc (sec->reloc_count * sizeof (bfd_vma)); - if (labels == NULL) - goto error_return; - label_end = labels; - for (irel = internal_relocs; irel < irelend; irel++) - { - if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_LABEL) - { - *label_end = irel->r_offset; - ++label_end; - } - } - - /* Note that the assembler currently always outputs relocs in - address order. If that ever changes, this code will need to sort - the label values and the relocs. */ - - label = labels; - - for (irel = internal_relocs; irel < irelend; irel++) - { - bfd_vma start, stop; - - if (ELF32_R_TYPE (irel->r_info) != (int) R_SH_CODE) - continue; - - start = irel->r_offset; - - for (irel++; irel < irelend; irel++) - if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_DATA) - break; - if (irel < irelend) - stop = irel->r_offset; - else - stop = sec->_cooked_size; - - if (! _bfd_sh_align_load_span (abfd, sec, contents, sh_elf_swap_insns, - (PTR) internal_relocs, &label, - label_end, start, stop, pswapped)) - goto error_return; - } - - free (labels); - - return true; - - error_return: - if (labels != NULL) - free (labels); - return false; -} - -/* Swap two SH instructions. This is like sh_swap_insns in coff-sh.c. */ - -static boolean -sh_elf_swap_insns (abfd, sec, relocs, contents, addr) - bfd *abfd; - asection *sec; - PTR relocs; - bfd_byte *contents; - bfd_vma addr; -{ - Elf_Internal_Rela *internal_relocs = (Elf_Internal_Rela *) relocs; - unsigned short i1, i2; - Elf_Internal_Rela *irel, *irelend; - - /* Swap the instructions themselves. */ - i1 = bfd_get_16 (abfd, contents + addr); - i2 = bfd_get_16 (abfd, contents + addr + 2); - bfd_put_16 (abfd, i2, contents + addr); - bfd_put_16 (abfd, i1, contents + addr + 2); - - /* Adjust all reloc addresses. */ - irelend = internal_relocs + sec->reloc_count; - for (irel = internal_relocs; irel < irelend; irel++) - { - enum sh_reloc_type type; - int add; - - /* There are a few special types of relocs that we don't want to - adjust. These relocs do not apply to the instruction itself, - but are only associated with the address. */ - type = (enum sh_reloc_type) ELF32_R_TYPE (irel->r_info); - if (type == R_SH_ALIGN - || type == R_SH_CODE - || type == R_SH_DATA - || type == R_SH_LABEL) - continue; - - /* If an R_SH_USES reloc points to one of the addresses being - swapped, we must adjust it. It would be incorrect to do this - for a jump, though, since we want to execute both - instructions after the jump. (We have avoided swapping - around a label, so the jump will not wind up executing an - instruction it shouldn't). */ - if (type == R_SH_USES) - { - bfd_vma off; - - off = irel->r_offset + 4 + irel->r_addend; - if (off == addr) - irel->r_offset += 2; - else if (off == addr + 2) - irel->r_offset -= 2; - } - - if (irel->r_offset == addr) - { - irel->r_offset += 2; - add = -2; - } - else if (irel->r_offset == addr + 2) - { - irel->r_offset -= 2; - add = 2; - } - else - add = 0; - - if (add != 0) - { - bfd_byte *loc; - unsigned short insn, oinsn; - boolean overflow; - - loc = contents + irel->r_offset; - overflow = false; - switch (type) - { - default: - break; - - case R_SH_DIR8WPN: - case R_SH_DIR8WPZ: - insn = bfd_get_16 (abfd, loc); - oinsn = insn; - insn += add / 2; - if ((oinsn & 0xff00) != (insn & 0xff00)) - overflow = true; - bfd_put_16 (abfd, insn, loc); - break; - - case R_SH_IND12W: - insn = bfd_get_16 (abfd, loc); - oinsn = insn; - insn += add / 2; - if ((oinsn & 0xf000) != (insn & 0xf000)) - overflow = true; - bfd_put_16 (abfd, insn, loc); - break; - - case R_SH_DIR8WPL: - /* This reloc ignores the least significant 3 bits of - the program counter before adding in the offset. - This means that if ADDR is at an even address, the - swap will not affect the offset. If ADDR is an at an - odd address, then the instruction will be crossing a - four byte boundary, and must be adjusted. */ - if ((addr & 3) != 0) - { - insn = bfd_get_16 (abfd, loc); - oinsn = insn; - insn += add / 2; - if ((oinsn & 0xff00) != (insn & 0xff00)) - overflow = true; - bfd_put_16 (abfd, insn, loc); - } - - break; - } - - if (overflow) - { - ((*_bfd_error_handler) - ("%s: 0x%lx: fatal: reloc overflow while relaxing", - bfd_get_filename (abfd), (unsigned long) irel->r_offset)); - bfd_set_error (bfd_error_bad_value); - return false; - } - } - } - - return true; -} - -/* Relocate an SH ELF section. */ - -static boolean -sh_elf_relocate_section (output_bfd, info, input_bfd, input_section, - contents, relocs, local_syms, local_sections) - bfd *output_bfd; - struct bfd_link_info *info; - bfd *input_bfd; - asection *input_section; - bfd_byte *contents; - Elf_Internal_Rela *relocs; - Elf_Internal_Sym *local_syms; - asection **local_sections; -{ - Elf_Internal_Shdr *symtab_hdr; - struct elf_link_hash_entry **sym_hashes; - Elf_Internal_Rela *rel, *relend; - - symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; - sym_hashes = elf_sym_hashes (input_bfd); - - rel = relocs; - relend = relocs + input_section->reloc_count; - for (; rel < relend; rel++) - { - int r_type; - reloc_howto_type *howto; - unsigned long r_symndx; - Elf_Internal_Sym *sym; - asection *sec; - struct elf_link_hash_entry *h; - bfd_vma relocation; - bfd_reloc_status_type r; - - r_symndx = ELF32_R_SYM (rel->r_info); - - 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; - } - - r_type = ELF32_R_TYPE (rel->r_info); - - /* Many of the relocs are only used for relaxing, and are - handled entirely by the relaxation code. */ - if (r_type > (int) LAST_INVALID_RELOC) - continue; - - if (r_type < 0 - || r_type >= (int) FIRST_INVALID_RELOC) - { - bfd_set_error (bfd_error_bad_value); - return false; - } - - /* FIXME: This is certainly incorrect. However, it is how the - COFF linker works. */ - if (r_type != (int) R_SH_DIR32 - && r_type != (int) R_SH_IND12W) - continue; - - howto = sh_elf_howto_table + r_type; - - /* This is a final link. */ - h = NULL; - sym = NULL; - sec = NULL; - if (r_symndx < symtab_hdr->sh_info) - { - /* There is nothing to be done for an internal IND12W - relocation. FIXME: This is probably wrong, but it's how - the COFF relocations work. */ - if (r_type == (int) R_SH_IND12W) - continue; - 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; - } - } - - /* FIXME: This is how the COFF relocations work. */ - if (r_type == (int) R_SH_IND12W) - relocation -= 4; - - /* FIXME: We should use the addend, but the COFF relocations - don't. */ - r = _bfd_final_link_relocate (howto, input_bfd, input_section, - contents, rel->r_offset, - relocation, 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; -} - -/* This is a version of bfd_generic_get_relocated_section_contents - which uses sh_elf_relocate_section. */ - -static bfd_byte * -sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order, - data, relocateable, symbols) - bfd *output_bfd; - struct bfd_link_info *link_info; - struct bfd_link_order *link_order; - bfd_byte *data; - boolean relocateable; - asymbol **symbols; -{ - Elf_Internal_Shdr *symtab_hdr; - asection *input_section = link_order->u.indirect.section; - bfd *input_bfd = input_section->owner; - asection **sections = NULL; - Elf_Internal_Rela *internal_relocs = NULL; - Elf32_External_Sym *external_syms = NULL; - Elf_Internal_Sym *internal_syms = NULL; - - /* We only need to handle the case of relaxing, or of having a - particular set of section contents, specially. */ - if (relocateable - || elf_section_data (input_section)->this_hdr.contents == NULL) - return bfd_generic_get_relocated_section_contents (output_bfd, link_info, - link_order, data, - relocateable, - symbols); - - symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; - - memcpy (data, elf_section_data (input_section)->this_hdr.contents, - input_section->_raw_size); - - if ((input_section->flags & SEC_RELOC) != 0 - && input_section->reloc_count > 0) - { - Elf_Internal_Sym *isymp; - asection **secpp; - Elf32_External_Sym *esym, *esymend; - - if (symtab_hdr->contents != NULL) - external_syms = (Elf32_External_Sym *) symtab_hdr->contents; - else - { - external_syms = ((Elf32_External_Sym *) - bfd_malloc (symtab_hdr->sh_info - * sizeof (Elf32_External_Sym))); - if (external_syms == NULL && symtab_hdr->sh_info > 0) - goto error_return; - if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || (bfd_read (external_syms, sizeof (Elf32_External_Sym), - symtab_hdr->sh_info, input_bfd) - != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym)))) - goto error_return; - } - - internal_relocs = (_bfd_elf32_link_read_relocs - (input_bfd, input_section, (PTR) NULL, - (Elf_Internal_Rela *) NULL, false)); - if (internal_relocs == NULL) - goto error_return; - - internal_syms = ((Elf_Internal_Sym *) - bfd_malloc (symtab_hdr->sh_info - * sizeof (Elf_Internal_Sym))); - if (internal_syms == NULL && symtab_hdr->sh_info > 0) - goto error_return; - - sections = (asection **) bfd_malloc (symtab_hdr->sh_info - * sizeof (asection *)); - if (sections == NULL && symtab_hdr->sh_info > 0) - goto error_return; - - isymp = internal_syms; - secpp = sections; - esym = external_syms; - esymend = esym + symtab_hdr->sh_info; - for (; esym < esymend; ++esym, ++isymp, ++secpp) - { - asection *isec; - - bfd_elf32_swap_symbol_in (input_bfd, esym, isymp); - - if (isymp->st_shndx == SHN_UNDEF) - isec = bfd_und_section_ptr; - else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE) - isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx); - else if (isymp->st_shndx == SHN_ABS) - isec = bfd_abs_section_ptr; - else if (isymp->st_shndx == SHN_COMMON) - isec = bfd_com_section_ptr; - else - { - /* Who knows? */ - isec = NULL; - } - - *secpp = isec; - } - - if (! sh_elf_relocate_section (output_bfd, link_info, input_bfd, - input_section, data, internal_relocs, - internal_syms, sections)) - goto error_return; - - if (sections != NULL) - free (sections); - sections = NULL; - if (internal_syms != NULL) - free (internal_syms); - internal_syms = NULL; - if (external_syms != NULL && symtab_hdr->contents == NULL) - free (external_syms); - external_syms = NULL; - if (internal_relocs != elf_section_data (input_section)->relocs) - free (internal_relocs); - internal_relocs = NULL; - } - - return data; - - error_return: - if (internal_relocs != NULL - && internal_relocs != elf_section_data (input_section)->relocs) - free (internal_relocs); - if (external_syms != NULL && symtab_hdr->contents == NULL) - free (external_syms); - if (internal_syms != NULL) - free (internal_syms); - if (sections != NULL) - free (sections); - return NULL; -} - -#define TARGET_BIG_SYM bfd_elf32_sh_vec -#define TARGET_BIG_NAME "elf32-sh" -#define TARGET_LITTLE_SYM bfd_elf32_shl_vec -#define TARGET_LITTLE_NAME "elf32-shl" -#define ELF_ARCH bfd_arch_sh -#define ELF_MACHINE_CODE EM_SH -#define ELF_MAXPAGESIZE 0x1 - -#define elf_symbol_leading_char '_' - -#define bfd_elf32_bfd_reloc_type_lookup sh_elf_reloc_type_lookup -#define elf_info_to_howto sh_elf_info_to_howto -#define bfd_elf32_bfd_relax_section sh_elf_relax_section -#define elf_backend_relocate_section sh_elf_relocate_section -#define bfd_elf32_bfd_get_relocated_section_contents \ - sh_elf_get_relocated_section_contents - -#include "elf32-target.h" diff --git a/contrib/binutils/bfd/filemode.c b/contrib/binutils/bfd/filemode.c deleted file mode 100644 index 6f4596872ca8..000000000000 --- a/contrib/binutils/bfd/filemode.c +++ /dev/null @@ -1,194 +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 "sysdep.h" -#include -#include - -void mode_string (); -static char ftypelet (); -static void rwx (); -static void setst (); - -/* filemodestring - fill in string STR with an ls-style ASCII - representation of the st_mode field of file stats block STATP. - 10 characters are stored in STR; no terminating null is added. - The characters stored in STR are: - - 0 File type. 'd' for directory, 'c' for character - special, 'b' for block special, 'm' for multiplex, - 'l' for symbolic link, 's' for socket, 'p' for fifo, - '-' for any other file type - - 1 'r' if the owner may read, '-' otherwise. - - 2 'w' if the owner may write, '-' otherwise. - - 3 'x' if the owner may execute, 's' if the file is - set-user-id, '-' otherwise. - 'S' if the file is set-user-id, but the execute - bit isn't set. - - 4 'r' if group members may read, '-' otherwise. - - 5 'w' if group members may write, '-' otherwise. - - 6 'x' if group members may execute, 's' if the file is - set-group-id, '-' otherwise. - 'S' if it is set-group-id but not executable. - - 7 'r' if any user may read, '-' otherwise. - - 8 'w' if any user may write, '-' otherwise. - - 9 'x' if any user may execute, 't' if the file is "sticky" - (will be retained in swap space after execution), '-' - otherwise. - 'T' if the file is sticky but not executable. */ - -void -filemodestring (statp, str) - struct stat *statp; - char *str; -{ - mode_string (statp->st_mode, str); -} - -/* Like filemodestring, but only the relevant part of the `struct stat' - is given as an argument. */ - -void -mode_string (mode, str) - unsigned short mode; - char *str; -{ - str[0] = ftypelet (mode); - rwx ((mode & 0700) << 0, &str[1]); - rwx ((mode & 0070) << 3, &str[4]); - rwx ((mode & 0007) << 6, &str[7]); - setst (mode, str); -} - -/* Return a character indicating the type of file described by - file mode BITS: - 'd' for directories - 'b' for block special files - 'c' for character special files - 'm' for multiplexor files - 'l' for symbolic links - 's' for sockets - 'p' for fifos - '-' for any other file type. */ - -static char -ftypelet (bits) - unsigned short bits; -{ - switch (bits & S_IFMT) - { - default: - return '-'; - case S_IFDIR: - return 'd'; -#ifdef S_IFLNK - case S_IFLNK: - return 'l'; -#endif -#ifdef S_IFCHR - case S_IFCHR: - return 'c'; -#endif -#ifdef S_IFBLK - case S_IFBLK: - return 'b'; -#endif -#ifdef S_IFMPC - case S_IFMPC: - case S_IFMPB: - return 'm'; -#endif -#ifdef S_IFSOCK - case S_IFSOCK: - return 's'; -#endif -#ifdef S_IFIFO -#if S_IFIFO != S_IFSOCK - case S_IFIFO: - return 'p'; -#endif -#endif -#ifdef S_IFNWK /* HP-UX */ - case S_IFNWK: - return 'n'; -#endif - } -} - -/* Look at read, write, and execute bits in BITS and set - flags in CHARS accordingly. */ - -static void -rwx (bits, chars) - unsigned short bits; - char *chars; -{ - chars[0] = (bits & S_IREAD) ? 'r' : '-'; - chars[1] = (bits & S_IWRITE) ? 'w' : '-'; - chars[2] = (bits & S_IEXEC) ? 'x' : '-'; -} - -/* Set the 's' and 't' flags in file attributes string CHARS, - according to the file mode BITS. */ - -static void -setst (bits, chars) - unsigned short bits; - char *chars; -{ -#ifdef S_ISUID - if (bits & S_ISUID) - { - if (chars[3] != 'x') - /* Set-uid, but not executable by owner. */ - chars[3] = 'S'; - else - chars[3] = 's'; - } -#endif -#ifdef S_ISGID - if (bits & S_ISGID) - { - if (chars[6] != 'x') - /* Set-gid, but not executable by group. */ - chars[6] = 'S'; - else - chars[6] = 's'; - } -#endif -#ifdef S_ISVTX - if (bits & S_ISVTX) - { - if (chars[9] != 'x') - /* Sticky, but not executable by others. */ - chars[9] = 'T'; - else - chars[9] = 't'; - } -#endif -} - - diff --git a/contrib/binutils/bfd/sunos.c b/contrib/binutils/bfd/sunos.c deleted file mode 100644 index 45e0cba992a0..000000000000 --- a/contrib/binutils/bfd/sunos.c +++ /dev/null @@ -1,2918 +0,0 @@ -/* BFD backend for SunOS binaries. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998 - 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 - -/* ??? Where should this go? */ -#define MACHTYPE_OK(mtype) \ - (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \ - || ((mtype) == M_SPARCLET \ - && bfd_lookup_arch (bfd_arch_sparc, bfd_mach_sparc_sparclet) != NULL) \ - || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \ - && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL)) - -/* 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
, %g1 */ -#define SPARC_PLT_PIC_WORD0 0x03000000 -/* jmp %g1 +
*/ -#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; - - /* Whether we need the .got table. */ - boolean got_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; - - /* The offset of __GLOBAL_OFFSET_TABLE_ into the .got section. */ - bfd_vma got_base; -}; - -/* 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->got_needed = false; - ret->dynsymcount = 0; - ret->bucketcount = 0; - ret->needed = NULL; - ret->got_base = 0; - - 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 - | SEC_LINKER_CREATED); - - /* 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) - || info->shared) - { - bfd *dynobj; - - dynobj = sunos_hash_table (info)->dynobj; - - s = bfd_get_section_by_name (dynobj, ".got"); - if (s->_raw_size == 0) - s->_raw_size = BYTES_IN_WORD; - - sunos_hash_table (info)->dynamic_sections_needed = true; - sunos_hash_table (info)->got_needed = true; - } - - return true; -} - -/* Add dynamic symbols during a link. This is called by the a.out - backend linker for each object it encounters. */ - -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; - - /* Make sure we have all the required sections. */ - if (info->hash->creator == abfd->xvec) - { - if (! sunos_create_dynamic_sections (abfd, info, - (((abfd->flags & DYNAMIC) != 0 - && ! info->relocateable) - ? true - : false))) - return false; - } - - /* There is nothing else to do for a normal object. */ - if ((abfd->flags & DYNAMIC) == 0) - return true; - - dynobj = sunos_hash_table (info)->dynobj; - - /* 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. If this is the first object we have - seen, we must preserve the dynamic sections we just created. */ - if (abfd != dynobj) - abfd->sections = NULL; - else - { - asection *s; - - for (s = abfd->sections; - (s->flags & SEC_LINKER_CREATED) == 0; - s = s->next) - ; - abfd->sections = s; - } - - /* 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 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. */ - 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; - char *namebuf, *p; - size_t alc; - bfd_byte b; - char *namecopy; - - 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 = (unsigned short)bfd_get_16 (abfd, buf + 8); - minor_vno = (unsigned short)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]. */ - alc = 30; - namebuf = (char *) bfd_malloc (alc + 1); - if (namebuf == NULL) - return false; - p = namebuf; - - if ((flags & 0x80000000) != 0) - { - *p++ = '-'; - *p++ = 'l'; - } - if (bfd_seek (abfd, name, SEEK_SET) != 0) - { - free (namebuf); - return false; - } - - do - { - if (bfd_read (&b, 1, 1, abfd) != 1) - { - free (namebuf); - return false; - } - - if ((size_t) (p - namebuf) >= alc) - { - char *n; - - alc *= 2; - n = (char *) bfd_realloc (namebuf, alc + 1); - if (n == NULL) - { - free (namebuf); - return false; - } - p = n + (p - namebuf); - namebuf = n; - } - - *p++ = b; - } - while (b != '\0'); - - if (major_vno == 0) - *p = '\0'; - else - { - char majbuf[30]; - char minbuf[30]; - - sprintf (majbuf, ".%d", major_vno); - if (minor_vno == 0) - minbuf[0] = '\0'; - else - sprintf (minbuf, ".%d", minor_vno); - - if ((p - namebuf) + strlen (majbuf) + strlen (minbuf) >= alc) - { - char *n; - - alc = (p - namebuf) + strlen (majbuf) + strlen (minbuf); - n = (char *) bfd_realloc (namebuf, alc + 1); - if (n == NULL) - { - free (namebuf); - return false; - } - p = n + (p - namebuf); - namebuf = n; - } - - strcpy (p, majbuf); - strcat (p, minbuf); - } - - namecopy = bfd_alloc (abfd, strlen (namebuf) + 1); - if (namecopy == NULL) - { - free (namebuf); - return false; - } - strcpy (namecopy, namebuf); - free (namebuf); - needed->name = namecopy; - - 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 ((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_undefined; - h->root.root.u.undef.abfd = h->root.root.u.def.section->owner; - } - 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 (info->relocateable) - return true; - - 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 - && ! sunos_hash_table (info)->got_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"); - - /* If the .got section is more than 0x1000 bytes, we set - __GLOBAL_OFFSET_TABLE_ to be 0x1000 bytes into the section, - so that 13 bit relocations have a greater chance of working. */ - s = bfd_get_section_by_name (dynobj, ".got"); - BFD_ASSERT (s != NULL); - if (s->_raw_size >= 0x1000) - h->root.root.u.def.value = 0x1000; - else - h->root.root.u.def.value = 0; - - sunos_hash_table (info)->got_base = h->root.root.u.def.value; - } - - /* If there are any shared objects in the link, then we need to set - up the dynamic linking information. */ - if (sunos_hash_table (info)->dynamic_sections_needed) - { - *sdynptr = bfd_get_section_by_name (dynobj, ".dynamic"); - - /* The .dynamic section is always the same size. */ - s = *sdynptr; - 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; - - *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) - { - asection *sgot; - - if (! sunos_create_dynamic_sections (abfd, info, false)) - 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); - - sgot = bfd_get_section_by_name (dynobj, ".got"); - BFD_ASSERT (sgot != NULL); - if (sgot->_raw_size == 0) - sgot->_raw_size = BYTES_IN_WORD; - sunos_hash_table (info)->got_needed = true; - } - - 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, false)) - 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); - - /* Make sure we have an initial entry in the .got table. */ - if (sgot->_raw_size == 0) - sgot->_raw_size = BYTES_IN_WORD; - sunos_hash_table (info)->got_needed = true; - } - - 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, false)) - 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); - - /* Make sure we have an initial entry in the .got table. */ - if (sgot->_raw_size == 0) - sgot->_raw_size = BYTES_IN_WORD; - sunos_hash_table (info)->got_needed = true; - } - - 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 ((char *) 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 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 (h->dynindx >= 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] = (bfd_byte)(h->dynindx >> 16); - srel->r_index[1] = (bfd_byte)(h->dynindx >> 8); - srel->r_index[2] = (bfd_byte)(h->dynindx); - srel->r_type[0] = (RELOC_STD_BITS_EXTERN_BIG - | RELOC_STD_BITS_JMPTABLE_BIG); - } - else - { - srel->r_index[2] = (bfd_byte)(h->dynindx >> 16); - srel->r_index[1] = (bfd_byte)(h->dynindx >> 8); - srel->r_index[0] = (bfd_byte)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] = (bfd_byte)(h->dynindx >> 16); - erel->r_index[1] = (bfd_byte)(h->dynindx >> 8); - erel->r_index[2] = (bfd_byte)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] = (bfd_byte)(h->dynindx >> 16); - erel->r_index[1] = (bfd_byte)(h->dynindx >> 8); - erel->r_index[0] = (bfd_byte)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; - } - } - - /* If this is not a dynamic symbol, we don't have to do anything - else. We only check this after handling the PLT entry, because - we can have a PLT entry for a nondynamic symbol when linking PIC - compiled code from a regular object. */ - 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); - - 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] = (bfd_byte)(indx >> 16); - srel->r_index[1] = (bfd_byte)(indx >> 8); - srel->r_index[2] = (bfd_byte)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] = (bfd_byte)(indx >> 16); - srel->r_index[1] = (bfd_byte)(indx >> 8); - srel->r_index[0] = (bfd_byte)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] = (bfd_byte)(indx >> 16); - erel->r_index[1] = (bfd_byte)(indx >> 8); - erel->r_index[2] = (bfd_byte)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] = (bfd_byte)(indx >> 16); - erel->r_index[1] = (bfd_byte)(indx >> 8); - erel->r_index[0] = (bfd_byte)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) - - sunos_hash_table (info)->got_base); - - /* 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] = (bfd_byte)(indx >> 16); - srel->r_index[1] = (bfd_byte)(indx >> 8); - srel->r_index[2] = (bfd_byte)indx; - } - else - { - srel->r_index[2] = (bfd_byte)(indx >> 16); - srel->r_index[1] = (bfd_byte)(indx >> 8); - srel->r_index[0] = (bfd_byte)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] = (bfd_byte)(indx >> 16); - erel->r_index[1] = (bfd_byte)(indx >> 8); - erel->r_index[2] = (bfd_byte)indx; - } - else - { - erel->r_index[2] = (bfd_byte)(indx >> 16); - erel->r_index[1] = (bfd_byte)(indx >> 8); - erel->r_index[0] = (bfd_byte)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; - - if (! sunos_hash_table (info)->dynamic_sections_needed - && ! sunos_hash_table (info)->got_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 || sdyn->_raw_size == 0) - 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; - } - } - - if (sdyn->_raw_size > 0) - { - struct external_sun4_dynamic esd; - struct external_sun4_dynamic_link esdl; - - /* 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/binutils/binutils/acconfig.h b/contrib/binutils/binutils/acconfig.h deleted file mode 100644 index c38c529c901c..000000000000 --- a/contrib/binutils/binutils/acconfig.h +++ /dev/null @@ -1,34 +0,0 @@ - -/* Name of package. */ -#undef PACKAGE - -/* Version of package. */ -#undef VERSION - -/* Configured target name. */ -#undef TARGET - -/* Whether strstr must be declared even if is included. */ -#undef NEED_DECLARATION_STRSTR - -/* Whether fprintf must be declared even if is included. */ -#undef NEED_DECLARATION_FPRINTF - -/* Whether sbrk must be declared even if is included. */ -#undef NEED_DECLARATION_SBRK - -/* Whether getenv must be declared even if is included. */ -#undef NEED_DECLARATION_GETENV -@TOP@ - -/* Is the type time_t defined in ? */ -#undef HAVE_TIME_T_IN_TIME_H - -/* Is the type time_t defined in ? */ -#undef HAVE_TIME_T_IN_TYPES_H - -/* Does define struct utimbuf? */ -#undef HAVE_GOOD_UTIME_H - -/* Do we need to use the b modifier when opening binary files? */ -#undef USE_BINARY_FOPEN diff --git a/contrib/binutils/binutils/config.texi b/contrib/binutils/binutils/config.texi deleted file mode 100644 index d40699c4cdfa..000000000000 --- a/contrib/binutils/binutils/config.texi +++ /dev/null @@ -1 +0,0 @@ -@set VERSION 2.9.1 diff --git a/contrib/binutils/binutils/defparse.c b/contrib/binutils/binutils/defparse.c deleted file mode 100644 index 1212c6b932cb..000000000000 --- a/contrib/binutils/binutils/defparse.c +++ /dev/null @@ -1,1056 +0,0 @@ - -/* A Bison parser, made from /5g/ian/binutils/release/copy/binutils/defparse.y - by GNU Bison version 1.25 - */ - -#define YYBISON 1 /* Identify Bison output. */ - -#define NAME 258 -#define LIBRARY 259 -#define DESCRIPTION 260 -#define STACKSIZE 261 -#define HEAPSIZE 262 -#define CODE 263 -#define DATA 264 -#define SECTIONS 265 -#define EXPORTS 266 -#define IMPORTS 267 -#define VERSIONK 268 -#define BASE 269 -#define CONSTANT 270 -#define READ 271 -#define WRITE 272 -#define EXECUTE 273 -#define SHARED 274 -#define NONAME 275 -#define ID 276 -#define NUMBER 277 - -#line 1 "/5g/ian/binutils/release/copy/binutils/defparse.y" - /* defparse.y - parser for .def files */ - -/* Copyright (C) 1995, 1997 Free Software Foundation, Inc. - -This file is part of GNU Binutils. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include "bfd.h" -#include "bucomm.h" -#include "dlltool.h" - -#line 26 "/5g/ian/binutils/release/copy/binutils/defparse.y" -typedef union { - char *id; - int number; -} YYSTYPE; -#include - -#ifndef __cplusplus -#ifndef __STDC__ -#define const -#endif -#endif - - - -#define YYFINAL 75 -#define YYFLAG -32768 -#define YYNTBASE 27 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 277 ? yytranslate[x] : 46) - -static const char yytranslate[] = { 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 25, 2, 23, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 24, 2, 2, 26, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22 -}; - -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 3, 5, 9, 13, 16, 19, 23, 27, 30, - 33, 36, 39, 42, 47, 48, 50, 53, 60, 63, - 65, 71, 75, 78, 80, 83, 87, 89, 91, 92, - 95, 96, 98, 100, 102, 104, 106, 107, 109, 110, - 112, 113, 115, 116, 119, 120, 123, 124, 128 -}; - -static const short yyrhs[] = { 27, - 28, 0, 28, 0, 3, 42, 45, 0, 4, 42, - 45, 0, 11, 29, 0, 5, 21, 0, 6, 22, - 37, 0, 7, 22, 37, 0, 8, 35, 0, 9, - 35, 0, 10, 33, 0, 12, 31, 0, 13, 22, - 0, 13, 22, 23, 22, 0, 0, 30, 0, 29, - 30, 0, 21, 44, 43, 40, 39, 41, 0, 31, - 32, 0, 32, 0, 21, 24, 21, 23, 21, 0, - 21, 23, 21, 0, 33, 34, 0, 34, 0, 21, - 35, 0, 35, 36, 38, 0, 38, 0, 25, 0, - 0, 25, 22, 0, 0, 16, 0, 17, 0, 18, - 0, 19, 0, 15, 0, 0, 20, 0, 0, 9, - 0, 0, 21, 0, 0, 26, 22, 0, 0, 24, - 21, 0, 0, 14, 24, 22, 0, 0 -}; - -#endif - -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 42, 43, 46, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 62, 64, 65, 68, 72, 74, - 77, 79, 81, 83, 86, 90, 92, 95, 97, 99, - 100, 103, 105, 106, 107, 110, 112, 115, 117, 120, - 122, 125, 126, 129, 131, 134, 136, 139, 140 -}; -#endif - - -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) - -static const char * const yytname[] = { "$","error","$undefined.","NAME","LIBRARY", -"DESCRIPTION","STACKSIZE","HEAPSIZE","CODE","DATA","SECTIONS","EXPORTS","IMPORTS", -"VERSIONK","BASE","CONSTANT","READ","WRITE","EXECUTE","SHARED","NONAME","ID", -"NUMBER","'.'","'='","','","'@'","start","command","explist","expline","implist", -"impline","seclist","secline","attr_list","opt_comma","opt_number","attr","opt_CONSTANT", -"opt_NONAME","opt_DATA","opt_name","opt_ordinal","opt_equal_name","opt_base", NULL -}; -#endif - -static const short yyr1[] = { 0, - 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 29, 29, 29, 30, 31, 31, - 32, 32, 33, 33, 34, 35, 35, 36, 36, 37, - 37, 38, 38, 38, 38, 39, 39, 40, 40, 41, - 41, 42, 42, 43, 43, 44, 44, 45, 45 -}; - -static const short yyr2[] = { 0, - 2, 1, 3, 3, 2, 2, 3, 3, 2, 2, - 2, 2, 2, 4, 0, 1, 2, 6, 2, 1, - 5, 3, 2, 1, 2, 3, 1, 1, 0, 2, - 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, - 0, 1, 0, 2, 0, 2, 0, 3, 0 -}; - -static const short yydefact[] = { 0, - 43, 43, 0, 0, 0, 0, 0, 0, 15, 0, - 0, 0, 2, 42, 49, 49, 6, 31, 31, 32, - 33, 34, 35, 9, 27, 10, 0, 11, 24, 47, - 5, 16, 0, 12, 20, 13, 1, 0, 3, 4, - 0, 7, 8, 28, 0, 25, 23, 0, 45, 17, - 0, 0, 19, 0, 0, 30, 26, 46, 0, 39, - 22, 0, 14, 48, 44, 38, 37, 0, 36, 41, - 21, 40, 18, 0, 0 -}; - -static const short yydefgoto[] = { 12, - 13, 31, 32, 34, 35, 28, 29, 24, 45, 42, - 25, 70, 67, 73, 15, 60, 49, 39 -}; - -static const short yypact[] = { 18, - -2, -2, 15, 17, 20, -1, -1, 19, 22, 23, - 24, 1,-32768,-32768, 31, 31,-32768, 12, 12,-32768, --32768,-32768,-32768, 16,-32768, 16, -1, 19,-32768, 14, - 22,-32768, -21, 23,-32768, 25,-32768, 26,-32768,-32768, - 27,-32768,-32768,-32768, -1, 16,-32768, 30, 21,-32768, - 32, 33,-32768, 34, 35,-32768,-32768,-32768, 36, 39, --32768, 29,-32768,-32768,-32768,-32768, 40, 41,-32768, 51, --32768,-32768,-32768, 61,-32768 -}; - -static const short yypgoto[] = {-32768, - 52,-32768, 37,-32768, 38,-32768, 42, -7,-32768, 44, - 28,-32768,-32768,-32768, 63,-32768,-32768, 50 -}; - - -#define YYLAST 73 - - -static const short yytable[] = { 26, - 74, 51, 52, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 20, 21, 22, 23, 14, 46, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, -29, -29, -29, -29, 17, 41, 48, 18, 27, - 44, 19, 30, 33, 38, 36, 59, 54, 56, 55, - 58, 68, 61, 62, 69, 63, 64, 65, 66, 72, - 75, 71, 43, 37, 16, 40, 0, 50, 0, 47, - 0, 53, 57 -}; - -static const short yycheck[] = { 7, - 0, 23, 24, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 16, 17, 18, 19, 21, 27, - 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 16, 17, 18, 19, 21, 25, 24, 22, 21, - 25, 22, 21, 21, 14, 22, 26, 23, 22, 24, - 21, 23, 21, 21, 15, 22, 22, 22, 20, 9, - 0, 21, 19, 12, 2, 16, -1, 31, -1, 28, - -1, 34, 45 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/cygnus/progressive-97r2/share/bison.simple" - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -#ifndef alloca -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) -#include -#else /* not sparc */ -#if defined (MSDOS) && !defined (__TURBOC__) -#include -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -#include - #pragma alloca -#else /* not MSDOS, __TURBOC__, or _AIX */ -#ifdef __hpux -#ifdef __cplusplus -extern "C" { -void *alloca (unsigned int); -}; -#else /* not __cplusplus */ -void *alloca (); -#endif /* not __cplusplus */ -#endif /* __hpux */ -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc. */ -#endif /* not GNU C. */ -#endif /* alloca not defined. */ - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT return(0) -#define YYABORT return(1) -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) -#endif -#else /* not YYLSP_NEEDED */ -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -int yyparse (void); -#endif - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - int count; -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (char *to, char *from, int count) -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif -#endif - -#line 196 "/usr/cygnus/progressive-97r2/share/bison.simple" - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - int yystacksize = YYINITDEPTH; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); - yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - goto yybackup; - yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - - switch (yyn) { - -case 3: -#line 47 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_name (yyvsp[-1].id, yyvsp[0].number); ; - break;} -case 4: -#line 48 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_library (yyvsp[-1].id, yyvsp[0].number); ; - break;} -case 6: -#line 50 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_description (yyvsp[0].id);; - break;} -case 7: -#line 51 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_stacksize (yyvsp[-1].number, yyvsp[0].number);; - break;} -case 8: -#line 52 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_heapsize (yyvsp[-1].number, yyvsp[0].number);; - break;} -case 9: -#line 53 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_code (yyvsp[0].number);; - break;} -case 10: -#line 54 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_data (yyvsp[0].number);; - break;} -case 13: -#line 57 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_version (yyvsp[0].number,0);; - break;} -case 14: -#line 58 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_version (yyvsp[-2].number,yyvsp[0].number);; - break;} -case 18: -#line 70 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_exports (yyvsp[-5].id, yyvsp[-4].id, yyvsp[-3].number, yyvsp[-2].number, yyvsp[-1].number, yyvsp[0].number);; - break;} -case 21: -#line 78 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_import (yyvsp[-4].id,yyvsp[-2].id,yyvsp[0].id);; - break;} -case 22: -#line 79 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_import (0, yyvsp[-2].id,yyvsp[0].id);; - break;} -case 25: -#line 87 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ def_section (yyvsp[-1].id,yyvsp[0].number);; - break;} -case 30: -#line 99 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number=yyvsp[0].number;; - break;} -case 31: -#line 100 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number=-1;; - break;} -case 32: -#line 104 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number = 1;; - break;} -case 33: -#line 105 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number = 2;; - break;} -case 34: -#line 106 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number=4;; - break;} -case 35: -#line 107 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number=8;; - break;} -case 36: -#line 111 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{yyval.number=1;; - break;} -case 37: -#line 112 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{yyval.number=0;; - break;} -case 38: -#line 116 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{yyval.number=1;; - break;} -case 39: -#line 117 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{yyval.number=0;; - break;} -case 40: -#line 121 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number = 1; ; - break;} -case 41: -#line 122 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number = 0; ; - break;} -case 42: -#line 125 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.id =yyvsp[0].id; ; - break;} -case 43: -#line 126 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.id=""; ; - break;} -case 44: -#line 130 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number=yyvsp[0].number;; - break;} -case 45: -#line 131 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number=-1;; - break;} -case 46: -#line 135 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.id = yyvsp[0].id; ; - break;} -case 47: -#line 136 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.id = 0; ; - break;} -case 48: -#line 139 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number= yyvsp[0].number;; - break;} -case 49: -#line 140 "/5g/ian/binutils/release/copy/binutils/defparse.y" -{ yyval.number=-1;; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 498 "/usr/cygnus/progressive-97r2/share/bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror ("parse error; also virtual memory exceeded"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ - - if (yyerrstatus == 3) - { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; -} -#line 145 "/5g/ian/binutils/release/copy/binutils/defparse.y" diff --git a/contrib/binutils/binutils/defparse.h b/contrib/binutils/binutils/defparse.h deleted file mode 100644 index fa35fb025b36..000000000000 --- a/contrib/binutils/binutils/defparse.h +++ /dev/null @@ -1,27 +0,0 @@ -typedef union { - char *id; - int number; -} YYSTYPE; -#define NAME 258 -#define LIBRARY 259 -#define DESCRIPTION 260 -#define STACKSIZE 261 -#define HEAPSIZE 262 -#define CODE 263 -#define DATA 264 -#define SECTIONS 265 -#define EXPORTS 266 -#define IMPORTS 267 -#define VERSIONK 268 -#define BASE 269 -#define CONSTANT 270 -#define READ 271 -#define WRITE 272 -#define EXECUTE 273 -#define SHARED 274 -#define NONAME 275 -#define ID 276 -#define NUMBER 277 - - -extern YYSTYPE yylval; diff --git a/contrib/binutils/binutils/rclex.c b/contrib/binutils/binutils/rclex.c deleted file mode 100644 index 3c9682ee8bde..000000000000 --- a/contrib/binutils/binutils/rclex.c +++ /dev/null @@ -1,2526 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.85 95/04/24 10:48:47 vern Exp $ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include -#include - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include -#include -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 86 -#define YY_END_OF_BUFFER 87 -static yyconst short int yy_accept[470] = - { 0, - 0, 0, 87, 85, 84, 83, 85, 78, 80, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 2, 4, 84, - 0, 81, 78, 80, 79, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 81, 0, 82, 11, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - - 82, 82, 82, 82, 82, 3, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 76, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 41, 82, 82, - 82, 53, 42, 82, 82, 82, 82, 82, 82, 82, - 46, 82, 82, 82, 82, 82, 82, 71, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - - 82, 82, 82, 7, 82, 82, 82, 38, 1, 82, - 82, 82, 82, 82, 18, 82, 82, 25, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 70, - 82, 82, 39, 40, 82, 82, 82, 82, 82, 30, - 82, 82, 82, 82, 82, 82, 50, 82, 82, 82, - 82, 82, 34, 82, 82, 9, 82, 82, 19, 82, - 68, 82, 82, 82, 82, 82, 82, 12, 0, 82, - 82, 82, 82, 82, 82, 82, 13, 82, 14, 82, - 82, 82, 82, 65, 82, 82, 82, 52, 82, 72, - 82, 82, 82, 82, 82, 82, 47, 82, 82, 82, - - 82, 82, 82, 82, 82, 82, 58, 82, 82, 36, - 82, 82, 82, 82, 82, 82, 82, 82, 0, 82, - 0, 77, 17, 82, 82, 51, 82, 10, 82, 82, - 82, 82, 16, 82, 82, 82, 82, 82, 82, 82, - 29, 82, 82, 82, 82, 82, 82, 82, 73, 82, - 31, 82, 82, 82, 82, 82, 82, 45, 6, 82, - 82, 82, 82, 77, 82, 23, 24, 82, 15, 82, - 27, 82, 82, 66, 82, 28, 54, 43, 82, 82, - 82, 48, 82, 69, 8, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - - 64, 82, 82, 82, 82, 56, 82, 82, 82, 82, - 35, 49, 82, 82, 82, 82, 20, 82, 82, 82, - 82, 82, 82, 82, 82, 74, 82, 82, 82, 32, - 82, 82, 37, 82, 82, 82, 82, 82, 82, 75, - 82, 67, 61, 82, 82, 82, 33, 59, 60, 5, - 21, 82, 82, 82, 82, 55, 57, 82, 82, 82, - 26, 63, 82, 82, 82, 62, 22, 44, 0 - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 6, 1, 1, 1, 1, 1, - 1, 1, 1, 7, 1, 1, 1, 8, 8, 8, - 9, 8, 8, 8, 8, 8, 8, 1, 1, 1, - 1, 1, 1, 1, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 19, 26, 27, 28, 29, 30, 19, 31, 32, 19, - 1, 1, 1, 1, 1, 1, 33, 33, 33, 33, - - 33, 33, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 33, - 19, 19, 34, 1, 35, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst int yy_meta[36] = - { 0, - 1, 2, 3, 2, 1, 4, 2, 5, 5, 5, - 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, - 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 5, 1, 1 - } ; - -static yyconst short int yy_base[476] = - { 0, - 0, 0, 515, 516, 34, 516, 509, 0, 492, 25, - 26, 45, 25, 28, 24, 486, 497, 49, 0, 40, - 43, 486, 51, 66, 67, 482, 35, 516, 516, 81, - 503, 84, 0, 486, 516, 0, 494, 477, 492, 475, - 74, 474, 477, 475, 46, 489, 69, 484, 471, 481, - 55, 477, 481, 466, 67, 469, 83, 83, 467, 477, - 464, 478, 464, 459, 475, 470, 74, 453, 81, 457, - 86, 76, 468, 467, 465, 452, 452, 458, 95, 461, - 453, 447, 446, 106, 466, 456, 0, 451, 444, 449, - 448, 443, 452, 435, 436, 449, 433, 448, 430, 426, - - 429, 430, 433, 441, 424, 0, 423, 436, 435, 420, - 415, 417, 427, 419, 420, 424, 412, 428, 423, 410, - 424, 405, 406, 407, 419, 409, 0, 402, 409, 416, - 414, 410, 408, 415, 393, 399, 412, 406, 392, 401, - 397, 391, 387, 388, 386, 392, 394, 103, 383, 387, - 399, 388, 389, 396, 385, 377, 379, 376, 373, 376, - 370, 374, 387, 368, 363, 98, 381, 0, 379, 367, - 363, 0, 0, 362, 363, 360, 358, 375, 361, 356, - 105, 373, 372, 351, 355, 355, 349, 0, 366, 352, - 347, 346, 352, 346, 343, 356, 346, 354, 356, 352, - - 347, 344, 349, 0, 335, 344, 350, 0, 0, 334, - 115, 334, 345, 119, 0, 345, 331, 0, 328, 326, - 336, 325, 336, 328, 327, 320, 317, 313, 330, 0, - 330, 331, 0, 0, 327, 322, 329, 314, 314, 0, - 114, 305, 307, 318, 322, 318, 0, 321, 318, 107, - 318, 318, 0, 306, 316, 0, 316, 308, 0, 294, - 0, 298, 307, 294, 291, 304, 304, 0, 132, 137, - 293, 287, 290, 300, 288, 290, 0, 293, 295, 295, - 276, 292, 295, 0, 293, 278, 276, 0, 277, 0, - 270, 283, 267, 285, 270, 281, 0, 280, 279, 271, - - 265, 277, 261, 257, 259, 257, 0, 274, 256, 0, - 255, 254, 258, 248, 269, 268, 265, 258, 270, 143, - 269, 149, 0, 259, 241, 0, 240, 0, 259, 238, - 258, 239, 0, 250, 237, 250, 236, 231, 247, 246, - 0, 249, 247, 247, 234, 227, 240, 225, 0, 222, - 0, 223, 222, 239, 224, 237, 218, 227, 0, 216, - 215, 222, 217, 235, 213, 0, 0, 209, 0, 226, - 0, 209, 203, 0, 216, 0, 0, 0, 212, 206, - 211, 0, 220, 0, 0, 215, 204, 199, 200, 199, - 213, 199, 199, 197, 206, 208, 207, 199, 188, 194, - - 192, 188, 188, 190, 196, 0, 198, 182, 184, 182, - 0, 0, 184, 181, 188, 176, 0, 177, 171, 172, - 170, 183, 186, 181, 171, 0, 183, 171, 164, 0, - 167, 175, 0, 164, 160, 155, 157, 156, 159, 0, - 155, 0, 0, 160, 165, 156, 0, 0, 0, 0, - 0, 141, 150, 141, 139, 0, 0, 128, 122, 126, - 0, 0, 109, 91, 79, 0, 0, 0, 516, 156, - 161, 65, 166, 171, 176 - } ; - -static yyconst short int yy_def[476] = - { 0, - 469, 1, 469, 469, 469, 469, 470, 471, 472, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 469, 469, 469, - 470, 469, 471, 472, 469, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 469, 470, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 469, 474, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 475, 474, - 475, 474, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 475, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 473, 473, 473, 0, 469, - 469, 469, 469, 469, 469 - } ; - -static yyconst short int yy_nxt[552] = - { 0, - 4, 5, 6, 5, 7, 8, 4, 9, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, - 20, 21, 22, 19, 23, 24, 25, 19, 26, 27, - 19, 19, 19, 28, 29, 30, 37, 30, 50, 41, - 52, 55, 51, 42, 81, 38, 43, 56, 82, 63, - 53, 39, 83, 40, 44, 95, 67, 64, 54, 96, - 59, 45, 60, 65, 103, 46, 68, 66, 47, 34, - 61, 62, 48, 49, 70, 73, 71, 74, 76, 72, - 77, 104, 30, 78, 30, 84, 90, 108, 85, 91, - 98, 99, 111, 75, 79, 113, 123, 109, 126, 129, - - 124, 131, 132, 114, 139, 468, 112, 84, 127, 130, - 85, 205, 225, 467, 206, 241, 269, 269, 242, 270, - 140, 226, 243, 295, 227, 228, 141, 229, 207, 273, - 304, 466, 274, 269, 269, 305, 319, 465, 321, 296, - 321, 322, 36, 321, 321, 464, 321, 322, 36, 321, - 321, 463, 321, 322, 36, 321, 31, 31, 462, 31, - 31, 33, 33, 461, 33, 33, 36, 460, 459, 36, - 36, 320, 320, 458, 320, 320, 321, 321, 457, 456, - 321, 455, 454, 453, 452, 451, 450, 449, 448, 447, - 446, 445, 444, 443, 442, 441, 440, 439, 438, 437, - - 436, 435, 434, 433, 432, 431, 430, 429, 428, 427, - 426, 425, 424, 423, 422, 421, 420, 419, 418, 417, - 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, - 406, 405, 404, 403, 402, 401, 400, 399, 398, 364, - 397, 396, 395, 394, 393, 392, 391, 390, 389, 388, - 387, 386, 385, 384, 383, 382, 381, 380, 379, 378, - 377, 376, 375, 374, 373, 372, 371, 370, 369, 368, - 367, 366, 365, 364, 364, 363, 362, 361, 360, 359, - 358, 357, 356, 355, 354, 353, 352, 351, 350, 349, - 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, - - 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, - 328, 327, 326, 325, 324, 323, 318, 317, 316, 315, - 314, 313, 312, 311, 310, 309, 308, 307, 306, 303, - 302, 301, 300, 299, 298, 297, 294, 293, 292, 291, - 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, - 280, 279, 278, 277, 276, 275, 272, 271, 268, 267, - 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, - 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, - 246, 245, 244, 240, 239, 238, 237, 236, 235, 234, - 233, 232, 231, 230, 224, 223, 222, 221, 220, 219, - - 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, - 208, 204, 203, 202, 201, 200, 199, 198, 197, 196, - 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, - 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, - 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, - 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, - 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, - 32, 145, 144, 143, 142, 138, 137, 136, 135, 134, - 133, 128, 125, 122, 121, 120, 119, 118, 117, 116, - 115, 110, 107, 106, 105, 102, 101, 100, 97, 94, - - 93, 92, 89, 88, 87, 86, 35, 32, 80, 69, - 58, 57, 35, 32, 469, 3, 469, 469, 469, 469, - 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 469 - } ; - -static yyconst short int yy_chk[552] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 5, 10, 5, 13, 11, - 14, 15, 13, 11, 27, 10, 11, 15, 27, 20, - 14, 10, 27, 10, 12, 45, 21, 20, 14, 45, - 18, 12, 18, 20, 51, 12, 21, 20, 12, 472, - 18, 18, 12, 12, 23, 24, 23, 24, 25, 23, - 25, 51, 30, 25, 30, 32, 41, 55, 32, 41, - 47, 47, 57, 24, 25, 58, 67, 55, 69, 71, - - 67, 72, 72, 58, 79, 465, 57, 84, 69, 71, - 84, 148, 166, 464, 148, 181, 211, 211, 181, 211, - 79, 166, 181, 241, 166, 166, 79, 166, 148, 214, - 250, 463, 214, 269, 269, 250, 269, 460, 270, 241, - 270, 270, 270, 270, 320, 459, 320, 320, 320, 320, - 322, 458, 322, 322, 322, 322, 470, 470, 455, 470, - 470, 471, 471, 454, 471, 471, 473, 453, 452, 473, - 473, 474, 474, 446, 474, 474, 475, 475, 445, 444, - 475, 441, 439, 438, 437, 436, 435, 434, 432, 431, - 429, 428, 427, 425, 424, 423, 422, 421, 420, 419, - - 418, 416, 415, 414, 413, 410, 409, 408, 407, 405, - 404, 403, 402, 401, 400, 399, 398, 397, 396, 395, - 394, 393, 392, 391, 390, 389, 388, 387, 386, 383, - 381, 380, 379, 375, 373, 372, 370, 368, 365, 364, - 363, 362, 361, 360, 358, 357, 356, 355, 354, 353, - 352, 350, 348, 347, 346, 345, 344, 343, 342, 340, - 339, 338, 337, 336, 335, 334, 332, 331, 330, 329, - 327, 325, 324, 321, 319, 318, 317, 316, 315, 314, - 313, 312, 311, 309, 308, 306, 305, 304, 303, 302, - 301, 300, 299, 298, 296, 295, 294, 293, 292, 291, - - 289, 287, 286, 285, 283, 282, 281, 280, 279, 278, - 276, 275, 274, 273, 272, 271, 267, 266, 265, 264, - 263, 262, 260, 258, 257, 255, 254, 252, 251, 249, - 248, 246, 245, 244, 243, 242, 239, 238, 237, 236, - 235, 232, 231, 229, 228, 227, 226, 225, 224, 223, - 222, 221, 220, 219, 217, 216, 213, 212, 210, 207, - 206, 205, 203, 202, 201, 200, 199, 198, 197, 196, - 195, 194, 193, 192, 191, 190, 189, 187, 186, 185, - 184, 183, 182, 180, 179, 178, 177, 176, 175, 174, - 171, 170, 169, 167, 165, 164, 163, 162, 161, 160, - - 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, - 149, 147, 146, 145, 144, 143, 142, 141, 140, 139, - 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, - 128, 126, 125, 124, 123, 122, 121, 120, 119, 118, - 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, - 107, 105, 104, 103, 102, 101, 100, 99, 98, 97, - 96, 95, 94, 93, 92, 91, 90, 89, 88, 86, - 85, 83, 82, 81, 80, 78, 77, 76, 75, 74, - 73, 70, 68, 66, 65, 64, 63, 62, 61, 60, - 59, 56, 54, 53, 52, 50, 49, 48, 46, 44, - - 43, 42, 40, 39, 38, 37, 34, 31, 26, 22, - 17, 16, 9, 7, 3, 469, 469, 469, 469, 469, - 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 469, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 469 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -char *yytext; -#line 1 "/5g/ian/binutils/release/copy/binutils/rclex.l" -#define INITIAL 0 -#line 2 "/5g/ian/binutils/release/copy/binutils/rclex.l" -/* Copyright 1997, 1998 Free Software Foundation, Inc. - Written by Ian Lance Taylor, Cygnus Support. - - This file is part of GNU Binutils. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -/* This is a lex input file which generates a lexer used by the - Windows rc file parser. It basically just recognized a bunch of - keywords. */ - -#include "bfd.h" -#include "bucomm.h" -#include "libiberty.h" -#include "windres.h" -#include "rcparse.h" - -#include -#include - -/* Whether we are in rcdata mode, in which we returns the lengths of - strings. */ - -static int rcdata_mode; - -/* List of allocated strings. */ - -struct alloc_string -{ - struct alloc_string *next; - char *s; -}; - -static struct alloc_string *strings; - -/* Local functions. */ - -static void cpp_line PARAMS ((const char *)); -static char *handle_quotes PARAMS ((const char *, unsigned long *)); -static char *get_string PARAMS ((int)); - -#line 691 "lex.yy.c" - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 58 "/5g/ian/binutils/release/copy/binutils/rclex.l" - - -#line 841 "lex.yy.c" - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 470 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 516 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 60 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return BEG; } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 61 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return BEG; } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 62 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return END; } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 63 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return END; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 64 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return ACCELERATORS; } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 65 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return VIRTKEY; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 66 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return ASCII; } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 67 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return NOINVERT; } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 68 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return SHIFT; } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 69 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return CONTROL; } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 70 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return ALT; } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 71 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return BITMAP; } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 72 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return CURSOR; } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 73 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return DIALOG; } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 74 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return DIALOGEX; } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 75 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return EXSTYLE; } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 76 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return CAPTION; } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 77 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return CLASS; } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 78 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return STYLE; } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 79 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return AUTO3STATE; } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 80 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return AUTOCHECKBOX; } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 81 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return AUTORADIOBUTTON; } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 82 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return CHECKBOX; } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 83 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return COMBOBOX; } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 84 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return CTEXT; } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 85 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return DEFPUSHBUTTON; } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 86 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return EDITTEXT; } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 87 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return GROUPBOX; } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 88 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return LISTBOX; } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 89 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return LTEXT; } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 90 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return PUSHBOX; } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 91 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return PUSHBUTTON; } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 92 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return RADIOBUTTON; } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 93 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return RTEXT; } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 94 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return SCROLLBAR; } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 95 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return STATE3; } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 96 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return USERBUTTON; } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 97 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return BEDIT; } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 98 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return HEDIT; } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 99 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return IEDIT; } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 100 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return FONT; } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 101 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return ICON; } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 102 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return LANGUAGE; } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 103 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return CHARACTERISTICS; } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 104 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return VERSIONK; } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 105 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return MENU; } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 106 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return MENUEX; } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 107 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return MENUITEM; } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 108 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return SEPARATOR; } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 109 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return POPUP; } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 110 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return CHECKED; } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 111 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return GRAYED; } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 112 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return HELP; } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 113 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return INACTIVE; } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 114 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return MENUBARBREAK; } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 115 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return MENUBREAK; } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 116 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return MESSAGETABLE; } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 117 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return RCDATA; } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 118 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return STRINGTABLE; } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 119 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return VERSIONINFO; } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 120 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return FILEVERSION; } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 121 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return PRODUCTVERSION; } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 122 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return FILEFLAGSMASK; } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 123 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return FILEFLAGS; } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 124 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return FILEOS; } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 125 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return FILETYPE; } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 126 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return FILESUBTYPE; } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 127 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return VALUE; } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 128 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return MOVEABLE; } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 129 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return FIXED; } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 130 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return PURE; } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 131 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return IMPURE; } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 132 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return PRELOAD; } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 133 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return LOADONCALL; } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 134 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return DISCARDABLE; } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 135 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return NOT; } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 137 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ - char *s, *send; - - /* This is a hack to let us parse version - information easily. */ - - s = strchr (yytext, '"'); - ++s; - send = strchr (s, '"'); - if (strncmp (s, "StringFileInfo", - sizeof "StringFileInfo" - 1) == 0 - && s + sizeof "StringFileInfo" - 1 == send) - return BLOCKSTRINGFILEINFO; - else if (strncmp (s, "VarFileInfo", - sizeof "VarFileInfo" - 1) == 0 - && s + sizeof "VarFileInfo" - 1 == send) - return BLOCKVARFILEINFO; - else - { - char *r; - - r = get_string (send - s + 1); - strncpy (r, s, send - s); - r[send - s] = '\0'; - yylval.s = r; - return BLOCK; - } - } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 166 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ - cpp_line (yytext); - } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 170 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ - yylval.i.val = strtoul (yytext, 0, 0); - yylval.i.dword = 1; - return NUMBER; - } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 176 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ - yylval.i.val = strtoul (yytext, 0, 0); - yylval.i.dword = 0; - return NUMBER; - } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 182 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ - char *s; - unsigned long length; - - s = handle_quotes (yytext, &length); - if (! rcdata_mode) - { - yylval.s = s; - return QUOTEDSTRING; - } - else - { - yylval.ss.length = length; - yylval.ss.s = s; - return SIZEDSTRING; - } - } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 200 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ - char *s; - - /* I rejected comma in a string in order to - handle VIRTKEY, CONTROL in an accelerator - resource. This means that an unquoted - file name can not contain a comma. I - don't know what rc permits. */ - - s = get_string (strlen (yytext) + 1); - strcpy (s, yytext); - yylval.s = s; - return STRING; - } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 215 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ ++rc_lineno; } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 216 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ /* ignore whitespace */ } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 217 "/5g/ian/binutils/release/copy/binutils/rclex.l" -{ return *yytext; } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 219 "/5g/ian/binutils/release/copy/binutils/rclex.l" -ECHO; - YY_BREAK -#line 1420 "lex.yy.c" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a singled characater, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 470 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 470 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 469); - - return yy_is_jam ? 0 : yy_current_state; - } - - -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } -#endif /* ifndef YY_NO_UNPUT */ - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - yytext_ptr = yy_c_buf_p; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - { - yy_c_buf_p = - yytext_ptr + YY_MORE_ADJ; - return EOF; - } - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - YY_FATAL_ERROR( - "unexpected last match in yyinput()" ); -#else - YY_FATAL_ERROR( - "unexpected last match in input()" ); -#endif - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - - return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO(( int )); -#endif -#endif - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *str ) -#else -YY_BUFFER_STATE yy_scan_string( str ) -yyconst char *str; -#endif - { - int len; - for ( len = 0; str[len]; ++len ) - ; - - return yy_scan_bytes( str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n - YY_MORE_ADJ; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 219 "/5g/ian/binutils/release/copy/binutils/rclex.l" - -#ifndef yywrap -/* This is needed for some versions of lex. */ -int yywrap () -{ - return 1; -} -#endif - -/* Handle a C preprocessor line. */ - -static void -cpp_line (s) - const char *s; -{ - int line; - char *send, *fn; - - ++s; - while (isspace (*s)) - ++s; - - line = strtol (s, &send, 0); - if (*send != '\0' && ! isspace (*send)) - return; - - /* Subtract 1 because we are about to count the newline. */ - rc_lineno = line - 1; - - s = send; - while (isspace (*s)) - ++s; - - if (*s != '"') - return; - - ++s; - send = strchr (s, '"'); - if (send == NULL) - return; - - fn = (char *) xmalloc (send - s + 1); - strncpy (fn, s, send - s); - fn[send - s] = '\0'; - - free (rc_filename); - rc_filename = fn; -} - -/* Handle a quoted string. The quotes are stripped. A pair of quotes - in a string are turned into a single quote. Adjacent strings are - merged separated by whitespace are merged, as in C. */ - -static char * -handle_quotes (input, len) - const char *input; - unsigned long *len; -{ - char *ret, *s; - const char *t; - int ch; - - ret = get_string (strlen (input) + 1); - - s = ret; - t = input; - if (*t == '"') - ++t; - while (*t != '\0') - { - if (*t == '\\') - { - ++t; - switch (*t) - { - case '\0': - rcparse_warning ("backslash at end of string"); - break; - - case '\"': - rcparse_warning ("use \"\" to put \" in a string"); - break; - - case 'a': - *s++ = ESCAPE_A; - ++t; - break; - - case 'b': - *s++ = ESCAPE_B; - ++t; - break; - - case 'f': - *s++ = ESCAPE_F; - ++t; - break; - - case 'n': - *s++ = ESCAPE_N; - ++t; - break; - - case 'r': - *s++ = ESCAPE_R; - ++t; - break; - - case 't': - *s++ = ESCAPE_T; - ++t; - break; - - case 'v': - *s++ = ESCAPE_V; - ++t; - break; - - case '\\': - *s++ = *t++; - break; - - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - ch = *t - '0'; - ++t; - if (*t >= '0' && *t <= '7') - { - ch = (ch << 3) | (*t - '0'); - ++t; - if (*t >= '0' && *t <= '7') - { - ch = (ch << 3) | (*t - '0'); - ++t; - } - } - *s++ = ch; - break; - - case 'x': - ++t; - ch = 0; - while (1) - { - if (*t >= '0' && *t <= '9') - ch = (ch << 4) | (*t - '0'); - else if (*t >= 'a' && *t <= 'f') - ch = (ch << 4) | (*t - 'a'); - else if (*t >= 'A' && *t <= 'F') - ch = (ch << 4) | (*t - 'A'); - else - break; - ++t; - } - *s++ = ch; - break; - - default: - rcparse_warning ("unrecognized escape sequence"); - *s++ = '\\'; - *s++ = *t++; - break; - } - } - else if (*t != '"') - *s++ = *t++; - else if (t[1] == '\0') - break; - else if (t[1] == '"') - { - *s++ = '"'; - t += 2; - } - else - { - ++t; - assert (isspace (*t)); - while (isspace (*t)) - ++t; - if (*t == '\0') - break; - assert (*t == '"'); - ++t; - } - } - - *s = '\0'; - - *len = s - ret; - - return ret; -} - -/* Allocate a string of a given length. */ - -static char * -get_string (len) - int len; -{ - struct alloc_string *as; - - as = (struct alloc_string *) xmalloc (sizeof *as); - as->s = xmalloc (len); - - as->next = strings; - strings = as->next; - - return as->s; -} - -/* Discard all the strings we have allocated. The parser calls this - when it no longer needs them. */ - -void -rcparse_discard_strings () -{ - struct alloc_string *as; - - as = strings; - while (as != NULL) - { - struct alloc_string *n; - - free (as->s); - n = as->next; - free (as); - as = n; - } - - strings = NULL; -} - -/* Enter rcdata mode. */ - -void -rcparse_rcdata () -{ - rcdata_mode = 1; -} - -/* Go back to normal mode from rcdata mode. */ - -void -rcparse_normal () -{ - rcdata_mode = 0; -} diff --git a/contrib/binutils/binutils/rcparse.c b/contrib/binutils/binutils/rcparse.c deleted file mode 100644 index 767dbcfe2308..000000000000 --- a/contrib/binutils/binutils/rcparse.c +++ /dev/null @@ -1,2993 +0,0 @@ - -/* A Bison parser, made from /5g/ian/binutils/release/copy/binutils/rcparse.y - by GNU Bison version 1.25 - */ - -#define YYBISON 1 /* Identify Bison output. */ - -#define BEG 258 -#define END 259 -#define ACCELERATORS 260 -#define VIRTKEY 261 -#define ASCII 262 -#define NOINVERT 263 -#define SHIFT 264 -#define CONTROL 265 -#define ALT 266 -#define BITMAP 267 -#define CURSOR 268 -#define DIALOG 269 -#define DIALOGEX 270 -#define EXSTYLE 271 -#define CAPTION 272 -#define CLASS 273 -#define STYLE 274 -#define AUTO3STATE 275 -#define AUTOCHECKBOX 276 -#define AUTORADIOBUTTON 277 -#define CHECKBOX 278 -#define COMBOBOX 279 -#define CTEXT 280 -#define DEFPUSHBUTTON 281 -#define EDITTEXT 282 -#define GROUPBOX 283 -#define LISTBOX 284 -#define LTEXT 285 -#define PUSHBOX 286 -#define PUSHBUTTON 287 -#define RADIOBUTTON 288 -#define RTEXT 289 -#define SCROLLBAR 290 -#define STATE3 291 -#define USERBUTTON 292 -#define BEDIT 293 -#define HEDIT 294 -#define IEDIT 295 -#define FONT 296 -#define ICON 297 -#define LANGUAGE 298 -#define CHARACTERISTICS 299 -#define VERSIONK 300 -#define MENU 301 -#define MENUEX 302 -#define MENUITEM 303 -#define SEPARATOR 304 -#define POPUP 305 -#define CHECKED 306 -#define GRAYED 307 -#define HELP 308 -#define INACTIVE 309 -#define MENUBARBREAK 310 -#define MENUBREAK 311 -#define MESSAGETABLE 312 -#define RCDATA 313 -#define STRINGTABLE 314 -#define VERSIONINFO 315 -#define FILEVERSION 316 -#define PRODUCTVERSION 317 -#define FILEFLAGSMASK 318 -#define FILEFLAGS 319 -#define FILEOS 320 -#define FILETYPE 321 -#define FILESUBTYPE 322 -#define BLOCKSTRINGFILEINFO 323 -#define BLOCKVARFILEINFO 324 -#define VALUE 325 -#define BLOCK 326 -#define MOVEABLE 327 -#define FIXED 328 -#define PURE 329 -#define IMPURE 330 -#define PRELOAD 331 -#define LOADONCALL 332 -#define DISCARDABLE 333 -#define NOT 334 -#define QUOTEDSTRING 335 -#define STRING 336 -#define NUMBER 337 -#define SIZEDSTRING 338 -#define NEG 339 - -#line 1 "/5g/ian/binutils/release/copy/binutils/rcparse.y" - /* rcparse.y -- parser for Windows rc files - Copyright 1997 Free Software Foundation, Inc. - Written by Ian Lance Taylor, Cygnus Support. - - This file is part of GNU Binutils. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -/* This is a parser for Windows rc files. It is based on the parser - by Gunther Ebert . */ - -#include "bfd.h" -#include "bucomm.h" -#include "libiberty.h" -#include "windres.h" - -#include - -/* The current language. */ - -static unsigned short language; - -/* The resource information during a sub statement. */ - -static struct res_res_info sub_res_info; - -/* Dialog information. This is built by the nonterminals styles and - controls. */ - -static struct dialog dialog; - -/* This is used when building a style. It is modified by the - nonterminal styleexpr. */ - -static unsigned long style; - -/* These are used when building a control. They are set before using - control_params. */ - -static unsigned long base_style; -static unsigned long default_style; -static unsigned long class; - - -#line 59 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -typedef union -{ - struct accelerator acc; - struct accelerator *pacc; - struct dialog_control *dialog_control; - struct menuitem *menuitem; - struct - { - struct rcdata_item *first; - struct rcdata_item *last; - } rcdata; - struct rcdata_item *rcdata_item; - struct stringtable_data *stringtable; - struct fixed_versioninfo *fixver; - struct ver_info *verinfo; - struct ver_stringinfo *verstring; - struct ver_varinfo *vervar; - struct res_id id; - struct res_res_info res_info; - struct - { - unsigned short on; - unsigned short off; - } memflags; - struct - { - unsigned long val; - /* Nonzero if this number was explicitly specified as long. */ - int dword; - } i; - unsigned long il; - unsigned short is; - const char *s; - struct - { - unsigned long length; - const char *s; - } ss; -} YYSTYPE; -#include - -#ifndef __cplusplus -#ifndef __STDC__ -#define const -#endif -#endif - - - -#define YYFINAL 462 -#define YYFLAG -32768 -#define YYNTBASE 98 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 339 ? yytranslate[x] : 188) - -static const char yytranslate[] = { 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 91, 86, 2, 96, - 97, 89, 87, 94, 88, 2, 90, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 95, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 85, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 84, 2, 92, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 93 -}; - -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 1, 5, 9, 13, 17, 21, 25, 29, 33, - 37, 41, 45, 49, 53, 57, 58, 65, 66, 69, - 72, 77, 79, 81, 83, 87, 90, 92, 94, 96, - 98, 100, 102, 107, 112, 113, 127, 128, 142, 143, - 158, 159, 163, 164, 168, 172, 173, 178, 182, 188, - 196, 200, 204, 209, 213, 214, 217, 218, 222, 223, - 227, 228, 232, 233, 237, 238, 242, 243, 247, 259, - 272, 273, 277, 278, 282, 283, 287, 288, 292, 293, - 297, 304, 315, 327, 328, 332, 333, 337, 338, 342, - 343, 347, 348, 352, 353, 357, 358, 362, 363, 367, - 368, 372, 373, 390, 398, 408, 419, 420, 423, 424, - 428, 429, 433, 434, 438, 439, 443, 448, 453, 457, - 464, 465, 468, 473, 476, 483, 484, 488, 491, 493, - 495, 497, 499, 501, 503, 510, 511, 514, 517, 521, - 527, 533, 540, 548, 558, 563, 570, 571, 574, 575, - 577, 579, 581, 585, 589, 590, 597, 598, 602, 607, - 614, 619, 626, 627, 634, 641, 645, 649, 653, 657, - 661, 662, 671, 679, 680, 686, 687, 691, 693, 695, - 696, 699, 703, 708, 712, 713, 716, 717, 720, 722, - 724, 726, 728, 730, 732, 734, 736, 738, 740, 743, - 747, 752, 754, 758, 759, 761, 764, 766, 768, 772, - 775, 778, 782, 786, 790, 794, 798, 802, 806, 810, - 813, 815, 817, 821, 824, 828, 832, 836, 840, 844, - 848, 852 -}; - -static const short yyrhs[] = { -1, - 98, 99, 100, 0, 98, 99, 106, 0, 98, 99, - 107, 0, 98, 99, 108, 0, 98, 99, 147, 0, - 98, 99, 148, 0, 98, 99, 149, 0, 98, 99, - 150, 0, 98, 99, 155, 0, 98, 99, 158, 0, - 98, 99, 159, 0, 98, 99, 164, 0, 98, 99, - 167, 0, 98, 99, 168, 0, 0, 173, 5, 174, - 3, 101, 4, 0, 0, 101, 102, 0, 103, 185, - 0, 103, 185, 94, 104, 0, 80, 0, 186, 0, - 105, 0, 104, 94, 105, 0, 104, 105, 0, 6, - 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, - 0, 173, 12, 176, 178, 0, 173, 13, 175, 178, - 0, 0, 173, 14, 176, 112, 186, 182, 182, 182, - 109, 113, 3, 115, 4, 0, 0, 173, 15, 176, - 112, 186, 182, 182, 182, 110, 113, 3, 115, 4, - 0, 0, 173, 15, 176, 112, 186, 182, 182, 182, - 182, 111, 113, 3, 115, 4, 0, 0, 16, 95, - 183, 0, 0, 113, 17, 80, 0, 113, 18, 173, - 0, 0, 113, 19, 114, 179, 0, 113, 16, 183, - 0, 113, 41, 183, 94, 80, 0, 113, 41, 183, - 94, 80, 182, 182, 0, 113, 46, 173, 0, 113, - 44, 183, 0, 113, 43, 183, 182, 0, 113, 45, - 183, 0, 0, 115, 116, 0, 0, 20, 117, 138, - 0, 0, 21, 118, 138, 0, 0, 22, 119, 138, - 0, 0, 38, 120, 138, 0, 0, 23, 121, 138, - 0, 0, 24, 122, 138, 0, 10, 139, 183, 182, - 141, 182, 182, 182, 182, 181, 140, 0, 10, 139, - 183, 182, 141, 182, 182, 182, 182, 182, 182, 140, - 0, 0, 25, 123, 138, 0, 0, 26, 124, 138, - 0, 0, 27, 125, 138, 0, 0, 28, 126, 138, - 0, 0, 39, 127, 138, 0, 42, 139, 183, 182, - 182, 140, 0, 42, 139, 183, 182, 182, 182, 182, - 143, 181, 140, 0, 42, 139, 183, 182, 182, 182, - 182, 143, 182, 182, 140, 0, 0, 40, 128, 138, - 0, 0, 29, 129, 138, 0, 0, 30, 130, 138, - 0, 0, 31, 131, 138, 0, 0, 32, 132, 138, - 0, 0, 33, 133, 138, 0, 0, 34, 134, 138, - 0, 0, 35, 135, 138, 0, 0, 36, 136, 138, - 0, 0, 37, 80, 94, 183, 94, 183, 94, 183, - 94, 183, 94, 183, 94, 137, 179, 181, 0, 139, - 183, 182, 182, 182, 182, 140, 0, 139, 183, 182, - 182, 182, 182, 145, 181, 140, 0, 139, 183, 182, - 182, 182, 182, 145, 182, 182, 140, 0, 0, 80, - 94, 0, 0, 3, 160, 4, 0, 0, 94, 142, - 179, 0, 0, 94, 144, 179, 0, 0, 94, 146, - 179, 0, 173, 41, 175, 178, 0, 173, 42, 175, - 178, 0, 43, 183, 182, 0, 173, 46, 174, 3, - 151, 4, 0, 0, 151, 152, 0, 48, 80, 182, - 153, 0, 48, 49, 0, 50, 80, 153, 3, 151, - 4, 0, 0, 153, 94, 154, 0, 153, 154, 0, - 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, - 56, 0, 173, 47, 174, 3, 156, 4, 0, 0, - 156, 157, 0, 48, 80, 0, 48, 80, 182, 0, - 48, 80, 182, 182, 181, 0, 50, 80, 3, 156, - 4, 0, 50, 80, 182, 3, 156, 4, 0, 50, - 80, 182, 182, 3, 156, 4, 0, 50, 80, 182, - 182, 182, 181, 3, 156, 4, 0, 173, 57, 176, - 178, 0, 173, 58, 174, 3, 160, 4, 0, 0, - 161, 162, 0, 0, 163, 0, 83, 0, 184, 0, - 163, 94, 83, 0, 163, 94, 184, 0, 0, 59, - 174, 3, 165, 166, 4, 0, 0, 166, 183, 80, - 0, 166, 183, 94, 80, 0, 173, 173, 174, 3, - 160, 4, 0, 173, 173, 174, 178, 0, 173, 60, - 169, 3, 170, 4, 0, 0, 169, 61, 183, 182, - 182, 182, 0, 169, 62, 183, 182, 182, 182, 0, - 169, 63, 183, 0, 169, 64, 183, 0, 169, 65, - 183, 0, 169, 66, 183, 0, 169, 67, 183, 0, - 0, 170, 68, 3, 71, 3, 171, 4, 4, 0, - 170, 69, 3, 70, 80, 172, 4, 0, 0, 171, - 70, 80, 94, 80, 0, 0, 172, 182, 182, 0, - 186, 0, 81, 0, 0, 174, 177, 0, 174, 44, - 183, 0, 174, 43, 183, 182, 0, 174, 45, 183, - 0, 0, 175, 177, 0, 0, 175, 177, 0, 72, - 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, - 0, 78, 0, 80, 0, 81, 0, 180, 0, 79, - 180, 0, 179, 84, 180, 0, 179, 84, 79, 180, - 0, 82, 0, 96, 183, 97, 0, 0, 182, 0, - 94, 183, 0, 184, 0, 82, 0, 96, 184, 97, - 0, 92, 184, 0, 88, 184, 0, 184, 89, 184, - 0, 184, 90, 184, 0, 184, 91, 184, 0, 184, - 87, 184, 0, 184, 88, 184, 0, 184, 86, 184, - 0, 184, 85, 184, 0, 184, 84, 184, 0, 94, - 186, 0, 187, 0, 82, 0, 96, 184, 97, 0, - 92, 184, 0, 187, 89, 184, 0, 187, 90, 184, - 0, 187, 91, 184, 0, 187, 87, 184, 0, 187, - 88, 184, 0, 187, 86, 184, 0, 187, 85, 184, - 0, 187, 84, 184, 0 -}; - -#endif - -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 154, 156, 157, 158, 159, 160, 161, 162, 163, 164, - 165, 166, 167, 168, 169, 172, 181, 188, 193, 213, - 219, 230, 252, 261, 266, 271, 277, 282, 287, 291, - 295, 299, 307, 316, 325, 343, 347, 366, 370, 390, - 396, 401, 407, 409, 413, 417, 420, 423, 427, 433, - 446, 450, 454, 458, 464, 466, 476, 484, 487, 494, - 497, 504, 507, 514, 520, 527, 530, 537, 540, 551, - 560, 567, 570, 577, 580, 587, 590, 597, 600, 607, - 613, 624, 636, 646, 653, 659, 666, 669, 676, 679, - 686, 689, 696, 699, 706, 709, 716, 719, 726, 729, - 736, 739, 742, 756, 769, 780, 791, 796, 802, 807, - 815, 819, 821, 825, 827, 831, 835, 844, 854, 863, - 870, 875, 891, 896, 900, 906, 911, 915, 921, 926, - 930, 934, 938, 942, 950, 957, 962, 978, 983, 987, - 991, 995, 999, 1003, 1012, 1021, 1031, 1036, 1042, 1048, - 1054, 1063, 1071, 1080, 1093, 1096, 1099, 1101, 1105, 1114, - 1119, 1127, 1134, 1141, 1147, 1153, 1158, 1163, 1168, 1173, - 1186, 1191, 1195, 1201, 1206, 1212, 1217, 1225, 1231, 1248, - 1256, 1262, 1267, 1272, 1281, 1288, 1298, 1305, 1316, 1322, - 1327, 1332, 1337, 1342, 1347, 1356, 1361, 1377, 1382, 1386, - 1390, 1396, 1401, 1409, 1414, 1422, 1431, 1440, 1445, 1449, - 1454, 1459, 1464, 1469, 1474, 1479, 1484, 1489, 1494, 1504, - 1513, 1524, 1529, 1533, 1538, 1543, 1548, 1553, 1558, 1563, - 1568, 1573 -}; -#endif - - -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) - -static const char * const yytname[] = { "$","error","$undefined.","BEG","END", -"ACCELERATORS","VIRTKEY","ASCII","NOINVERT","SHIFT","CONTROL","ALT","BITMAP", -"CURSOR","DIALOG","DIALOGEX","EXSTYLE","CAPTION","CLASS","STYLE","AUTO3STATE", -"AUTOCHECKBOX","AUTORADIOBUTTON","CHECKBOX","COMBOBOX","CTEXT","DEFPUSHBUTTON", -"EDITTEXT","GROUPBOX","LISTBOX","LTEXT","PUSHBOX","PUSHBUTTON","RADIOBUTTON", -"RTEXT","SCROLLBAR","STATE3","USERBUTTON","BEDIT","HEDIT","IEDIT","FONT","ICON", -"LANGUAGE","CHARACTERISTICS","VERSIONK","MENU","MENUEX","MENUITEM","SEPARATOR", -"POPUP","CHECKED","GRAYED","HELP","INACTIVE","MENUBARBREAK","MENUBREAK","MESSAGETABLE", -"RCDATA","STRINGTABLE","VERSIONINFO","FILEVERSION","PRODUCTVERSION","FILEFLAGSMASK", -"FILEFLAGS","FILEOS","FILETYPE","FILESUBTYPE","BLOCKSTRINGFILEINFO","BLOCKVARFILEINFO", -"VALUE","BLOCK","MOVEABLE","FIXED","PURE","IMPURE","PRELOAD","LOADONCALL","DISCARDABLE", -"NOT","QUOTEDSTRING","STRING","NUMBER","SIZEDSTRING","'|'","'^'","'&'","'+'", -"'-'","'*'","'/'","'%'","'~'","NEG","','","'='","'('","')'","input","newcmd", -"accelerator","acc_entries","acc_entry","acc_event","acc_options","acc_option", -"bitmap","cursor","dialog","@1","@2","@3","exstyle","styles","@4","controls", -"control","@5","@6","@7","@8","@9","@10","@11","@12","@13","@14","@15","@16", -"@17","@18","@19","@20","@21","@22","@23","@24","@25","control_params","optstringc", -"opt_control_data","control_styleexpr","@26","icon_styleexpr","@27","control_params_styleexpr", -"@28","font","icon","language","menu","menuitems","menuitem","menuitem_flags", -"menuitem_flag","menuex","menuexitems","menuexitem","messagetable","rcdata", -"optrcdata_data","@29","optrcdata_data_int","rcdata_data","stringtable","@30", -"string_data","user","versioninfo","fixedverinfo","verblocks","vervals","vertrans", -"id","suboptions","memflags_move_discard","memflags_move","memflag","file_name", -"styleexpr","parennumber","optcnumexpr","cnumexpr","numexpr","sizednumexpr", -"cposnumexpr","posnumexpr","sizedposnumexpr", NULL -}; -#endif - -static const short yyr1[] = { 0, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 99, 100, 101, 101, 102, - 102, 103, 103, 104, 104, 104, 105, 105, 105, 105, - 105, 105, 106, 107, 109, 108, 110, 108, 111, 108, - 112, 112, 113, 113, 113, 114, 113, 113, 113, 113, - 113, 113, 113, 113, 115, 115, 117, 116, 118, 116, - 119, 116, 120, 116, 121, 116, 122, 116, 116, 116, - 123, 116, 124, 116, 125, 116, 126, 116, 127, 116, - 116, 116, 116, 128, 116, 129, 116, 130, 116, 131, - 116, 132, 116, 133, 116, 134, 116, 135, 116, 136, - 116, 137, 116, 138, 138, 138, 139, 139, 140, 140, - 142, 141, 144, 143, 146, 145, 147, 148, 149, 150, - 151, 151, 152, 152, 152, 153, 153, 153, 154, 154, - 154, 154, 154, 154, 155, 156, 156, 157, 157, 157, - 157, 157, 157, 157, 158, 159, 161, 160, 162, 162, - 163, 163, 163, 163, 165, 164, 166, 166, 166, 167, - 167, 168, 169, 169, 169, 169, 169, 169, 169, 169, - 170, 170, 170, 171, 171, 172, 172, 173, 173, 174, - 174, 174, 174, 174, 175, 175, 176, 176, 177, 177, - 177, 177, 177, 177, 177, 178, 178, 179, 179, 179, - 179, 180, 180, 181, 181, 182, 183, 184, 184, 184, - 184, 184, 184, 184, 184, 184, 184, 184, 184, 185, - 186, 187, 187, 187, 187, 187, 187, 187, 187, 187, - 187, 187 -}; - -static const short yyr2[] = { 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 0, 6, 0, 2, 2, - 4, 1, 1, 1, 3, 2, 1, 1, 1, 1, - 1, 1, 4, 4, 0, 13, 0, 13, 0, 14, - 0, 3, 0, 3, 3, 0, 4, 3, 5, 7, - 3, 3, 4, 3, 0, 2, 0, 3, 0, 3, - 0, 3, 0, 3, 0, 3, 0, 3, 11, 12, - 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, - 6, 10, 11, 0, 3, 0, 3, 0, 3, 0, - 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, - 3, 0, 16, 7, 9, 10, 0, 2, 0, 3, - 0, 3, 0, 3, 0, 3, 4, 4, 3, 6, - 0, 2, 4, 2, 6, 0, 3, 2, 1, 1, - 1, 1, 1, 1, 6, 0, 2, 2, 3, 5, - 5, 6, 7, 9, 4, 6, 0, 2, 0, 1, - 1, 1, 3, 3, 0, 6, 0, 3, 4, 6, - 4, 6, 0, 6, 6, 3, 3, 3, 3, 3, - 0, 8, 7, 0, 5, 0, 3, 1, 1, 0, - 2, 3, 4, 3, 0, 2, 0, 2, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 4, 1, 3, 0, 1, 2, 1, 1, 3, 2, - 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, - 1, 1, 3, 2, 3, 3, 3, 3, 3, 3, - 3, 3 -}; - -static const short yydefact[] = { 1, - 16, 0, 0, 180, 179, 222, 0, 0, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 0, 178, 221, 208, 0, 0, 0, 0, - 207, 0, 224, 0, 180, 185, 185, 185, 185, 185, - 185, 180, 180, 185, 180, 163, 180, 0, 0, 0, - 0, 0, 0, 0, 0, 211, 210, 0, 0, 119, - 0, 0, 0, 0, 0, 0, 0, 0, 155, 0, - 0, 0, 189, 190, 191, 192, 193, 194, 195, 181, - 223, 0, 0, 0, 0, 41, 41, 0, 0, 0, - 0, 0, 0, 0, 0, 232, 231, 230, 228, 229, - 225, 226, 227, 209, 206, 219, 218, 217, 215, 216, - 212, 213, 214, 157, 0, 182, 184, 18, 186, 196, - 197, 33, 186, 34, 0, 0, 0, 117, 118, 121, - 136, 145, 147, 171, 0, 0, 0, 0, 0, 0, - 0, 147, 161, 0, 183, 0, 0, 0, 0, 0, - 0, 0, 149, 0, 0, 0, 166, 167, 168, 169, - 170, 0, 156, 0, 17, 22, 19, 0, 23, 42, - 0, 0, 120, 0, 0, 122, 135, 0, 0, 137, - 146, 151, 148, 150, 152, 162, 0, 0, 0, 0, - 160, 158, 0, 0, 20, 0, 0, 124, 0, 126, - 138, 0, 0, 0, 0, 0, 0, 159, 220, 0, - 35, 37, 126, 0, 139, 136, 0, 153, 154, 0, - 0, 164, 165, 27, 28, 29, 30, 31, 32, 21, - 24, 43, 43, 39, 123, 121, 129, 130, 131, 132, - 133, 134, 0, 128, 204, 0, 136, 0, 174, 176, - 0, 26, 0, 0, 43, 0, 127, 140, 205, 141, - 0, 136, 204, 0, 0, 25, 55, 0, 0, 0, - 46, 0, 0, 0, 0, 0, 55, 0, 125, 142, - 0, 0, 0, 0, 173, 0, 0, 48, 44, 45, - 0, 0, 0, 52, 54, 51, 0, 55, 143, 136, - 172, 0, 177, 36, 107, 57, 59, 61, 65, 67, - 71, 73, 75, 77, 86, 88, 90, 92, 94, 96, - 98, 100, 0, 63, 79, 84, 107, 56, 0, 202, - 0, 47, 198, 0, 53, 38, 0, 0, 0, 0, - 0, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 0, 107, - 107, 107, 0, 199, 0, 0, 49, 40, 144, 175, - 108, 0, 58, 0, 60, 62, 66, 68, 72, 74, - 76, 78, 87, 89, 91, 93, 95, 97, 99, 101, - 0, 64, 80, 85, 0, 203, 0, 200, 0, 0, - 0, 0, 0, 201, 50, 111, 0, 0, 0, 109, - 0, 0, 0, 0, 147, 81, 0, 112, 0, 0, - 0, 0, 0, 0, 109, 0, 110, 113, 204, 204, - 115, 104, 204, 0, 0, 109, 205, 109, 205, 0, - 109, 205, 0, 114, 82, 109, 69, 109, 116, 105, - 109, 0, 83, 70, 106, 0, 102, 0, 204, 103, - 0, 0 -}; - -static const short yydefgoto[] = { 1, - 2, 9, 146, 167, 168, 230, 231, 10, 11, 12, - 232, 233, 255, 126, 253, 291, 287, 328, 342, 343, - 344, 360, 345, 346, 347, 348, 349, 350, 361, 362, - 351, 352, 353, 354, 355, 356, 357, 358, 458, 373, - 374, 416, 407, 411, 429, 435, 433, 440, 13, 14, - 15, 16, 150, 176, 214, 244, 17, 151, 180, 18, - 19, 152, 153, 183, 184, 20, 114, 144, 21, 22, - 94, 154, 264, 265, 23, 32, 83, 84, 80, 122, - 332, 333, 258, 259, 30, 31, 195, 24, 25 -}; - -static const short yypact[] = {-32768, - 41, 97, 496,-32768,-32768,-32768, 496, 496,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768, 149,-32768, 419,-32768, 496, 496, 496, -49, - 456, 214,-32768, 533,-32768, -75,-32768, -12, -12,-32768, --32768,-32768,-32768, -75,-32768,-32768,-32768, 496, 496, 496, - 496, 496, 496, 496, 496,-32768,-32768, 547, 496,-32768, - 496, 496, 496, 496, 496, 496, 496, 496,-32768, 496, - 496, 496,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768, 234, 583, 2, 573, 95, 95, 573, 573, 257, - 277, 2, 341, 295, 195, 577, 366, 538, 163, 163, --32768,-32768,-32768,-32768,-32768, 577, 366, 538, 163, 163, --32768,-32768,-32768,-32768, -49,-32768,-32768,-32768, 53,-32768, --32768,-32768,-32768,-32768, 33, 123, 123,-32768,-32768,-32768, --32768,-32768,-32768,-32768, 496, 496, 496, 496, 496, 496, - 496,-32768,-32768, 14,-32768, 17, 496, -49, -49, 38, - 100, 127, 231, 55, -49, -49,-32768,-32768,-32768,-32768, --32768, 132,-32768, -77,-32768,-32768,-32768, 45,-32768,-32768, - -49, -49,-32768, 66, 63,-32768,-32768, 64, 67,-32768, --32768,-32768,-32768, 76, 456,-32768, 171, 180, -49, -49, --32768,-32768, 106, 123, 98, -49, -49,-32768, -49,-32768, - -49, 6, 309, 128, 131, -49, -49,-32768,-32768, 663, --32768, -49,-32768, 20, -49,-32768, 9,-32768, 456, 205, - 136,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 26, --32768,-32768,-32768,-32768, 376,-32768,-32768,-32768,-32768,-32768, --32768,-32768, 624,-32768, -49, 125,-32768, 13,-32768,-32768, - 663,-32768, 405, 417,-32768, 154,-32768,-32768,-32768,-32768, - 164,-32768, -49, 7, 11,-32768,-32768, 496, 144, 169, --32768, 496, 496, 496, 496, 169,-32768, 423,-32768,-32768, - 184, 230, 232, 162,-32768, -49, 455,-32768,-32768,-32768, - -39, 153, -49,-32768,-32768,-32768, 492,-32768,-32768,-32768, --32768, 168,-32768,-32768, 186,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768, 201,-32768,-32768,-32768, 186,-32768, 34,-32768, - 496, 159,-32768, 202,-32768,-32768, 529, 196, 203, 170, - 496, 186, 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, 190, 186, - 186, 186, 496,-32768, 151, 115, -49,-32768,-32768,-32768, --32768, -49,-32768, 496,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - 496,-32768,-32768,-32768, -49,-32768, 34,-32768, -49, 200, - -49, 209, -49,-32768,-32768,-32768, -49, -49, 496, 27, - -39, -49, -49, 210,-32768,-32768, -49, 159, -49, -49, - 496, 301, 221, -49, 28, 222,-32768,-32768, -49, -49, --32768,-32768, -49, 496, -39, 296, -49, 296, -49, -39, - 296, -49, 224, 159,-32768, 296,-32768, 296, 159,-32768, - 296, 496,-32768,-32768,-32768, 244,-32768, -39, -38,-32768, - 324,-32768 -}; - -static const short yypgoto[] = {-32768, --32768,-32768,-32768,-32768,-32768,-32768, -172,-32768,-32768,-32768, --32768,-32768,-32768, 238, -211,-32768, -160,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 254, - -267, 145,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768, 90,-32768, 134, 105,-32768, -135,-32768,-32768, --32768, -141,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768, -21, 178, 256, 113, 491, 251, - -303, -319, -249, -30, -46, 0,-32768, -107,-32768 -}; - - -#define YYLAST 680 - - -static const short yytable[] = { 60, - 162, 47, 192, -187, -187, -187, 33, 34, 216, 364, - 283, 247, 105, 282, 285, 262, 193, 163, 148, 149, - 165, 254, 236, 115, 116, 117, 56, 57, 58, 415, - 415, 224, 225, 226, 227, 228, 229, 341, 169, 329, - 461, 173, 330, 278, 59, 366, 398, 96, 97, 98, - 99, 100, 101, 102, 103, 59, 331, 252, 186, 363, - 106, 107, 108, 109, 110, 111, 112, 113, -188, -187, - 237, 238, 239, 240, 241, 242, 284, 404, 266, -187, - 246, 120, 121, -187, 145, 174, 209, 175, 155, 156, - 157, 158, 159, 160, 161, 26, 166, 164, 6, 59, - 170, 27, 59, 177, 59, 28, 59, 418, 7, 29, - 125, 261, 8, 243, 198, 330, 297, 171, 172, 251, - 59, 431, 187, 188, 189, 190, 281, 147, 260, 331, - 181, 444, -188, -188, -188, 191, 449, 337, 194, 3, - 196, 197, 200, 201, -188, 199, 202, 178, -188, 179, - 86, 87, 185, 35, 459, 4, 92, 279, 206, 207, - 36, 37, 38, 39, 338, 211, 212, 280, 213, 203, - 215, 217, 178, 204, 179, 222, 223, 5, 6, 436, - 438, 234, 205, 441, 245, 208, 248, 299, 7, 40, - 41, 210, 8, 397, 42, 43, 330, 142, 220, 369, - 221, 174, 219, 175, 6, 44, 45, 249, 46, 460, - 331, 178, 82, 179, 7, 250, 69, 263, 8, 90, - 91, 288, 93, 289, 95, 292, 293, 294, 295, 5, - 6, 178, 300, 179, 286, 301, 118, 70, 71, 72, - 7, 302, 366, 178, 8, 179, 334, 396, 290, 5, - 6, 66, 67, 68, 296, 303, 70, 71, 72, 130, - 7, 339, 335, 371, 8, 340, 73, 74, 75, 76, - 77, 78, 79, 422, 120, 121, 70, 71, 72, 131, - 359, 367, 370, 391, 365, 73, 74, 75, 76, 77, - 78, 79, 85, 406, 372, 88, 89, 134, 415, 70, - 71, 72, 409, 421, 427, 73, 74, 75, 76, 77, - 78, 79, 26, 182, 428, 434, 395, 452, 27, 70, - 71, 72, 28, 462, 127, 256, 29, 401, 73, 74, - 75, 76, 77, 78, 79, 124, 399, 457, 128, 129, - 0, 400, 132, 133, 402, 143, 235, 257, 73, 74, - 75, 76, 77, 78, 79, 135, 136, 137, 138, 139, - 140, 141, 414, 0, 403, 0, 0, 0, 405, 0, - 408, 0, 410, 0, 426, 0, 412, 413, 0, 417, - 0, 419, 420, 70, 71, 72, 423, 443, 424, 425, - 26, 218, 0, 430, 0, 0, 27, 0, 437, 439, - 28, 0, 442, 0, 29, 456, 446, 267, 448, 0, - 0, 451, 73, 74, 75, 76, 77, 78, 79, 277, - 268, 269, 270, 271, 0, 298, 237, 238, 239, 240, - 241, 242, 268, 269, 270, 271, 0, 0, 268, 269, - 270, 271, 0, 0, 0, 272, 0, 273, 274, 275, - 276, 63, 64, 65, 66, 67, 68, 272, 304, 273, - 274, 275, 276, 272, 305, 273, 274, 275, 276, 243, - 0, 0, 0, 0, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, - 322, 323, 324, 325, 326, 336, 327, 0, 0, 0, - 0, 305, 48, 49, 50, 51, 52, 53, 54, 55, - 0, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 368, 327, 0, 0, 0, 0, 305, 61, - 62, 63, 64, 65, 66, 67, 68, 0, 306, 307, - 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, - 318, 319, 320, 321, 322, 323, 324, 325, 326, 432, - 327, 0, 0, 119, 0, 123, 0, 26, 123, 123, - 445, 0, 447, 27, 0, 450, 0, 28, 0, 0, - 453, 29, 454, 0, 0, 455, 375, 376, 377, 378, - 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, - 389, 390, 0, 392, 393, 394, 61, 62, 63, 64, - 65, 66, 67, 68, 64, 65, 66, 67, 68, 81, - 61, 62, 63, 64, 65, 66, 67, 68, 0, 0, - 0, 0, 0, 104, 73, 74, 75, 76, 77, 78, - 79, 0, 120, 121, 73, 74, 75, 76, 77, 78, - 79, 62, 63, 64, 65, 66, 67, 68, 224, 225, - 226, 227, 228, 229, 237, 238, 239, 240, 241, 242 -}; - -static const short yycheck[] = { 30, - 142, 23, 80, 16, 80, 81, 7, 8, 3, 329, - 4, 3, 59, 263, 4, 3, 94, 4, 126, 127, - 4, 233, 3, 70, 71, 72, 27, 28, 29, 3, - 3, 6, 7, 8, 9, 10, 11, 305, 146, 79, - 0, 4, 82, 255, 94, 84, 366, 48, 49, 50, - 51, 52, 53, 54, 55, 94, 96, 230, 4, 327, - 61, 62, 63, 64, 65, 66, 67, 68, 16, 82, - 51, 52, 53, 54, 55, 56, 70, 397, 251, 92, - 216, 80, 81, 96, 115, 48, 194, 50, 135, 136, - 137, 138, 139, 140, 141, 82, 80, 144, 82, 94, - 147, 88, 94, 4, 94, 92, 94, 411, 92, 96, - 16, 247, 96, 94, 49, 82, 277, 148, 149, 94, - 94, 94, 68, 69, 155, 156, 262, 95, 4, 96, - 4, 435, 80, 81, 82, 4, 440, 298, 94, 43, - 171, 172, 80, 80, 92, 80, 80, 48, 96, 50, - 38, 39, 153, 5, 458, 59, 44, 4, 189, 190, - 12, 13, 14, 15, 300, 196, 197, 4, 199, 94, - 201, 202, 48, 3, 50, 206, 207, 81, 82, 429, - 430, 212, 3, 433, 215, 80, 217, 4, 92, 41, - 42, 94, 96, 79, 46, 47, 82, 3, 71, 4, - 70, 48, 203, 50, 82, 57, 58, 3, 60, 459, - 96, 48, 35, 50, 92, 80, 3, 248, 96, 42, - 43, 268, 45, 80, 47, 272, 273, 274, 275, 81, - 82, 48, 3, 50, 265, 4, 3, 43, 44, 45, - 92, 80, 84, 48, 96, 50, 94, 97, 270, 81, - 82, 89, 90, 91, 276, 286, 43, 44, 45, 3, - 92, 94, 293, 94, 96, 80, 72, 73, 74, 75, - 76, 77, 78, 415, 80, 81, 43, 44, 45, 3, - 80, 80, 80, 94, 331, 72, 73, 74, 75, 76, - 77, 78, 37, 94, 341, 40, 41, 3, 3, 43, - 44, 45, 94, 94, 4, 72, 73, 74, 75, 76, - 77, 78, 82, 83, 94, 94, 363, 94, 88, 43, - 44, 45, 92, 0, 87, 236, 96, 374, 72, 73, - 74, 75, 76, 77, 78, 85, 367, 94, 88, 89, - -1, 372, 92, 3, 391, 95, 213, 243, 72, 73, - 74, 75, 76, 77, 78, 61, 62, 63, 64, 65, - 66, 67, 409, -1, 395, -1, -1, -1, 399, -1, - 401, -1, 403, -1, 421, -1, 407, 408, -1, 410, - -1, 412, 413, 43, 44, 45, 417, 434, 419, 420, - 82, 83, -1, 424, -1, -1, 88, -1, 429, 430, - 92, -1, 433, -1, 96, 452, 437, 3, 439, -1, - -1, 442, 72, 73, 74, 75, 76, 77, 78, 3, - 16, 17, 18, 19, -1, 3, 51, 52, 53, 54, - 55, 56, 16, 17, 18, 19, -1, -1, 16, 17, - 18, 19, -1, -1, -1, 41, -1, 43, 44, 45, - 46, 86, 87, 88, 89, 90, 91, 41, 4, 43, - 44, 45, 46, 41, 10, 43, 44, 45, 46, 94, - -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 4, 42, -1, -1, -1, - -1, 10, 84, 85, 86, 87, 88, 89, 90, 91, - -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 4, 42, -1, -1, -1, -1, 10, 84, - 85, 86, 87, 88, 89, 90, 91, -1, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 425, - 42, -1, -1, 83, -1, 85, -1, 82, 88, 89, - 436, -1, 438, 88, -1, 441, -1, 92, -1, -1, - 446, 96, 448, -1, -1, 451, 343, 344, 345, 346, - 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, - 357, 358, -1, 360, 361, 362, 84, 85, 86, 87, - 88, 89, 90, 91, 87, 88, 89, 90, 91, 97, - 84, 85, 86, 87, 88, 89, 90, 91, -1, -1, - -1, -1, -1, 97, 72, 73, 74, 75, 76, 77, - 78, -1, 80, 81, 72, 73, 74, 75, 76, 77, - 78, 85, 86, 87, 88, 89, 90, 91, 6, 7, - 8, 9, 10, 11, 51, 52, 53, 54, 55, 56 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/cygnus/progressive-97r2/share/bison.simple" - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -#ifndef alloca -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) -#include -#else /* not sparc */ -#if defined (MSDOS) && !defined (__TURBOC__) -#include -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -#include - #pragma alloca -#else /* not MSDOS, __TURBOC__, or _AIX */ -#ifdef __hpux -#ifdef __cplusplus -extern "C" { -void *alloca (unsigned int); -}; -#else /* not __cplusplus */ -void *alloca (); -#endif /* not __cplusplus */ -#endif /* __hpux */ -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc. */ -#endif /* not GNU C. */ -#endif /* alloca not defined. */ - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT return(0) -#define YYABORT return(1) -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) -#endif -#else /* not YYLSP_NEEDED */ -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -int yyparse (void); -#endif - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - int count; -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (char *to, char *from, int count) -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif -#endif - -#line 196 "/usr/cygnus/progressive-97r2/share/bison.simple" - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - int yystacksize = YYINITDEPTH; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); - yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - goto yybackup; - yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - - switch (yyn) { - -case 16: -#line 174 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - rcparse_discard_strings (); - ; - break;} -case 17: -#line 183 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_accelerator (yyvsp[-5].id, &yyvsp[-3].res_info, yyvsp[-1].pacc); - ; - break;} -case 18: -#line 190 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.pacc = NULL; - ; - break;} -case 19: -#line 194 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - struct accelerator *a; - - a = (struct accelerator *) res_alloc (sizeof *a); - *a = yyvsp[0].acc; - if (yyvsp[-1].pacc == NULL) - yyval.pacc = a; - else - { - struct accelerator **pp; - - for (pp = &yyvsp[-1].pacc->next; *pp != NULL; pp = &(*pp)->next) - ; - *pp = a; - yyval.pacc = yyvsp[-1].pacc; - } - ; - break;} -case 20: -#line 215 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.acc = yyvsp[-1].acc; - yyval.acc.id = yyvsp[0].il; - ; - break;} -case 21: -#line 220 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.acc = yyvsp[-3].acc; - yyval.acc.id = yyvsp[-2].il; - yyval.acc.flags |= yyvsp[0].is; - if ((yyval.acc.flags & ACC_VIRTKEY) == 0 - && (yyval.acc.flags & (ACC_SHIFT | ACC_CONTROL | ACC_ALT)) != 0) - rcparse_warning ("inappropriate modifiers for non-VIRTKEY"); - ; - break;} -case 22: -#line 232 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - const char *s = yyvsp[0].s; - char ch; - - yyval.acc.next = NULL; - yyval.acc.id = 0; - ch = *s; - if (ch != '^') - yyval.acc.flags = 0; - else - { - yyval.acc.flags = ACC_CONTROL | ACC_VIRTKEY; - ++s; - ch = *s; - ch = toupper ((unsigned char) ch); - } - yyval.acc.key = ch; - if (s[1] != '\0') - rcparse_warning ("accelerator should only be one character"); - ; - break;} -case 23: -#line 253 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.acc.next = NULL; - yyval.acc.flags = 0; - yyval.acc.id = 0; - yyval.acc.key = yyvsp[0].il; - ; - break;} -case 24: -#line 263 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = yyvsp[0].is; - ; - break;} -case 25: -#line 267 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = yyvsp[-2].is | yyvsp[0].is; - ; - break;} -case 26: -#line 272 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = yyvsp[-1].is | yyvsp[0].is; - ; - break;} -case 27: -#line 279 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = ACC_VIRTKEY; - ; - break;} -case 28: -#line 283 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - /* This is just the absence of VIRTKEY. */ - yyval.is = 0; - ; - break;} -case 29: -#line 288 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = ACC_NOINVERT; - ; - break;} -case 30: -#line 292 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = ACC_SHIFT; - ; - break;} -case 31: -#line 296 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = ACC_CONTROL; - ; - break;} -case 32: -#line 300 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = ACC_ALT; - ; - break;} -case 33: -#line 309 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_bitmap (yyvsp[-3].id, &yyvsp[-1].res_info, yyvsp[0].s); - ; - break;} -case 34: -#line 318 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_cursor (yyvsp[-3].id, &yyvsp[-1].res_info, yyvsp[0].s); - ; - break;} -case 35: -#line 328 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - memset (&dialog, 0, sizeof dialog); - dialog.x = yyvsp[-3].il; - dialog.y = yyvsp[-2].il; - dialog.width = yyvsp[-1].il; - dialog.height = yyvsp[0].il; - dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU; - dialog.exstyle = yyvsp[-4].il; - dialog.menu.named = 1; - dialog.class.named = 1; - dialog.font = NULL; - dialog.ex = NULL; - dialog.controls = NULL; - sub_res_info = yyvsp[-5].res_info; - ; - break;} -case 36: -#line 344 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_dialog (yyvsp[-12].id, &sub_res_info, &dialog); - ; - break;} -case 37: -#line 349 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - memset (&dialog, 0, sizeof dialog); - dialog.x = yyvsp[-3].il; - dialog.y = yyvsp[-2].il; - dialog.width = yyvsp[-1].il; - dialog.height = yyvsp[0].il; - dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU; - dialog.exstyle = yyvsp[-4].il; - dialog.menu.named = 1; - dialog.class.named = 1; - dialog.font = NULL; - dialog.ex = ((struct dialog_ex *) - res_alloc (sizeof (struct dialog_ex))); - memset (dialog.ex, 0, sizeof (struct dialog_ex)); - dialog.controls = NULL; - sub_res_info = yyvsp[-5].res_info; - ; - break;} -case 38: -#line 367 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_dialog (yyvsp[-12].id, &sub_res_info, &dialog); - ; - break;} -case 39: -#line 372 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - memset (&dialog, 0, sizeof dialog); - dialog.x = yyvsp[-4].il; - dialog.y = yyvsp[-3].il; - dialog.width = yyvsp[-2].il; - dialog.height = yyvsp[-1].il; - dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU; - dialog.exstyle = yyvsp[-5].il; - dialog.menu.named = 1; - dialog.class.named = 1; - dialog.font = NULL; - dialog.ex = ((struct dialog_ex *) - res_alloc (sizeof (struct dialog_ex))); - memset (dialog.ex, 0, sizeof (struct dialog_ex)); - dialog.ex->help = yyvsp[0].il; - dialog.controls = NULL; - sub_res_info = yyvsp[-6].res_info; - ; - break;} -case 40: -#line 391 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_dialog (yyvsp[-13].id, &sub_res_info, &dialog); - ; - break;} -case 41: -#line 398 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = 0; - ; - break;} -case 42: -#line 402 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = yyvsp[0].il; - ; - break;} -case 44: -#line 410 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - unicode_from_ascii ((int *) NULL, &dialog.caption, yyvsp[0].s); - ; - break;} -case 45: -#line 414 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - dialog.class = yyvsp[0].id; - ; - break;} -case 46: -#line 418 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ style = dialog.style; ; - break;} -case 47: -#line 420 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - dialog.style = style; - ; - break;} -case 48: -#line 424 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - dialog.exstyle = yyvsp[0].il; - ; - break;} -case 49: -#line 428 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - dialog.style |= DS_SETFONT; - dialog.pointsize = yyvsp[-2].il; - unicode_from_ascii ((int *) NULL, &dialog.font, yyvsp[0].s); - ; - break;} -case 50: -#line 434 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - dialog.style |= DS_SETFONT; - dialog.pointsize = yyvsp[-4].il; - unicode_from_ascii ((int *) NULL, &dialog.font, yyvsp[-2].s); - if (dialog.ex == NULL) - rcparse_warning ("extended FONT requires DIALOGEX"); - else - { - dialog.ex->weight = yyvsp[-1].il; - dialog.ex->italic = yyvsp[0].il; - } - ; - break;} -case 51: -#line 447 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - dialog.menu = yyvsp[0].id; - ; - break;} -case 52: -#line 451 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - sub_res_info.characteristics = yyvsp[0].il; - ; - break;} -case 53: -#line 455 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - sub_res_info.language = yyvsp[-1].il | (yyvsp[0].il << 8); - ; - break;} -case 54: -#line 459 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - sub_res_info.version = yyvsp[0].il; - ; - break;} -case 56: -#line 467 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - struct dialog_control **pp; - - for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next) - ; - *pp = yyvsp[0].dialog_control; - ; - break;} -case 57: -#line 478 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_AUTO3STATE | WS_TABSTOP; - base_style = BS_AUTO3STATE; - class = CTL_BUTTON; - ; - break;} -case 58: -#line 484 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 59: -#line 488 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_AUTOCHECKBOX | WS_TABSTOP; - base_style = BS_AUTOCHECKBOX; - class = CTL_BUTTON; - ; - break;} -case 60: -#line 494 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 61: -#line 498 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_AUTORADIOBUTTON | WS_TABSTOP; - base_style = BS_AUTORADIOBUTTON; - class = CTL_BUTTON; - ; - break;} -case 62: -#line 504 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 63: -#line 508 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; - base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; - class = CTL_EDIT; - ; - break;} -case 64: -#line 514 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - if (dialog.ex == NULL) - rcparse_warning ("IEDIT requires DIALOGEX"); - res_string_to_id (&yyval.dialog_control->class, "BEDIT"); - ; - break;} -case 65: -#line 521 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_CHECKBOX | WS_TABSTOP; - base_style = BS_CHECKBOX | WS_TABSTOP; - class = CTL_BUTTON; - ; - break;} -case 66: -#line 527 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 67: -#line 531 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = CBS_SIMPLE | WS_TABSTOP; - base_style = 0; - class = CTL_COMBOBOX; - ; - break;} -case 68: -#line 537 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 69: -#line 542 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = define_control (yyvsp[-9].s, yyvsp[-8].il, yyvsp[-5].il, yyvsp[-4].il, yyvsp[-3].il, yyvsp[-2].il, yyvsp[-7].il, style, yyvsp[-1].il); - if (yyvsp[0].rcdata_item != NULL) - { - if (dialog.ex == NULL) - rcparse_warning ("control data requires DIALOGEX"); - yyval.dialog_control->data = yyvsp[0].rcdata_item; - } - ; - break;} -case 70: -#line 553 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = define_control (yyvsp[-10].s, yyvsp[-9].il, yyvsp[-6].il, yyvsp[-5].il, yyvsp[-4].il, yyvsp[-3].il, yyvsp[-8].il, style, yyvsp[-2].il); - if (dialog.ex == NULL) - rcparse_warning ("help ID requires DIALOGEX"); - yyval.dialog_control->help = yyvsp[-1].il; - yyval.dialog_control->data = yyvsp[0].rcdata_item; - ; - break;} -case 71: -#line 561 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = SS_CENTER | WS_GROUP; - base_style = SS_CENTER; - class = CTL_STATIC; - ; - break;} -case 72: -#line 567 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 73: -#line 571 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_DEFPUSHBUTTON | WS_TABSTOP; - base_style = BS_DEFPUSHBUTTON | WS_TABSTOP; - class = CTL_BUTTON; - ; - break;} -case 74: -#line 577 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 75: -#line 581 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; - base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; - class = CTL_EDIT; - ; - break;} -case 76: -#line 587 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 77: -#line 591 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_GROUPBOX; - base_style = BS_GROUPBOX; - class = CTL_BUTTON; - ; - break;} -case 78: -#line 597 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 79: -#line 601 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; - base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; - class = CTL_EDIT; - ; - break;} -case 80: -#line 607 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - if (dialog.ex == NULL) - rcparse_warning ("IEDIT requires DIALOGEX"); - res_string_to_id (&yyval.dialog_control->class, "HEDIT"); - ; - break;} -case 81: -#line 614 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = define_control (yyvsp[-4].s, yyvsp[-3].il, yyvsp[-2].il, yyvsp[-1].il, 0, 0, CTL_STATIC, - SS_ICON | WS_CHILD | WS_VISIBLE, 0); - if (yyvsp[0].rcdata_item != NULL) - { - if (dialog.ex == NULL) - rcparse_warning ("control data requires DIALOGEX"); - yyval.dialog_control->data = yyvsp[0].rcdata_item; - } - ; - break;} -case 82: -#line 626 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = define_control (yyvsp[-8].s, yyvsp[-7].il, yyvsp[-6].il, yyvsp[-5].il, yyvsp[-4].il, yyvsp[-3].il, CTL_STATIC, - style, yyvsp[-1].il); - if (yyvsp[0].rcdata_item != NULL) - { - if (dialog.ex == NULL) - rcparse_warning ("control data requires DIALOGEX"); - yyval.dialog_control->data = yyvsp[0].rcdata_item; - } - ; - break;} -case 83: -#line 638 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = define_control (yyvsp[-9].s, yyvsp[-8].il, yyvsp[-7].il, yyvsp[-6].il, yyvsp[-5].il, yyvsp[-4].il, CTL_STATIC, - style, yyvsp[-2].il); - if (dialog.ex == NULL) - rcparse_warning ("help ID requires DIALOGEX"); - yyval.dialog_control->help = yyvsp[-1].il; - yyval.dialog_control->data = yyvsp[0].rcdata_item; - ; - break;} -case 84: -#line 647 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; - base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; - class = CTL_EDIT; - ; - break;} -case 85: -#line 653 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - if (dialog.ex == NULL) - rcparse_warning ("IEDIT requires DIALOGEX"); - res_string_to_id (&yyval.dialog_control->class, "IEDIT"); - ; - break;} -case 86: -#line 660 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = LBS_NOTIFY | WS_BORDER; - base_style = LBS_NOTIFY | WS_BORDER; - class = CTL_LISTBOX; - ; - break;} -case 87: -#line 666 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 88: -#line 670 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = SS_LEFT | WS_GROUP; - base_style = SS_LEFT; - class = CTL_STATIC; - ; - break;} -case 89: -#line 676 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 90: -#line 680 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_PUSHBOX | WS_TABSTOP; - base_style = BS_PUSHBOX; - class = CTL_BUTTON; - ; - break;} -case 91: -#line 686 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 92: -#line 690 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_PUSHBUTTON | WS_TABSTOP; - base_style = BS_PUSHBUTTON | WS_TABSTOP; - class = CTL_BUTTON; - ; - break;} -case 93: -#line 696 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 94: -#line 700 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_RADIOBUTTON | WS_TABSTOP; - base_style = BS_RADIOBUTTON; - class = CTL_BUTTON; - ; - break;} -case 95: -#line 706 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 96: -#line 710 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = SS_RIGHT | WS_GROUP; - base_style = SS_RIGHT; - class = CTL_STATIC; - ; - break;} -case 97: -#line 716 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 98: -#line 720 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = SBS_HORZ; - base_style = 0; - class = CTL_SCROLLBAR; - ; - break;} -case 99: -#line 726 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 100: -#line 730 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - default_style = BS_3STATE | WS_TABSTOP; - base_style = BS_3STATE; - class = CTL_BUTTON; - ; - break;} -case 101: -#line 736 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = yyvsp[0].dialog_control; - ; - break;} -case 102: -#line 741 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ style = WS_CHILD | WS_VISIBLE; ; - break;} -case 103: -#line 743 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = define_control (yyvsp[-14].s, yyvsp[-12].il, yyvsp[-10].il, yyvsp[-8].il, yyvsp[-6].il, yyvsp[-4].il, CTL_BUTTON, - style, yyvsp[0].il); - ; - break;} -case 104: -#line 759 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = define_control (yyvsp[-6].s, yyvsp[-5].il, yyvsp[-4].il, yyvsp[-3].il, yyvsp[-2].il, yyvsp[-1].il, class, - default_style | WS_CHILD | WS_VISIBLE, 0); - if (yyvsp[0].rcdata_item != NULL) - { - if (dialog.ex == NULL) - rcparse_warning ("control data requires DIALOGEX"); - yyval.dialog_control->data = yyvsp[0].rcdata_item; - } - ; - break;} -case 105: -#line 771 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = define_control (yyvsp[-8].s, yyvsp[-7].il, yyvsp[-6].il, yyvsp[-5].il, yyvsp[-4].il, yyvsp[-3].il, class, style, yyvsp[-1].il); - if (yyvsp[0].rcdata_item != NULL) - { - if (dialog.ex == NULL) - rcparse_warning ("control data requires DIALOGEX"); - yyval.dialog_control->data = yyvsp[0].rcdata_item; - } - ; - break;} -case 106: -#line 782 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.dialog_control = define_control (yyvsp[-9].s, yyvsp[-8].il, yyvsp[-7].il, yyvsp[-6].il, yyvsp[-5].il, yyvsp[-4].il, class, style, yyvsp[-2].il); - if (dialog.ex == NULL) - rcparse_warning ("help ID requires DIALOGEX"); - yyval.dialog_control->help = yyvsp[-1].il; - yyval.dialog_control->data = yyvsp[0].rcdata_item; - ; - break;} -case 107: -#line 793 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.s = NULL; - ; - break;} -case 108: -#line 797 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.s = yyvsp[-1].s; - ; - break;} -case 109: -#line 804 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.rcdata_item = NULL; - ; - break;} -case 110: -#line 808 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.rcdata_item = yyvsp[-1].rcdata.first; - ; - break;} -case 111: -#line 817 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ style = WS_CHILD | WS_VISIBLE; ; - break;} -case 113: -#line 823 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ style = SS_ICON | WS_CHILD | WS_VISIBLE; ; - break;} -case 115: -#line 829 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ style = base_style | WS_CHILD | WS_VISIBLE; ; - break;} -case 117: -#line 837 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_font (yyvsp[-3].id, &yyvsp[-1].res_info, yyvsp[0].s); - ; - break;} -case 118: -#line 846 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_icon (yyvsp[-3].id, &yyvsp[-1].res_info, yyvsp[0].s); - ; - break;} -case 119: -#line 856 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - language = yyvsp[-1].il | (yyvsp[0].il << 8); - ; - break;} -case 120: -#line 865 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_menu (yyvsp[-5].id, &yyvsp[-3].res_info, yyvsp[-1].menuitem); - ; - break;} -case 121: -#line 872 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = NULL; - ; - break;} -case 122: -#line 876 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - if (yyvsp[-1].menuitem == NULL) - yyval.menuitem = yyvsp[0].menuitem; - else - { - struct menuitem **pp; - - for (pp = &yyvsp[-1].menuitem->next; *pp != NULL; pp = &(*pp)->next) - ; - *pp = yyvsp[0].menuitem; - yyval.menuitem = yyvsp[-1].menuitem; - } - ; - break;} -case 123: -#line 893 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (yyvsp[-2].s, yyvsp[-1].il, yyvsp[0].is, 0, 0, NULL); - ; - break;} -case 124: -#line 897 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (NULL, 0, 0, 0, 0, NULL); - ; - break;} -case 125: -#line 901 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (yyvsp[-4].s, 0, yyvsp[-3].is, 0, 0, yyvsp[-1].menuitem); - ; - break;} -case 126: -#line 908 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = 0; - ; - break;} -case 127: -#line 912 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = yyvsp[-2].is | yyvsp[0].is; - ; - break;} -case 128: -#line 916 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = yyvsp[-1].is | yyvsp[0].is; - ; - break;} -case 129: -#line 923 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = MENUITEM_CHECKED; - ; - break;} -case 130: -#line 927 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = MENUITEM_GRAYED; - ; - break;} -case 131: -#line 931 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = MENUITEM_HELP; - ; - break;} -case 132: -#line 935 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = MENUITEM_INACTIVE; - ; - break;} -case 133: -#line 939 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = MENUITEM_MENUBARBREAK; - ; - break;} -case 134: -#line 943 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.is = MENUITEM_MENUBREAK; - ; - break;} -case 135: -#line 952 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_menu (yyvsp[-5].id, &yyvsp[-3].res_info, yyvsp[-1].menuitem); - ; - break;} -case 136: -#line 959 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = NULL; - ; - break;} -case 137: -#line 963 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - if (yyvsp[-1].menuitem == NULL) - yyval.menuitem = yyvsp[0].menuitem; - else - { - struct menuitem **pp; - - for (pp = &yyvsp[-1].menuitem->next; *pp != NULL; pp = &(*pp)->next) - ; - *pp = yyvsp[0].menuitem; - yyval.menuitem = yyvsp[-1].menuitem; - } - ; - break;} -case 138: -#line 980 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (yyvsp[0].s, 0, 0, 0, 0, NULL); - ; - break;} -case 139: -#line 984 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (yyvsp[-1].s, yyvsp[0].il, 0, 0, 0, NULL); - ; - break;} -case 140: -#line 988 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (yyvsp[-3].s, yyvsp[-2].il, yyvsp[-1].il, yyvsp[0].il, 0, NULL); - ; - break;} -case 141: -#line 992 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (yyvsp[-3].s, 0, 0, 0, 0, yyvsp[-1].menuitem); - ; - break;} -case 142: -#line 996 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (yyvsp[-4].s, yyvsp[-3].il, 0, 0, 0, yyvsp[-1].menuitem); - ; - break;} -case 143: -#line 1000 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (yyvsp[-5].s, yyvsp[-4].il, yyvsp[-3].il, 0, 0, yyvsp[-1].menuitem); - ; - break;} -case 144: -#line 1005 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.menuitem = define_menuitem (yyvsp[-7].s, yyvsp[-6].il, yyvsp[-5].il, yyvsp[-4].il, yyvsp[-3].il, yyvsp[-1].menuitem); - ; - break;} -case 145: -#line 1014 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_messagetable (yyvsp[-3].id, &yyvsp[-1].res_info, yyvsp[0].s); - ; - break;} -case 146: -#line 1023 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_rcdata (yyvsp[-5].id, &yyvsp[-3].res_info, yyvsp[-1].rcdata.first); - ; - break;} -case 147: -#line 1032 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - rcparse_rcdata (); - ; - break;} -case 148: -#line 1036 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - rcparse_normal (); - yyval.rcdata = yyvsp[0].rcdata; - ; - break;} -case 149: -#line 1044 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.rcdata.first = NULL; - yyval.rcdata.last = NULL; - ; - break;} -case 150: -#line 1049 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.rcdata = yyvsp[0].rcdata; - ; - break;} -case 151: -#line 1056 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - struct rcdata_item *ri; - - ri = define_rcdata_string (yyvsp[0].ss.s, yyvsp[0].ss.length); - yyval.rcdata.first = ri; - yyval.rcdata.last = ri; - ; - break;} -case 152: -#line 1064 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - struct rcdata_item *ri; - - ri = define_rcdata_number (yyvsp[0].i.val, yyvsp[0].i.dword); - yyval.rcdata.first = ri; - yyval.rcdata.last = ri; - ; - break;} -case 153: -#line 1072 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - struct rcdata_item *ri; - - ri = define_rcdata_string (yyvsp[0].ss.s, yyvsp[0].ss.length); - yyval.rcdata.first = yyvsp[-2].rcdata.first; - yyvsp[-2].rcdata.last->next = ri; - yyval.rcdata.last = ri; - ; - break;} -case 154: -#line 1081 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - struct rcdata_item *ri; - - ri = define_rcdata_number (yyvsp[0].i.val, yyvsp[0].i.dword); - yyval.rcdata.first = yyvsp[-2].rcdata.first; - yyvsp[-2].rcdata.last->next = ri; - yyval.rcdata.last = ri; - ; - break;} -case 155: -#line 1095 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ sub_res_info = yyvsp[-1].res_info; ; - break;} -case 158: -#line 1102 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_stringtable (&sub_res_info, yyvsp[-1].il, yyvsp[0].s); - ; - break;} -case 159: -#line 1106 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_stringtable (&sub_res_info, yyvsp[-2].il, yyvsp[0].s); - ; - break;} -case 160: -#line 1116 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_user_data (yyvsp[-5].id, yyvsp[-4].id, &yyvsp[-3].res_info, yyvsp[-1].rcdata.first); - ; - break;} -case 161: -#line 1120 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_user_file (yyvsp[-3].id, yyvsp[-2].id, &yyvsp[-1].res_info, yyvsp[0].s); - ; - break;} -case 162: -#line 1129 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - define_versioninfo (yyvsp[-5].id, language, yyvsp[-3].fixver, yyvsp[-1].verinfo); - ; - break;} -case 163: -#line 1136 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.fixver = ((struct fixed_versioninfo *) - res_alloc (sizeof (struct fixed_versioninfo))); - memset (yyval.fixver, 0, sizeof (struct fixed_versioninfo)); - ; - break;} -case 164: -#line 1142 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyvsp[-5].fixver->file_version_ms = (yyvsp[-3].il << 16) | yyvsp[-2].il; - yyvsp[-5].fixver->file_version_ls = (yyvsp[-1].il << 16) | yyvsp[0].il; - yyval.fixver = yyvsp[-5].fixver; - ; - break;} -case 165: -#line 1148 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyvsp[-5].fixver->product_version_ms = (yyvsp[-3].il << 16) | yyvsp[-2].il; - yyvsp[-5].fixver->product_version_ls = (yyvsp[-1].il << 16) | yyvsp[0].il; - yyval.fixver = yyvsp[-5].fixver; - ; - break;} -case 166: -#line 1154 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyvsp[-2].fixver->file_flags_mask = yyvsp[0].il; - yyval.fixver = yyvsp[-2].fixver; - ; - break;} -case 167: -#line 1159 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyvsp[-2].fixver->file_flags = yyvsp[0].il; - yyval.fixver = yyvsp[-2].fixver; - ; - break;} -case 168: -#line 1164 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyvsp[-2].fixver->file_os = yyvsp[0].il; - yyval.fixver = yyvsp[-2].fixver; - ; - break;} -case 169: -#line 1169 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyvsp[-2].fixver->file_type = yyvsp[0].il; - yyval.fixver = yyvsp[-2].fixver; - ; - break;} -case 170: -#line 1174 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyvsp[-2].fixver->file_subtype = yyvsp[0].il; - yyval.fixver = yyvsp[-2].fixver; - ; - break;} -case 171: -#line 1188 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.verinfo = NULL; - ; - break;} -case 172: -#line 1192 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.verinfo = append_ver_stringfileinfo (yyvsp[-7].verinfo, yyvsp[-4].s, yyvsp[-2].verstring); - ; - break;} -case 173: -#line 1196 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.verinfo = append_ver_varfileinfo (yyvsp[-6].verinfo, yyvsp[-2].s, yyvsp[-1].vervar); - ; - break;} -case 174: -#line 1203 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.verstring = NULL; - ; - break;} -case 175: -#line 1207 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.verstring = append_verval (yyvsp[-4].verstring, yyvsp[-2].s, yyvsp[0].s); - ; - break;} -case 176: -#line 1214 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.vervar = NULL; - ; - break;} -case 177: -#line 1218 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.vervar = append_vertrans (yyvsp[-2].vervar, yyvsp[-1].il, yyvsp[0].il); - ; - break;} -case 178: -#line 1227 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.id.named = 0; - yyval.id.u.id = yyvsp[0].il; - ; - break;} -case 179: -#line 1232 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - char *copy, *s; - - /* It seems that resource ID's are forced to upper case. */ - copy = xstrdup (yyvsp[0].s); - for (s = copy; *s != '\0'; s++) - if (islower (*s)) - *s = toupper (*s); - res_string_to_id (&yyval.id, copy); - free (copy); - ; - break;} -case 180: -#line 1250 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - memset (&yyval.res_info, 0, sizeof (struct res_res_info)); - yyval.res_info.language = language; - /* FIXME: Is this the right default? */ - yyval.res_info.memflags = MEMFLAG_MOVEABLE; - ; - break;} -case 181: -#line 1257 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.res_info = yyvsp[-1].res_info; - yyval.res_info.memflags |= yyvsp[0].memflags.on; - yyval.res_info.memflags &=~ yyvsp[0].memflags.off; - ; - break;} -case 182: -#line 1263 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.res_info = yyvsp[-2].res_info; - yyval.res_info.characteristics = yyvsp[0].il; - ; - break;} -case 183: -#line 1268 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.res_info = yyvsp[-3].res_info; - yyval.res_info.language = yyvsp[-1].il | (yyvsp[0].il << 8); - ; - break;} -case 184: -#line 1273 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.res_info = yyvsp[-2].res_info; - yyval.res_info.version = yyvsp[0].il; - ; - break;} -case 185: -#line 1283 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - memset (&yyval.res_info, 0, sizeof (struct res_res_info)); - yyval.res_info.language = language; - yyval.res_info.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE; - ; - break;} -case 186: -#line 1289 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.res_info = yyvsp[-1].res_info; - yyval.res_info.memflags |= yyvsp[0].memflags.on; - yyval.res_info.memflags &=~ yyvsp[0].memflags.off; - ; - break;} -case 187: -#line 1300 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - memset (&yyval.res_info, 0, sizeof (struct res_res_info)); - yyval.res_info.language = language; - yyval.res_info.memflags = MEMFLAG_MOVEABLE; - ; - break;} -case 188: -#line 1306 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.res_info = yyvsp[-1].res_info; - yyval.res_info.memflags |= yyvsp[0].memflags.on; - yyval.res_info.memflags &=~ yyvsp[0].memflags.off; - ; - break;} -case 189: -#line 1318 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.memflags.on = MEMFLAG_MOVEABLE; - yyval.memflags.off = 0; - ; - break;} -case 190: -#line 1323 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.memflags.on = 0; - yyval.memflags.off = MEMFLAG_MOVEABLE; - ; - break;} -case 191: -#line 1328 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.memflags.on = MEMFLAG_PURE; - yyval.memflags.off = 0; - ; - break;} -case 192: -#line 1333 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.memflags.on = 0; - yyval.memflags.off = MEMFLAG_PURE; - ; - break;} -case 193: -#line 1338 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.memflags.on = MEMFLAG_PRELOAD; - yyval.memflags.off = 0; - ; - break;} -case 194: -#line 1343 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.memflags.on = 0; - yyval.memflags.off = MEMFLAG_PRELOAD; - ; - break;} -case 195: -#line 1348 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.memflags.on = MEMFLAG_DISCARDABLE; - yyval.memflags.off = 0; - ; - break;} -case 196: -#line 1358 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.s = yyvsp[0].s; - ; - break;} -case 197: -#line 1362 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.s = yyvsp[0].s; - ; - break;} -case 198: -#line 1379 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - style |= yyvsp[0].il; - ; - break;} -case 199: -#line 1383 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - style &=~ yyvsp[0].il; - ; - break;} -case 200: -#line 1387 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - style |= yyvsp[0].il; - ; - break;} -case 201: -#line 1391 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - style &=~ yyvsp[0].il; - ; - break;} -case 202: -#line 1398 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = yyvsp[0].i.val; - ; - break;} -case 203: -#line 1402 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = yyvsp[-1].il; - ; - break;} -case 204: -#line 1411 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = 0; - ; - break;} -case 205: -#line 1415 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = yyvsp[0].il; - ; - break;} -case 206: -#line 1424 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = yyvsp[0].il; - ; - break;} -case 207: -#line 1433 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = yyvsp[0].i.val; - ; - break;} -case 208: -#line 1442 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i = yyvsp[0].i; - ; - break;} -case 209: -#line 1446 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i = yyvsp[-1].i; - ; - break;} -case 210: -#line 1450 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = ~ yyvsp[0].i.val; - yyval.i.dword = yyvsp[0].i.dword; - ; - break;} -case 211: -#line 1455 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = - yyvsp[0].i.val; - yyval.i.dword = yyvsp[0].i.dword; - ; - break;} -case 212: -#line 1460 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val * yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 213: -#line 1465 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val / yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 214: -#line 1470 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val % yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 215: -#line 1475 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val + yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 216: -#line 1480 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val - yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 217: -#line 1485 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val & yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 218: -#line 1490 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val ^ yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 219: -#line 1495 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val | yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 220: -#line 1506 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = yyvsp[0].il; - ; - break;} -case 221: -#line 1515 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.il = yyvsp[0].i.val; - ; - break;} -case 222: -#line 1526 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i = yyvsp[0].i; - ; - break;} -case 223: -#line 1530 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i = yyvsp[-1].i; - ; - break;} -case 224: -#line 1534 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = ~ yyvsp[0].i.val; - yyval.i.dword = yyvsp[0].i.dword; - ; - break;} -case 225: -#line 1539 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val * yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 226: -#line 1544 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val / yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 227: -#line 1549 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val % yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 228: -#line 1554 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val + yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 229: -#line 1559 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val - yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 230: -#line 1564 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val & yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 231: -#line 1569 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val ^ yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -case 232: -#line 1574 "/5g/ian/binutils/release/copy/binutils/rcparse.y" -{ - yyval.i.val = yyvsp[-2].i.val | yyvsp[0].i.val; - yyval.i.dword = yyvsp[-2].i.dword || yyvsp[0].i.dword; - ; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 498 "/usr/cygnus/progressive-97r2/share/bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror ("parse error; also virtual memory exceeded"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ - - if (yyerrstatus == 3) - { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; -} -#line 1580 "/5g/ian/binutils/release/copy/binutils/rcparse.y" - - -/* Set the language from the command line. */ - -void -rcparse_set_language (lang) - int lang; -{ - language = lang; -} diff --git a/contrib/binutils/binutils/rcparse.h b/contrib/binutils/binutils/rcparse.h deleted file mode 100644 index dbf9c59509c4..000000000000 --- a/contrib/binutils/binutils/rcparse.h +++ /dev/null @@ -1,124 +0,0 @@ -typedef union -{ - struct accelerator acc; - struct accelerator *pacc; - struct dialog_control *dialog_control; - struct menuitem *menuitem; - struct - { - struct rcdata_item *first; - struct rcdata_item *last; - } rcdata; - struct rcdata_item *rcdata_item; - struct stringtable_data *stringtable; - struct fixed_versioninfo *fixver; - struct ver_info *verinfo; - struct ver_stringinfo *verstring; - struct ver_varinfo *vervar; - struct res_id id; - struct res_res_info res_info; - struct - { - unsigned short on; - unsigned short off; - } memflags; - struct - { - unsigned long val; - /* Nonzero if this number was explicitly specified as long. */ - int dword; - } i; - unsigned long il; - unsigned short is; - const char *s; - struct - { - unsigned long length; - const char *s; - } ss; -} YYSTYPE; -#define BEG 258 -#define END 259 -#define ACCELERATORS 260 -#define VIRTKEY 261 -#define ASCII 262 -#define NOINVERT 263 -#define SHIFT 264 -#define CONTROL 265 -#define ALT 266 -#define BITMAP 267 -#define CURSOR 268 -#define DIALOG 269 -#define DIALOGEX 270 -#define EXSTYLE 271 -#define CAPTION 272 -#define CLASS 273 -#define STYLE 274 -#define AUTO3STATE 275 -#define AUTOCHECKBOX 276 -#define AUTORADIOBUTTON 277 -#define CHECKBOX 278 -#define COMBOBOX 279 -#define CTEXT 280 -#define DEFPUSHBUTTON 281 -#define EDITTEXT 282 -#define GROUPBOX 283 -#define LISTBOX 284 -#define LTEXT 285 -#define PUSHBOX 286 -#define PUSHBUTTON 287 -#define RADIOBUTTON 288 -#define RTEXT 289 -#define SCROLLBAR 290 -#define STATE3 291 -#define USERBUTTON 292 -#define BEDIT 293 -#define HEDIT 294 -#define IEDIT 295 -#define FONT 296 -#define ICON 297 -#define LANGUAGE 298 -#define CHARACTERISTICS 299 -#define VERSIONK 300 -#define MENU 301 -#define MENUEX 302 -#define MENUITEM 303 -#define SEPARATOR 304 -#define POPUP 305 -#define CHECKED 306 -#define GRAYED 307 -#define HELP 308 -#define INACTIVE 309 -#define MENUBARBREAK 310 -#define MENUBREAK 311 -#define MESSAGETABLE 312 -#define RCDATA 313 -#define STRINGTABLE 314 -#define VERSIONINFO 315 -#define FILEVERSION 316 -#define PRODUCTVERSION 317 -#define FILEFLAGSMASK 318 -#define FILEFLAGS 319 -#define FILEOS 320 -#define FILETYPE 321 -#define FILESUBTYPE 322 -#define BLOCKSTRINGFILEINFO 323 -#define BLOCKVARFILEINFO 324 -#define VALUE 325 -#define BLOCK 326 -#define MOVEABLE 327 -#define FIXED 328 -#define PURE 329 -#define IMPURE 330 -#define PRELOAD 331 -#define LOADONCALL 332 -#define DISCARDABLE 333 -#define NOT 334 -#define QUOTEDSTRING 335 -#define STRING 336 -#define NUMBER 337 -#define SIZEDSTRING 338 -#define NEG 339 - - -extern YYSTYPE yylval; diff --git a/contrib/binutils/etc/cfg-paper.texi b/contrib/binutils/etc/cfg-paper.texi deleted file mode 100644 index bcfbb31e13f8..000000000000 --- a/contrib/binutils/etc/cfg-paper.texi +++ /dev/null @@ -1,717 +0,0 @@ -\input texinfo -@c %**start of header -@setfilename cfg-paper.info -@settitle On Configuring Development Tools -@c %**end of header -@setchapternewpage off - -@ifinfo -This document attempts to describe the general concepts behind -configuration of the @sc{gnu} Development Tools. -It also discusses common usage. - -Copyright (C) 1991, 1992, 1994 Cygnus Support -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by Cygnus Support. -@end ifinfo - -@titlepage -@sp 10 -@title{On Configuring Development Tools} -@author{K. Richard Pixley, @code{rich@@cygnus.com}} -@author{Cygnus Support} -@page - -@vskip 0pt plus 1filll -Copyright @copyright{} 1991, 1992, 1994 Cygnus Support - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by Cygnus Support. -@end titlepage - -@ifinfo -@format -START-INFO-DIR-ENTRY -* configuration: (cfg-paper). Some theory on configuring source. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@node top, Some Basic Terms, (dir), (dir) - -@ifinfo -This document attempts to describe the general concepts behind -configuration of the @sc{gnu} Development Tools. -It also discusses common usage. -@end ifinfo - -@menu -* Some Basic Terms:: Some Basic Terms -* Specifics.:: Specifics -* Building Development Environments:: Building Development Environments -* A Walk Through:: A Walk Through -* Final Notes:: Final Notes -* Index:: Index - - --- The Detailed Node Listing --- - -Some Basic Terms - -* Host Environments:: Host Environments -* Configuration Time Options:: Configuration Time Options - -A Walk Through - -* Native Development Environments:: Native Development Environments -* Emulation Environments:: Emulation Environments -* Simple Cross Environments:: Simple Cross Environments -* Crossing Into Targets:: Crossing Into Targets -* Canadian Cross:: Canadian Cross - -Final Notes - -* Hacking Configurations:: Hacking Configurations -@end menu - -@node Some Basic Terms, Specifics., top, top -@chapter Some Basic Terms - -There are a lot of terms that are frequently used when discussing -development tools. Most of the common terms have been used for many -different concepts such that their meanings have become ambiguous to the -point of being confusing. Typically, we only guess at their meanings -from context and we frequently guess wrong. - -This document uses very few terms by comparison. The intent is to make -the concepts as clear as possible in order to convey the usage and -intent of these tools. - -@emph{Programs} run on @emph{machines}. Programs are very nearly always -written in @emph{source}. Programs are @emph{built} from source. -@emph{Compilation} is a process that is frequently, but not always, used -when building programs. -@cindex Programs -@cindex Machines -@cindex Source -@cindex Building -@cindex Compilation - -@menu -* Host Environments:: Host Environments -* Configuration Time Options:: Configuration Time Options -@end menu - -@node Host Environments, Configuration Time Options, Some Basic Terms, Some Basic Terms -@section Host Environments - -@cindex host -In this document, the word @emph{host} refers to the environment in -which the source in question will be compiled. @emph{host} and -@emph{host name} have nothing to do with the proper name of your host, -like @emph{ucbvax}, @emph{prep.ai.mit.edu} or @emph{att.com}. Instead -they refer to things like @emph{sun4} and @emph{dec3100}. - -Forget for a moment that this particular directory of source is the -source for a development environment. Instead, pretend that it is the -source for a simpler, more mundane, application, say, a desk calculator. - -Source that can be compiled in more than one environment, generally -needs to be set up for each environment explicitly. Here we refer to -that process as configuration. That is, we configure the source for a -host. - -For example, if we wanted to configure our mythical desk calculator to -compile on a SparcStation, we might configure for host sun4. With our -configuration system: - -@example -cd desk-calculator ; ./configure sun4 -@end example - -@noindent -does the trick. @code{configure} is a shell script that sets up Makefiles, -subdirectories, and symbolic links appropriate for compiling the source -on a sun4. - -The @emph{host} environment does not necessarily refer to the machine on -which the tools are built. It is possible to provide a sun3 development -environment on a sun4. If we wanted to use a cross compiler on the sun4 -to build a program intended to be run on a sun3, we would configure the -source for sun3. - -@example -cd desk-calculator ; ./configure sun3 -@end example - -@noindent -The fact that we are actually building the program on a sun4 makes no -difference if the sun3 cross compiler presents an environment that looks -like a sun3 from the point of view of the desk calculator source code. -Specifically, the environment is a sun3 environment if the header files, -predefined symbols, and libraries appear as they do on a sun3. - -Nor does the host environment refer to the the machine on which the -program to be built will run. It is possible to provide a sun3 -emulation environment on a sun4 such that programs built in a sun3 -development environment actually run on the sun4. This technique is -often used within individual programs to remedy deficiencies in the host -operating system. For example, some operating systems do not provide -the @code{bcopy} function and so it is emulated using the -@code{memcpy} funtion. - -Host environment simply refers to the environment in which the program -will be built from the source. - - -@node Configuration Time Options, , Host Environments, Some Basic Terms -@section Configuration Time Options - -Many programs have compile time options. That is, features of the -program that are either compiled into the program or not based on a -choice made by the person who builds the program. We refer to these as -@emph{configuration options}. For example, our desk calculator might be -capable of being compiled into a program that either uses infix notation -or postfix as a configuration option. For a sun3, to choose infix you -might use: - -@example -./configure sun3 --enable-notation=infix -@end example - -@noindent -while for a sun4 with postfix you might use: - -@example -./configure sun4 --enable-notation=postfix -@end example - -If we wanted to build both at the same time, the intermediate pieces -used in the build process must be kept separate. - -@example -mkdir ../objdir.sun4 -(cd ../objdir.sun4 ; ../configure sun4 --enable-notation=postfix --srcdir=../src) -mkdir ../objdir.sun3 -(cd ../objdir.sun3 ; ../configure sun3 --enable-notation=infix --srcdir=../src) -@end example - -@noindent -will create subdirectories for the intermediate pieces of the sun4 and -sun3 configurations. This is necessary as previous systems were only -capable of one configuration at a time. Otherwise, a second -configuration would write over the first. We've chosen to retain this -behaviour so the obj directories and the @code{--srcdir} configuration -option are necessary to get the new behaviour. The order of the -arguments doesn't matter. There should be exactly one argument without -a leading @samp{-} and that argument will be assumed to be the host -name. - -From here on the examples will assume that you want to build the tools -@emph{in place} and won't show the @code{--srcdir} option, but remember -that it is available. - -In order to actually install the program, the configuration system needs -to know where you would like the program installed. The default -location is @file{/usr/local}. We refer to this location as -@code{$(prefix)}. All user visible programs will be installed in -@file{@code{$(prefix)}/bin}. All other programs and files will be -installed in a subdirectory of @file{@code{$(prefix)}/lib}. - -You can only change @code{$(prefix)} as a configuration time -option. - -@example -./configure sun4 --enable-notation=postfix --prefix=/local -@end example - -@noindent -Will configure the source such that: - -@example -make install -@end example - -@noindent -will put its programs in @file{/local/bin} and @file{/local/lib/gcc}. -If you change @code{$(prefix)} after building the source, you will need -to: - -@example -make clean -@end example - -@noindent -before the change will be propogated properly. This is because some -tools need to know the locations of other tools. - -With these concepts in mind, we can drop the desk calculator example and -move on to the application that resides in these directories, namely, -the source to a development environment. - -@node Specifics., Building Development Environments, Some Basic Terms, top -@chapter Specifics - -The @sc{gnu} Development Tools can be built on a wide variety of hosts. So, -of course, they must be configured. Like the last example, - -@example -./configure sun4 --prefix=/local -./configure sun3 --prefix=/local -@end example - -@noindent -will configure the source to be built in subdirectories, in order to -keep the intermediate pieces separate, and to be installed in -@file{/local}. - -When built with suitable development environments, these will be native -tools. We'll explain the term @emph{native} later. - -@node Building Development Environments, A Walk Through, Specifics., top -@chapter Building Development Environments - -@cindex Target - -The @sc{gnu} development tools can not only be built in a -number of host development environments, they can also be configured to -create a number of different development environments on each of those -hosts. We refer to a specific development environment created as a -@emph{target}. That is, the word @emph{target} refers to the development -environment produced by compiling this source and installing the -resulting programs. - -For the @sc{gnu} development tools, the default target is the -same as the host. That is, the development environment produced is -intended to be compatible with the environment used to build the tools. - -In the example above, we created two configurations, one for sun4 and -one for sun3. The first configuration is expecting to be built in a -sun4 development environment, to create a sun4 development environment. -It doesn't necessarily need to be built on a sun4 if a sun4 development -environment is available elsewhere. Likewise, if the available sun4 -development environment produces executables intended for something -other than sun4, then the development environment built from this sun4 -configuration will run on something other than a sun4. From the point -of view of the configuration system and the @sc{gnu} development tools -source, this doesn't matter. What matters is that they will be built in -a sun4 environment. - -Similarly, the second configuration given above is expecting to be built -in a sun3 development environment, to create a sun3 development -environment. - -The development environment produced is a configuration time option, -just like @code{$(prefix)}. - -@example -./configure sun4 --prefix=/local --target=sun3 -./configure sun3 --prefix=/local --target=sun4 -@end example - -In this example, like before, we create two configurations. The first -is intended to be built in a sun4 environment, in subdirectories, to be -installed in @file{/local}. The second is intended to be built in a -sun3 environment, in subdirectories, to be installed in @file{/local}. - -Unlike the previous example, the first configuration will produce a sun3 -development environment, perhaps even suitable for building the second -configuration. Likewise, the second configuration will produce a sun4 -development environment, perhaps even suitable for building the first -configuration. - -The development environment used to build these configurations will -determine the machines on which the resulting development environments -can be used. - - -@node A Walk Through, Final Notes, Building Development Environments, top -@chapter A Walk Through - - -@menu -* Native Development Environments:: Native Development Environments -* Emulation Environments:: Emulation Environments -* Simple Cross Environments:: Simple Cross Environments -* Crossing Into Targets:: Crossing Into Targets -* Canadian Cross:: Canadian Cross -@end menu - -@node Native Development Environments, Emulation Environments, A Walk Through, A Walk Through -@section Native Development Environments - -Let us assume for a moment that you have a sun4 and that with your sun4 -you received a development environment. This development environment is -intended to be run on your sun4 to build programs that can be run on -your sun4. You could, for instance, run this development environment on -your sun4 to build our example desk calculator program. You could then -run the desk calculator program on your sun4. - -@cindex Native -@cindex Foreign -The resulting desk calculator program is referred to as a @emph{native} -program. The development environment itself is composed of native -programs that, when run, build other native programs. Any other program -is referred to as @emph{foreign}. Programs intended for other machines are -foreign programs. - -This type of development environment, which is by far the most common, -is refered to as @emph{native}. That is, a native development environment -runs on some machine to build programs for that same machine. The -process of using a native development environment to build native -programs is called a @emph{native} build. - -@example -./configure sun4 -@end example - -@noindent -will configure this source such that when built in a sun4 development -environment, with a development environment that builds programs -intended to be run on sun4 machines, the programs built will be native -programs and the resulting development environment will be a native -development environment. - -The development system that came with your sun4 is one such environment. -Using it to build the @sc{gnu} Development Tools is a very common activity -and the resulting development environment is quite popular. - -@example -make all -@end example - -@noindent -will build the tools as configured and will assume that you want to use -the native development environment that came with your machine. - -@cindex Bootstrapping -@cindex Stage1 -Using a development environment to build a development environment is -called @emph{bootstrapping}. The release of the @sc{gnu} -Development Tools is capable of bootstrapping itself. This is a very -powerful feature that we'll return to later. For now, let's pretend -that you used the native development environment that came with your -sun4 to bootstrap the release and let's call the new -development environment @emph{stage1}. - -Why bother? Well, most people find that the @sc{gnu} development -environment builds programs that run faster and take up less space than -the native development environments that came with their machines. Some -people didn't get development environments with their machines and some -people just like using the @sc{gnu} tools better than using other tools. - -@cindex Stage2 -While you're at it, if the @sc{gnu} tools produce better programs, maybe you -should use them to build the @sc{gnu} tools. So let's -pretend that you do. Let's call the new development environment -@emph{stage2}. - -@cindex Stage3 -So far you've built a development environment, stage1, and you've used -stage1 to build a new, faster and smaller development environment, -stage2, but you haven't run any of the programs that the @sc{gnu} tools have -built. You really don't yet know if these tools work. Do you have any -programs built with the @sc{gnu} tools? Yes, you do. stage2. What does -that program do? It builds programs. Ok, do you have any source handy -to build into a program? Yes, you do. The @sc{gnu} tools themselves. In -fact, if you use stage2 to build the @sc{gnu} tools again the resulting -programs should be identical to stage2. Let's pretend that you do and -call the new development environment @emph{stage3}. - -@cindex Three stage boot -You've just completed what's called a @emph{three stage boot}. You now have -a small, fast, somewhat tested, development environment. - -@example -make bootstrap -@end example - -@noindent -will do a three stage boot across all tools and will compare stage2 to -stage3 and complain if they are not identical. - -Once built, - -@example -make install -@end example - -@noindent -will install the development environment in the default location, or in -@code{$(prefix)} if you specified an alternate when you configured. - -@cindex Cross -Any development environment that is not a native development environment -is refered to as a @emph{cross} development environment. There are many -different types of cross development environments but most fall into one -of three basic categories. - - -@node Emulation Environments, Simple Cross Environments, Native Development Environments, A Walk Through -@section Emulation Environments - -@cindex Emulation -The first category of cross development environment is called -@emph{emulation}. There are two primary types of emulation, but both -types result in programs that run on the native host. - -@cindex Software emulation -@cindex Software emulator -The first type is @emph{software emulation}. This form of cross -development environment involves a native program that when run on the -native host, is capable of interpreting, and in most aspects running, a -program intended for some other machine. This technique is typically -used when the other machine is either too expensive, too slow, too fast, -or not available, perhaps because it hasn't yet been built. The native, -interpreting program is called a @emph{software emulator}. - -The @sc{gnu} Development Tools do not currently include any software -emulators. Some do exist and the @sc{gnu} Development Tools can be -configured to create simple cross development environments for with -these emulators. More on this later. - -The second type of emulation is when source intended for some other -development environment is built into a program intended for the native -host. The concepts of operating system universes and hosted operating -systems are two such development environments. - -@node Simple Cross Environments, Crossing Into Targets, Emulation Environments, A Walk Through -@section Simple Cross Environments - -@example -./configure sun4 --target=a29k -@end example - -@noindent -will configure the tools such that when compiled in a sun4 development -environment the resulting development environment can be used to create -programs intended for an a29k. Again, this does not necessarily mean -that the new development environment can be run on a sun4. That would -depend on the development environment used to build these tools. - -Earlier you saw how to configure the tools to build a native development -environment, that is, a development environment that runs on your sun4 -and builds programs for your sun4. Let's pretend that you use stage3 to -build this simple cross configuration and let's call the new development -environment gcc-a29k. Remember that this is a native build. Gcc-a29k -is a collection of native programs intended to run on your sun4. That's -what stage3 builds, programs for your sun4. Gcc-a29k represents an a29k -development environment that builds programs intended to run on an a29k. -But, remember, gcc-a29k runs on your sun4. Programs built with gcc-a29k -will run on your sun4 only with the help of an appropriate software -emulator. - -@cindex Simple cross -@cindex Crossing to -Building gcc-a29k is also a bootstrap but of a slightly different sort. -We call gcc-a29k a @emph{simple cross} environment and using gcc-a29k to -build a program intended for a29k is called @emph{crossing to} a29k. -Simple cross environments are the second category of cross development -environments. - - -@node Crossing Into Targets, Canadian Cross, Simple Cross Environments, A Walk Through -@section Crossing Into Targets - -@example -./configure a29k --target=a29k -@end example - -@noindent -will configure the tools such that when compiled in an a29k development -environment, the resulting development environment can be used to create -programs intended for an a29k. Again, this does not necessarily mean -that the new development environment can be run on an a29k. That would -depend on the development environment used to build these tools. - -If you've been following along this walk through, then you've already -built an a29k environment, namely gcc-a29k. Let's pretend you use -gcc-a29k to build the current configuration. - -Gcc-a29k builds programs intended for the a29k so the new development -environment will be intended for use on an a29k. That is, this new gcc -consists of programs that are foreign to your sun4. They cannot be run -on your sun4. - -@cindex Crossing into -The process of building this configuration is a another bootstrap. This -bootstrap is also a cross to a29k. Because this type of build is both a -bootstrap and a cross to a29k, it is sometimes referred to as a -@emph{cross into} a29k. This new development environment isn't really a -cross development environment at all. It is intended to run on an a29k -to produce programs for an a29k. You'll remember that this makes it, by -definition, an a29k native compiler. @emph{Crossing into} has been -introduced here not because it is a type of cross development -environment, but because it is frequently mistaken as one. The process -is @emph{a cross} but the resulting development environment is a native -development environment. - -You could not have built this configuration with stage3, because stage3 -doesn't provide an a29k environment. Instead it provides a sun4 -environment. - -If you happen to have an a29k lying around, you could now use this fresh -development environment on the a29k to three-stage these tools all over -again. This process would look just like it did when we built the -native sun4 development environment because we would be building another -native development environment, this one on a29k. - - -@node Canadian Cross, , Crossing Into Targets, A Walk Through -@section Canadian Cross - -So far you've seen that our development environment source must be -configured for a specific host and for a specific target. You've also -seen that the resulting development environment depends on the -development environment used in the build process. - -When all four match identically, that is, the configured host, the -configured target, the environment presented by the development -environment used in the build, and the machine on which the resulting -development environment is intended to run, then the new development -environment will be a native development environment. - -When all four match except the configured host, then we can assume that -the development environment used in the build is some form of library -emulation. - -When all four match except for the configured target, then the resulting -development environment will be a simple cross development environment. - -When all four match except for the host on which the development -environment used in the build runs, the build process is a @emph{cross into} -and the resulting development environment will be native to some other -machine. - -Most of the other permutations do exist in some form, but only one more -is interesting to the current discussion. - -@example -./configure a29k --target=sun3 -@end example - -@noindent -will configure the tools such that when compiled in an a29k development -environment, the resulting development environment can be used to create -programs intended for a sun3. Again, this does not necessarily mean -that the new development environment can be run on an a29k. That would -depend on the development environment used to build these tools. - -If you are still following along, then you have two a29k development -environments, the native development environment that runs on a29k, and -the simple cross that runs on your sun4. If you use the a29k native -development environment on the a29k, you will be doing the same thing we -did a while back, namely building a simple cross from a29k to sun3. -Let's pretend that instead, you use gcc-a29k, the simple cross -development environment that runs on sun4 but produces programs for -a29k. - -The resulting development environment will run on a29k because that's -what gcc-a29k builds, a29k programs. This development environment will -produce programs for a sun3 because that is how it was configured. This -means that the resulting development environment is a simple cross. - -@cindex Canadian Cross -@cindex Three party cross -There really isn't a common name for this process because very few -development environments are capable of being configured this -extensively. For the sake of discussion, let's call this process a -@emph{Canadian cross}. It's a three party cross, Canada has a three -party system, hence Canadian Cross. - -@node Final Notes, Index, A Walk Through, top -@chapter Final Notes - -By @emph{configures}, I mean that links, Makefile, .gdbinit, and -config.status are built. Configuration is always done from the source -directory. - -@table @code - -@item ./configure @var{name} -configures this directory, perhaps recursively, for a single host+target -pair where the host and target are both @var{name}. If a previous -configuration existed, it will be overwritten. - -@item ./configure @var{hostname} --target=@var{targetname} -configures this directory, perhaps recursively, for a single host+target -pair where the host is @var{hostname} and target is @var{targetname}. -If a previous configuration existed, it will be overwritten. - -@end table - -@menu -* Hacking Configurations:: Hacking Configurations -@end menu - -@node Hacking Configurations, , Final Notes, Final Notes -@section Hacking Configurations - -The configure scripts essentially do three things, create subdirectories -if appropriate, build a @file{Makefile}, and create links to files, all -based on and tailored to, a specific host+target pair. The scripts also -create a @file{.gdbinit} if appropriate but this is not tailored. - -The Makefile is created by prepending some variable definitions to a -Makefile template called @file{Makefile.in} and then inserting host and -target specific Makefile fragments. The variables are set based on the -chosen host+target pair and build style, that is, if you use -@code{--srcdir} or not. The host and target specific Makefile may or may -not exist. - -@itemize @bullet - -@item -Makefiles can be edited directly, but those changes will eventually be -lost. Changes intended to be permanent for a specific host should be -made to the host specific Makefile fragment. This should be in -@file{./config/mh-@var{host}} if it exists. Changes intended to be -permanent for a specific target should be made to the target specific -Makefile fragment. This should be in @file{./config/mt-@var{target}} if -it exists. Changes intended to be permanent for the directory should be -made in @file{Makefile.in}. To propogate changes to any of these, -either use @code{make Makefile} or @code{./config.status} or -re-configure. - -@end itemize - -@page -@node Index, , Final Notes, top -@appendix Index - -@printindex cp - -@contents -@bye - -@c Local Variables: -@c fill-column: 72 -@c End: diff --git a/contrib/binutils/etc/configure.man b/contrib/binutils/etc/configure.man deleted file mode 100644 index a7699041a711..000000000000 --- a/contrib/binutils/etc/configure.man +++ /dev/null @@ -1,166 +0,0 @@ -.\" -*- nroff -*- -.\" Copyright (c) 1991, 1992, 1996 Cygnus Support -.\" written by K. Richard Pixley -.TH configure 1 "29 March 1996" "cygnus support" "Cygnus Support" -.de BP -.sp -.ti \-.2i -\(** -.. - -.SH NAME -configure \- prepare source code to be built - -.SH SYNOPSIS -configure HOST [--target=TARGET] [--srcdir=DIR] [--rm] - [--site=SITE] [--prefix=DIR] [--exec_prefix=DIR] - [--program_prefix=DIR] [--tmpdir=DIR] - [--with-PACKAGE[=YES/NO]] [--without-PACKAGE] - [--enable-FEATURE[=YES/NO]] [--disable-FEATURE] - [--norecursion] [--nfp] [-s] [-v] [-V | --version] [--help] - -.SH DESCRIPTION -.I configure -is a program used to prepare souce code to be built. It does this by -generating Makefiles and .gdbinit files, creating symlinks, recursing -in subdirectories, and some other miscellaneous file editing. - -.SH OPTIONS -.I configure -accepts the following options: - -.TP -.I \--target=TARGET -Requests that the sources be configured to target the -.I TARGET -machine. If no target is specified explicitly, the target is assumed -to be the same as the host. - -.TP -.I \--srcdir=DIR -tells configure to find the source in -.I DIR. -Object code is always built in the current directory, -.I `.'. - -.TP -.I \--rm -asks configure to remove a configuration rather than create one. - -.TP -.I \--site=SITE -asks configure to use any site-specific Makefile fragments for -.I SITE -when building Makefiles. - -.TP -.I \--prefix=DIR -sets the location in which to install files to -.I DIR. -The default is "/usr/local". - -.TP -.I \--exec_prefix=DIR -sets the root directory for host-dependent files to -.I DIR. -The default location is the value of -.I prefix. - -.TP -.I \--program_prefix=DIR -configures the source to install programs which have the same names as -common Unix programs, such as "make", in -.I DIR. -Also applies to programs which might be used for cross-compilation. - -.TP -.I \--tmpdir=DIR -sets the directory in which configure creates temporary files to -.I DIR. - -.TP -.I \--with-PACKAGE[=YES/NO] -sets a flag for the build to recognize that -.I PACKAGE -is explicitly present or not present. If -.I \=YES/NO -is nonexistent, the default is -.I YES. -.I \--without-PACKAGE -is equivalent to -.IR \--with-PACKAGE=no . - -.TP -.I \--enable-FEATURE[=YES/NO] -sets a flag for the build to recognize that -.I FEATURE -should be included or not included. If -.I \=YES/NO -is nonexistent, the default is -.I YES. -.I \--disable-FEATURE -is equivalent to -.IR --enable-FEATURE=no . - -.TP -.I \--norecursion -asks that only the current directory be configured. Normally -.I configure -recurs on subdirectories. - -.TP -.I \-nfp -Notifies -.I configure -that all of the specified hosts have -.I no floating point -units. - -.TP -.I \-s -used internally by configure to supress status messages on -subdirectory recursions. Override with -.I \-v - -.TP -.I \-v -verbose output. Asks that configure print status lines for each -directory configured. Normally, only the status lines for the current -directory are printed. - -.TP -.I \--version -.I \-V -prints -.I configure -version number. - -.TP -.I \-help -displays a brief usage summary. - - -.SH FILES -configure.in for each directory's individual needs -.br -Makefile.in Makefile template -.br -config.sub for parsing configuration names -.br -config.guess for guessing HOST when not specified -.br -config.status non-recursively rebuilds current directory - -.SH FILES -.ta \w'gmon.sum 'u -a.out the namelist and text space. -.br -gmon.out dynamic call graph and profile. -.br -gmon.sum summarized dynamic call graph and profile. - -.SH "SEE ALSO" -.RB "`\|" configure "\|'" -entry in -.B -info. diff --git a/contrib/binutils/gas/acconfig.h b/contrib/binutils/gas/acconfig.h deleted file mode 100644 index c9c60025c757..000000000000 --- a/contrib/binutils/gas/acconfig.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Name of package. */ -#undef PACKAGE - -/* Version of package. */ -#undef VERSION - -/* Should gas use high-level BFD interfaces? */ -#undef BFD_ASSEMBLER - -/* Some assert/preprocessor combinations are incapable of handling - certain kinds of constructs in the argument of assert. For example, - quoted strings (if requoting isn't done right) or newlines. */ -#undef BROKEN_ASSERT - -/* If we aren't doing cross-assembling, some operations can be optimized, - since byte orders and value sizes don't need to be adjusted. */ -#undef CROSS_COMPILE - -/* Some gas code wants to know these parameters. */ -#undef TARGET_ALIAS -#undef TARGET_CPU -#undef TARGET_CANONICAL -#undef TARGET_OS -#undef TARGET_VENDOR - -/* Sometimes the system header files don't declare strstr. */ -#undef NEED_DECLARATION_STRSTR - -/* Sometimes the system header files don't declare malloc and realloc. */ -#undef NEED_DECLARATION_MALLOC - -/* Sometimes the system header files don't declare free. */ -#undef NEED_DECLARATION_FREE - -/* Sometimes the system header files don't declare sbrk. */ -#undef NEED_DECLARATION_SBRK - -/* Sometimes errno.h doesn't declare errno itself. */ -#undef NEED_DECLARATION_ERRNO - -#undef MANY_SEGMENTS - -/* The configure script defines this for some targets based on the - target name used. It is not always defined. */ -#undef TARGET_BYTES_BIG_ENDIAN - -/* Needed only for some configurations that can produce multiple output - formats. */ -#undef DEFAULT_EMULATION -#undef EMULATIONS -#undef USE_EMULATIONS -#undef OBJ_MAYBE_AOUT -#undef OBJ_MAYBE_BOUT -#undef OBJ_MAYBE_COFF -#undef OBJ_MAYBE_ECOFF -#undef OBJ_MAYBE_ELF -#undef OBJ_MAYBE_GENERIC -#undef OBJ_MAYBE_HP300 -#undef OBJ_MAYBE_IEEE -#undef OBJ_MAYBE_SOM -#undef OBJ_MAYBE_VMS - -/* Used for some of the COFF configurations, when the COFF code needs - to select something based on the CPU type before it knows it... */ -#undef I386COFF -#undef M68KCOFF -#undef M88KCOFF - -/* Using cgen code? */ -#undef USING_CGEN - -/* Needed only for sparc configuration. */ -#undef DEFAULT_ARCH - -/* Needed only for PowerPC Solaris. */ -#undef TARGET_SOLARIS_COMMENT - -/* Needed only for SCO 5. */ -#undef SCO_ELF diff --git a/contrib/binutils/gas/conf.in b/contrib/binutils/gas/conf.in deleted file mode 100644 index d56807cd88d5..000000000000 --- a/contrib/binutils/gas/conf.in +++ /dev/null @@ -1,127 +0,0 @@ -/* conf.in. Generated automatically from configure.in by autoheader. */ - -/* Define if using alloca.c. */ -#undef C_ALLOCA - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -#undef CRAY_STACKSEG_END - -/* Define if you have alloca, as a function or macro. */ -#undef HAVE_ALLOCA - -/* Define if you have and it should be used (not on Ultrix). */ -#undef HAVE_ALLOCA_H - -/* Define as __inline if that's what the C compiler calls it. */ -#undef inline - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown - */ -#undef STACK_DIRECTION - -/* Should gas use high-level BFD interfaces? */ -#undef BFD_ASSEMBLER - -/* Some assert/preprocessor combinations are incapable of handling - certain kinds of constructs in the argument of assert. For example, - quoted strings (if requoting isn't done right) or newlines. */ -#undef BROKEN_ASSERT - -/* If we aren't doing cross-assembling, some operations can be optimized, - since byte orders and value sizes don't need to be adjusted. */ -#undef CROSS_COMPILE - -/* Some gas code wants to know these parameters. */ -#undef TARGET_ALIAS -#undef TARGET_CPU -#undef TARGET_CANONICAL -#undef TARGET_OS -#undef TARGET_VENDOR - -/* Sometimes the system header files don't declare strstr. */ -#undef NEED_DECLARATION_STRSTR - -/* Sometimes the system header files don't declare malloc and realloc. */ -#undef NEED_DECLARATION_MALLOC - -/* Sometimes the system header files don't declare free. */ -#undef NEED_DECLARATION_FREE - -/* Sometimes the system header files don't declare sbrk. */ -#undef NEED_DECLARATION_SBRK - -/* Sometimes errno.h doesn't declare errno itself. */ -#undef NEED_DECLARATION_ERRNO - -#undef MANY_SEGMENTS - -/* Needed only for sparc configuration. */ -#undef SPARC_V9 -#undef SPARC_ARCH64 - -/* Defined if using CGEN. */ -#undef USING_CGEN - -/* Needed only for some configurations that can produce multiple output - formats. */ -#undef DEFAULT_EMULATION -#undef EMULATIONS -#undef USE_EMULATIONS -#undef OBJ_MAYBE_AOUT -#undef OBJ_MAYBE_BOUT -#undef OBJ_MAYBE_COFF -#undef OBJ_MAYBE_ECOFF -#undef OBJ_MAYBE_ELF -#undef OBJ_MAYBE_GENERIC -#undef OBJ_MAYBE_HP300 -#undef OBJ_MAYBE_IEEE -#undef OBJ_MAYBE_SOM -#undef OBJ_MAYBE_VMS - -/* Used for some of the COFF configurations, when the COFF code needs - to select something based on the CPU type before it knows it... */ -#undef I386COFF -#undef M68KCOFF -#undef M88KCOFF - -/* Define if you have the remove function. */ -#undef HAVE_REMOVE - -/* Define if you have the sbrk function. */ -#undef HAVE_SBRK - -/* Define if you have the unlink function. */ -#undef HAVE_UNLINK - -/* Define if you have the header file. */ -#undef HAVE_ERRNO_H - -/* Define if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define if you have the header file. */ -#undef HAVE_STDARG_H - -/* Define if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define if you have the header file. */ -#undef HAVE_STRING_H - -/* Define if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define if you have the header file. */ -#undef HAVE_VARARGS_H diff --git a/contrib/binutils/gas/config/atof-vax.c b/contrib/binutils/gas/config/atof-vax.c deleted file mode 100644 index 8ba290faca83..000000000000 --- a/contrib/binutils/gas/config/atof-vax.c +++ /dev/null @@ -1,517 +0,0 @@ -/* atof_vax.c - turn a Flonum into a VAX floating point number - Copyright (C) 1987, 1992, 93, 95, 1997 Free Software Foundation, Inc. - - This file is part of GAS, the GNU Assembler. - - GAS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GAS is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GAS; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -#include "as.h" - -static int atof_vax_sizeof PARAMS ((int)); -static int next_bits PARAMS ((int)); -static void make_invalid_floating_point_number PARAMS ((LITTLENUM_TYPE *)); -static int what_kind_of_float PARAMS ((int, int *, long *)); -static char *atof_vax PARAMS ((char *, int, LITTLENUM_TYPE *)); - -/* Precision in LittleNums. */ -#define MAX_PRECISION (8) -#define H_PRECISION (8) -#define G_PRECISION (4) -#define D_PRECISION (4) -#define F_PRECISION (2) - -/* Length in LittleNums of guard bits. */ -#define GUARD (2) - -int flonum_gen2vax PARAMS ((int format_letter, FLONUM_TYPE * f, - LITTLENUM_TYPE * words)); - -/* Number of chars in flonum type 'letter'. */ -static int -atof_vax_sizeof (letter) - int letter; -{ - int return_value; - - /* - * Permitting uppercase letters is probably a bad idea. - * Please use only lower-cased letters in case the upper-cased - * ones become unsupported! - */ - switch (letter) - { - case 'f': - case 'F': - return_value = 4; - break; - - case 'd': - case 'D': - case 'g': - case 'G': - return_value = 8; - break; - - case 'h': - case 'H': - return_value = 16; - break; - - default: - return_value = 0; - break; - } - return (return_value); -} /* atof_vax_sizeof */ - -static const long mask[] = -{ - 0x00000000, - 0x00000001, - 0x00000003, - 0x00000007, - 0x0000000f, - 0x0000001f, - 0x0000003f, - 0x0000007f, - 0x000000ff, - 0x000001ff, - 0x000003ff, - 0x000007ff, - 0x00000fff, - 0x00001fff, - 0x00003fff, - 0x00007fff, - 0x0000ffff, - 0x0001ffff, - 0x0003ffff, - 0x0007ffff, - 0x000fffff, - 0x001fffff, - 0x003fffff, - 0x007fffff, - 0x00ffffff, - 0x01ffffff, - 0x03ffffff, - 0x07ffffff, - 0x0fffffff, - 0x1fffffff, - 0x3fffffff, - 0x7fffffff, - 0xffffffff -}; - - -/* Shared between flonum_gen2vax and next_bits */ -static int bits_left_in_littlenum; -static LITTLENUM_TYPE *littlenum_pointer; -static LITTLENUM_TYPE *littlenum_end; - -static int -next_bits (number_of_bits) - int number_of_bits; -{ - int return_value; - - if (littlenum_pointer < littlenum_end) - return 0; - if (number_of_bits >= bits_left_in_littlenum) - { - return_value = mask[bits_left_in_littlenum] & *littlenum_pointer; - number_of_bits -= bits_left_in_littlenum; - return_value <<= number_of_bits; - bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits; - littlenum_pointer--; - if (littlenum_pointer >= littlenum_end) - return_value |= ((*littlenum_pointer) >> (bits_left_in_littlenum)) & mask[number_of_bits]; - } - else - { - bits_left_in_littlenum -= number_of_bits; - return_value = mask[number_of_bits] & ((*littlenum_pointer) >> bits_left_in_littlenum); - } - return (return_value); -} - -static void -make_invalid_floating_point_number (words) - LITTLENUM_TYPE *words; -{ - *words = 0x8000; /* Floating Reserved Operand Code */ -} - -static int /* 0 means letter is OK. */ -what_kind_of_float (letter, precisionP, exponent_bitsP) - int letter; /* In: lowercase please. What kind of float? */ - int *precisionP; /* Number of 16-bit words in the float. */ - long *exponent_bitsP; /* Number of exponent bits. */ -{ - int retval; /* 0: OK. */ - - retval = 0; - switch (letter) - { - case 'f': - *precisionP = F_PRECISION; - *exponent_bitsP = 8; - break; - - case 'd': - *precisionP = D_PRECISION; - *exponent_bitsP = 8; - break; - - case 'g': - *precisionP = G_PRECISION; - *exponent_bitsP = 11; - break; - - case 'h': - *precisionP = H_PRECISION; - *exponent_bitsP = 15; - break; - - default: - retval = 69; - break; - } - return (retval); -} - -/***********************************************************************\ - * * - * Warning: this returns 16-bit LITTLENUMs, because that is * - * what the VAX thinks in. It is up to the caller to figure * - * out any alignment problems and to conspire for the bytes/word * - * to be emitted in the right order. Bigendians beware! * - * * - \***********************************************************************/ - -static char * /* Return pointer past text consumed. */ -atof_vax (str, what_kind, words) - char *str; /* Text to convert to binary. */ - int what_kind; /* 'd', 'f', 'g', 'h' */ - LITTLENUM_TYPE *words; /* Build the binary here. */ -{ - FLONUM_TYPE f; - LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD]; - /* Extra bits for zeroed low-order bits. */ - /* The 1st MAX_PRECISION are zeroed, */ - /* the last contain flonum bits. */ - char *return_value; - int precision; /* Number of 16-bit words in the format. */ - long exponent_bits; - - return_value = str; - f.low = bits + MAX_PRECISION; - f.high = NULL; - f.leader = NULL; - f.exponent = 0; - f.sign = '\0'; - - if (what_kind_of_float (what_kind, &precision, &exponent_bits)) - { - return_value = NULL; /* We lost. */ - make_invalid_floating_point_number (words); - } - - if (return_value) - { - memset (bits, '\0', sizeof (LITTLENUM_TYPE) * MAX_PRECISION); - - /* Use more LittleNums than seems */ - /* necessary: the highest flonum may have */ - /* 15 leading 0 bits, so could be useless. */ - f.high = f.low + precision - 1 + GUARD; - - if (atof_generic (&return_value, ".", "eE", &f)) - { - make_invalid_floating_point_number (words); - return_value = NULL; /* we lost */ - } - else - { - if (flonum_gen2vax (what_kind, &f, words)) - { - return_value = NULL; - } - } - } - return (return_value); -} /* atof_vax() */ - -/* - * In: a flonum, a vax floating point format. - * Out: a vax floating-point bit pattern. - */ - -int /* 0: OK. */ -flonum_gen2vax (format_letter, f, words) - char format_letter; /* One of 'd' 'f' 'g' 'h'. */ - FLONUM_TYPE *f; - LITTLENUM_TYPE *words; /* Deliver answer here. */ -{ - LITTLENUM_TYPE *lp; - int precision; - long exponent_bits; - int return_value; /* 0 == OK. */ - - return_value = what_kind_of_float (format_letter, &precision, &exponent_bits); - - if (return_value != 0) - { - make_invalid_floating_point_number (words); - } - else - { - if (f->low > f->leader) - { - /* 0.0e0 seen. */ - memset (words, '\0', sizeof (LITTLENUM_TYPE) * precision); - } - else - { - long exponent_1; - long exponent_2; - long exponent_3; - long exponent_4; - int exponent_skippage; - LITTLENUM_TYPE word1; - - /* JF: Deal with new Nan, +Inf and -Inf codes */ - if (f->sign != '-' && f->sign != '+') - { - make_invalid_floating_point_number (words); - return return_value; - } - /* - * All vaxen floating_point formats (so far) have: - * Bit 15 is sign bit. - * Bits 14:n are excess-whatever exponent. - * Bits n-1:0 (if any) are most significant bits of fraction. - * Bits 15:0 of the next word are the next most significant bits. - * And so on for each other word. - * - * All this to be compatible with a KF11?? (Which is still faster - * than lots of vaxen I can think of, but it also has higher - * maintenance costs ... sigh). - * - * So we need: number of bits of exponent, number of bits of - * mantissa. - */ - -#ifdef NEVER /******* This zeroing seems redundant - Dean 3may86 **********/ - /* - * No matter how few bits we got back from the atof() - * routine, add enough zero littlenums so the rest of the - * code won't run out of "significant" bits in the mantissa. - */ - { - LITTLENUM_TYPE *ltp; - for (ltp = f->leader + 1; - ltp <= f->low + precision; - ltp++) - { - *ltp = 0; - } - } -#endif - - bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS; - littlenum_pointer = f->leader; - littlenum_end = f->low; - /* Seek (and forget) 1st significant bit */ - for (exponent_skippage = 0; - !next_bits (1); - exponent_skippage++);; - - exponent_1 = f->exponent + f->leader + 1 - f->low; - /* Radix LITTLENUM_RADIX, point just higher than f->leader. */ - exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS; - /* Radix 2. */ - exponent_3 = exponent_2 - exponent_skippage; - /* Forget leading zeros, forget 1st bit. */ - exponent_4 = exponent_3 + (1 << (exponent_bits - 1)); - /* Offset exponent. */ - - if (exponent_4 & ~mask[exponent_bits]) - { - /* - * Exponent overflow. Lose immediately. - */ - - make_invalid_floating_point_number (words); - - /* - * We leave return_value alone: admit we read the - * number, but return a floating exception - * because we can't encode the number. - */ - } - else - { - lp = words; - - /* Word 1. Sign, exponent and perhaps high bits. */ - /* Assume 2's complement integers. */ - word1 = (((exponent_4 & mask[exponent_bits]) << (15 - exponent_bits)) - | ((f->sign == '+') ? 0 : 0x8000) - | next_bits (15 - exponent_bits)); - *lp++ = word1; - - /* The rest of the words are just mantissa bits. */ - for (; lp < words + precision; lp++) - { - *lp = next_bits (LITTLENUM_NUMBER_OF_BITS); - } - - if (next_bits (1)) - { - /* - * Since the NEXT bit is a 1, round UP the mantissa. - * The cunning design of these hidden-1 floats permits - * us to let the mantissa overflow into the exponent, and - * it 'does the right thing'. However, we lose if the - * highest-order bit of the lowest-order word flips. - * Is that clear? - */ - - unsigned long carry; - - /* - #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2) - Please allow at least 1 more bit in carry than is in a LITTLENUM. - We need that extra bit to hold a carry during a LITTLENUM carry - propagation. Another extra bit (kept 0) will assure us that we - don't get a sticky sign bit after shifting right, and that - permits us to propagate the carry without any masking of bits. - #endif - */ - for (carry = 1, lp--; - carry && (lp >= words); - lp--) - { - carry = *lp + carry; - *lp = carry; - carry >>= LITTLENUM_NUMBER_OF_BITS; - } - - if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1))) - { - make_invalid_floating_point_number (words); - /* - * We leave return_value alone: admit we read the - * number, but return a floating exception - * because we can't encode the number. - */ - } - } /* if (we needed to round up) */ - } /* if (exponent overflow) */ - } /* if (0.0e0) */ - } /* if (float_type was OK) */ - return (return_value); -} /* flonum_gen2vax() */ - - -/* JF this used to be in vax.c but this looks like a better place for it */ - -/* - * md_atof() - * - * In: input_line_pointer->the 1st character of a floating-point - * number. - * 1 letter denoting the type of statement that wants a - * binary floating point number returned. - * Address of where to build floating point literal. - * Assumed to be 'big enough'. - * Address of where to return size of literal (in chars). - * - * Out: Input_line_pointer->of next char after floating number. - * Error message, or 0. - * Floating point literal. - * Number of chars we used for the literal. - */ - -#define MAXIMUM_NUMBER_OF_LITTLENUMS (8) /* For .hfloats. */ - -char * -md_atof (what_statement_type, literalP, sizeP) - int what_statement_type; - char *literalP; - int *sizeP; -{ - LITTLENUM_TYPE words[MAXIMUM_NUMBER_OF_LITTLENUMS]; - register char kind_of_float; - register int number_of_chars; - register LITTLENUM_TYPE *littlenumP; - - switch (what_statement_type) - { - case 'F': /* .float */ - case 'f': /* .ffloat */ - kind_of_float = 'f'; - break; - - case 'D': /* .double */ - case 'd': /* .dfloat */ - kind_of_float = 'd'; - break; - - case 'g': /* .gfloat */ - kind_of_float = 'g'; - break; - - case 'h': /* .hfloat */ - kind_of_float = 'h'; - break; - - default: - kind_of_float = 0; - break; - }; - - if (kind_of_float) - { - register LITTLENUM_TYPE *limit; - - input_line_pointer = atof_vax (input_line_pointer, - kind_of_float, - words); - /* - * The atof_vax() builds up 16-bit numbers. - * Since the assembler may not be running on - * a little-endian machine, be very careful about - * converting words to chars. - */ - number_of_chars = atof_vax_sizeof (kind_of_float); - know (number_of_chars <= MAXIMUM_NUMBER_OF_LITTLENUMS * sizeof (LITTLENUM_TYPE)); - limit = words + (number_of_chars / sizeof (LITTLENUM_TYPE)); - for (littlenumP = words; littlenumP < limit; littlenumP++) - { - md_number_to_chars (literalP, *littlenumP, sizeof (LITTLENUM_TYPE)); - literalP += sizeof (LITTLENUM_TYPE); - }; - } - else - { - number_of_chars = 0; - }; - - *sizeP = number_of_chars; - return kind_of_float ? 0 : "Bad call to md_atof()"; -} - -/* end of atof-vax.c */ diff --git a/contrib/binutils/gas/config/i386coff.mt b/contrib/binutils/gas/config/i386coff.mt deleted file mode 100644 index efda83365181..000000000000 --- a/contrib/binutils/gas/config/i386coff.mt +++ /dev/null @@ -1 +0,0 @@ -TDEFINES=-DI386COFF diff --git a/contrib/binutils/gas/config/sco5.mt b/contrib/binutils/gas/config/sco5.mt deleted file mode 100644 index 8879320c4e1e..000000000000 --- a/contrib/binutils/gas/config/sco5.mt +++ /dev/null @@ -1 +0,0 @@ -TDEFINES=-DSCO_ELF diff --git a/contrib/binutils/gas/config/tc-sh.c b/contrib/binutils/gas/config/tc-sh.c deleted file mode 100644 index eaa6146eea75..000000000000 --- a/contrib/binutils/gas/config/tc-sh.c +++ /dev/null @@ -1,2335 +0,0 @@ -/* tc-sh.c -- Assemble code for the Hitachi Super-H - Copyright (C) 1993, 94, 95, 96, 1997 Free Software Foundation. - - This file is part of GAS, the GNU Assembler. - - GAS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GAS is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GAS; see the file COPYING. If not, write to - the Free Software Foundation, 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - Written By Steve Chamberlain - sac@cygnus.com - */ - -#include -#include "as.h" -#include "bfd.h" -#include "subsegs.h" -#define DEFINE_TABLE -#include "opcodes/sh-opc.h" -#include -const char comment_chars[] = "!"; -const char line_separator_chars[] = ";"; -const char line_comment_chars[] = "!#"; - -static void s_uses PARAMS ((int)); - -static void sh_count_relocs PARAMS ((bfd *, segT, PTR)); -static void sh_frob_section PARAMS ((bfd *, segT, PTR)); - -/* This table describes all the machine specific pseudo-ops the assembler - has to support. The fields are: - pseudo-op name without dot - function to call to execute this pseudo-op - Integer arg to pass to the function - */ - -void cons (); -void s_align_bytes (); -static void s_uacons PARAMS ((int)); - -int shl = 0; - -static void -little (ignore) - int ignore; -{ - shl = 1; - target_big_endian = 0; -} - -const pseudo_typeS md_pseudo_table[] = -{ - {"int", cons, 4}, - {"word", cons, 2}, - {"form", listing_psize, 0}, - {"little", little, 0}, - {"heading", listing_title, 0}, - {"import", s_ignore, 0}, - {"page", listing_eject, 0}, - {"program", s_ignore, 0}, - {"uses", s_uses, 0}, - {"uaword", s_uacons, 2}, - {"ualong", s_uacons, 4}, - {0, 0, 0} -}; - -/*int md_reloc_size; */ - -int sh_relax; /* set if -relax seen */ - -/* Whether -small was seen. */ - -int sh_small; - -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ -const char FLT_CHARS[] = "rRsSfFdDxXpP"; - -#define C(a,b) ENCODE_RELAX(a,b) - -#define JREG 14 /* Register used as a temp when relaxing */ -#define ENCODE_RELAX(what,length) (((what) << 4) + (length)) -#define GET_WHAT(x) ((x>>4)) - -/* These are the two types of relaxable instrction */ -#define COND_JUMP 1 -#define UNCOND_JUMP 2 - -#define UNDEF_DISP 0 -#define COND8 1 -#define COND12 2 -#define COND32 3 -#define UNCOND12 1 -#define UNCOND32 2 -#define UNDEF_WORD_DISP 4 -#define END 5 - -#define UNCOND12 1 -#define UNCOND32 2 - -/* Branch displacements are from the address of the branch plus - four, thus all minimum and maximum values have 4 added to them. */ -#define COND8_F 258 -#define COND8_M -252 -#define COND8_LENGTH 2 - -/* There is one extra instruction before the branch, so we must add - two more bytes to account for it. */ -#define COND12_F 4100 -#define COND12_M -4090 -#define COND12_LENGTH 6 - -/* ??? The minimum and maximum values are wrong, but this does not matter - since this relocation type is not supported yet. */ -#define COND32_F (1<<30) -#define COND32_M -(1<<30) -#define COND32_LENGTH 14 - -#define UNCOND12_F 4098 -#define UNCOND12_M -4092 -#define UNCOND12_LENGTH 2 - -/* ??? The minimum and maximum values are wrong, but this does not matter - since this relocation type is not supported yet. */ -#define UNCOND32_F (1<<30) -#define UNCOND32_M -(1<<30) -#define UNCOND32_LENGTH 14 - -const relax_typeS md_relax_table[C (END, 0)] = { - { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, - { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, - - { 0 }, - /* C (COND_JUMP, COND8) */ - { COND8_F, COND8_M, COND8_LENGTH, C (COND_JUMP, COND12) }, - /* C (COND_JUMP, COND12) */ - { COND12_F, COND12_M, COND12_LENGTH, C (COND_JUMP, COND32), }, - /* C (COND_JUMP, COND32) */ - { COND32_F, COND32_M, COND32_LENGTH, 0, }, - { 0 }, { 0 }, { 0 }, { 0 }, - { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, - - { 0 }, - /* C (UNCOND_JUMP, UNCOND12) */ - { UNCOND12_F, UNCOND12_M, UNCOND12_LENGTH, C (UNCOND_JUMP, UNCOND32), }, - /* C (UNCOND_JUMP, UNCOND32) */ - { UNCOND32_F, UNCOND32_M, UNCOND32_LENGTH, 0, }, - { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, - { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, -}; - -static struct hash_control *opcode_hash_control; /* Opcode mnemonics */ - -/* - This function is called once, at assembler startup time. This should - set up all the tables, etc that the MD part of the assembler needs - */ - -void -md_begin () -{ - sh_opcode_info *opcode; - char *prev_name = ""; - - if (! shl) - target_big_endian = 1; - - opcode_hash_control = hash_new (); - - /* Insert unique names into hash table */ - for (opcode = sh_table; opcode->name; opcode++) - { - if (strcmp (prev_name, opcode->name)) - { - prev_name = opcode->name; - hash_insert (opcode_hash_control, opcode->name, (char *) opcode); - } - else - { - /* Make all the opcodes with the same name point to the same - string */ - opcode->name = prev_name; - } - } -} - -static int reg_m; -static int reg_n; -static int reg_b; - -static expressionS immediate; /* absolute expression */ - -typedef struct - { - sh_arg_type type; - int reg; - } - -sh_operand_info; - -/* try and parse a reg name, returns number of chars consumed */ -static int -parse_reg (src, mode, reg) - char *src; - int *mode; - int *reg; -{ - /* We use !isalnum for the next character after the register name, to - make sure that we won't accidentally recognize a symbol name such as - 'sram' as being a reference to the register 'sr'. */ - - if (src[0] == 'r') - { - if (src[1] >= '0' && src[1] <= '7' && strncmp(&src[2], "_bank", 5) == 0 - && ! isalnum (src[7])) - { - *mode = A_REG_B; - *reg = (src[1] - '0'); - return 7; - } - } - - if (src[0] == 'r') - { - if (src[1] == '1') - { - if (src[2] >= '0' && src[2] <= '5' && ! isalnum (src[3])) - { - *mode = A_REG_N; - *reg = 10 + src[2] - '0'; - return 3; - } - } - if (src[1] >= '0' && src[1] <= '9' && ! isalnum (src[2])) - { - *mode = A_REG_N; - *reg = (src[1] - '0'); - return 2; - } - } - - if (src[0] == 's' && src[1] == 's' && src[2] == 'r' && ! isalnum (src[3])) - { - *mode = A_SSR; - return 3; - } - - if (src[0] == 's' && src[1] == 'p' && src[2] == 'c' && ! isalnum (src[3])) - { - *mode = A_SPC; - return 3; - } - - if (src[0] == 's' && src[1] == 'g' && src[2] == 'r' && ! isalnum (src[3])) - { - *mode = A_SGR; - return 3; - } - - if (src[0] == 'd' && src[1] == 'b' && src[2] == 'r' && ! isalnum (src[3])) - { - *mode = A_DBR; - return 3; - } - - if (src[0] == 's' && src[1] == 'r' && ! isalnum (src[2])) - { - *mode = A_SR; - return 2; - } - - if (src[0] == 's' && src[1] == 'p' && ! isalnum (src[2])) - { - *mode = A_REG_N; - *reg = 15; - return 2; - } - - if (src[0] == 'p' && src[1] == 'r' && ! isalnum (src[2])) - { - *mode = A_PR; - return 2; - } - if (src[0] == 'p' && src[1] == 'c' && ! isalnum (src[2])) - { - *mode = A_DISP_PC; - return 2; - } - if (src[0] == 'g' && src[1] == 'b' && src[2] == 'r' && ! isalnum (src[3])) - { - *mode = A_GBR; - return 3; - } - if (src[0] == 'v' && src[1] == 'b' && src[2] == 'r' && ! isalnum (src[3])) - { - *mode = A_VBR; - return 3; - } - - if (src[0] == 'm' && src[1] == 'a' && src[2] == 'c' && ! isalnum (src[4])) - { - if (src[3] == 'l') - { - *mode = A_MACL; - return 4; - } - if (src[3] == 'h') - { - *mode = A_MACH; - return 4; - } - } - if (src[0] == 'f' && src[1] == 'r') - { - if (src[2] == '1') - { - if (src[3] >= '0' && src[3] <= '5' && ! isalnum (src[4])) - { - *mode = F_REG_N; - *reg = 10 + src[3] - '0'; - return 4; - } - } - if (src[2] >= '0' && src[2] <= '9' && ! isalnum (src[3])) - { - *mode = F_REG_N; - *reg = (src[2] - '0'); - return 3; - } - } - if (src[0] == 'd' && src[1] == 'r') - { - if (src[2] == '1') - { - if (src[3] >= '0' && src[3] <= '4' && ! ((src[3] - '0') & 1) - && ! isalnum (src[4])) - { - *mode = D_REG_N; - *reg = 10 + src[3] - '0'; - return 4; - } - } - if (src[2] >= '0' && src[2] <= '8' && ! ((src[2] - '0') & 1) - && ! isalnum (src[3])) - { - *mode = D_REG_N; - *reg = (src[2] - '0'); - return 3; - } - } - if (src[0] == 'x' && src[1] == 'd') - { - if (src[2] == '1') - { - if (src[3] >= '0' && src[3] <= '4' && ! ((src[3] - '0') & 1) - && ! isalnum (src[4])) - { - *mode = X_REG_N; - *reg = 11 + src[3] - '0'; - return 4; - } - } - if (src[2] >= '0' && src[2] <= '8' && ! ((src[2] - '0') & 1) - && ! isalnum (src[3])) - { - *mode = X_REG_N; - *reg = (src[2] - '0') + 1; - return 3; - } - } - if (src[0] == 'f' && src[1] == 'v') - { - if (src[2] == '1'&& src[3] == '2' && ! isalnum (src[4])) - { - *mode = V_REG_N; - *reg = 12; - return 4; - } - if ((src[2] == '0' || src[2] == '4' || src[2] == '8') && ! isalnum (src[3])) - { - *mode = V_REG_N; - *reg = (src[2] - '0'); - return 3; - } - } - if (src[0] == 'f' && src[1] == 'p' && src[2] == 'u' && src[3] == 'l' - && ! isalnum (src[4])) - { - *mode = FPUL_N; - return 4; - } - - if (src[0] == 'f' && src[1] == 'p' && src[2] == 's' && src[3] == 'c' - && src[4] == 'r' && ! isalnum (src[5])) - { - *mode = FPSCR_N; - return 5; - } - - if (src[0] == 'x' && src[1] == 'm' && src[2] == 't' && src[3] == 'r' - && src[4] == 'x' && ! isalnum (src[5])) - { - *mode = XMTRX_M4; - return 5; - } - - return 0; -} - -static symbolS *dot() -{ - const char *fake; - - /* JF: '.' is pseudo symbol with value of current location - in current segment. */ - fake = FAKE_LABEL_NAME; - return symbol_new (fake, - now_seg, - (valueT) frag_now_fix (), - frag_now); - -} - - -static -char * -parse_exp (s) - char *s; -{ - char *save; - char *new; - - save = input_line_pointer; - input_line_pointer = s; - expression (&immediate); - if (immediate.X_op == O_absent) - as_bad ("missing operand"); - new = input_line_pointer; - input_line_pointer = save; - return new; -} - - -/* The many forms of operand: - - Rn Register direct - @Rn Register indirect - @Rn+ Autoincrement - @-Rn Autodecrement - @(disp:4,Rn) - @(disp:8,GBR) - @(disp:8,PC) - - @(R0,Rn) - @(R0,GBR) - - disp:8 - disp:12 - #imm8 - pr, gbr, vbr, macl, mach - - */ - -static -char * -parse_at (src, op) - char *src; - sh_operand_info *op; -{ - int len; - int mode; - src++; - if (src[0] == '-') - { - /* Must be predecrement */ - src++; - - len = parse_reg (src, &mode, &(op->reg)); - if (mode != A_REG_N) - as_bad ("illegal register after @-"); - - op->type = A_DEC_N; - src += len; - } - else if (src[0] == '(') - { - /* Could be @(disp, rn), @(disp, gbr), @(disp, pc), @(r0, gbr) or - @(r0, rn) */ - src++; - len = parse_reg (src, &mode, &(op->reg)); - if (len && mode == A_REG_N) - { - src += len; - if (op->reg != 0) - { - as_bad ("must be @(r0,...)"); - } - if (src[0] == ',') - src++; - /* Now can be rn or gbr */ - len = parse_reg (src, &mode, &(op->reg)); - if (mode == A_GBR) - { - op->type = A_R0_GBR; - } - else if (mode == A_REG_N) - { - op->type = A_IND_R0_REG_N; - } - else - { - as_bad ("syntax error in @(r0,...)"); - } - } - else - { - /* Must be an @(disp,.. thing) */ - src = parse_exp (src); - if (src[0] == ',') - src++; - /* Now can be rn, gbr or pc */ - len = parse_reg (src, &mode, &op->reg); - if (len) - { - if (mode == A_REG_N) - { - op->type = A_DISP_REG_N; - } - else if (mode == A_GBR) - { - op->type = A_DISP_GBR; - } - else if (mode == A_DISP_PC) - { - /* Turn a plain @(4,pc) into @(.+4,pc) */ - if (immediate.X_op == O_constant) { - immediate.X_add_symbol = dot(); - immediate.X_op = O_symbol; - } - op->type = A_DISP_PC; - } - else - { - as_bad ("syntax error in @(disp,[Rn, gbr, pc])"); - } - } - else - { - as_bad ("syntax error in @(disp,[Rn, gbr, pc])"); - } - } - src += len; - if (src[0] != ')') - as_bad ("expecting )"); - else - src++; - } - else - { - src += parse_reg (src, &mode, &(op->reg)); - if (mode != A_REG_N) - { - as_bad ("illegal register after @"); - } - if (src[0] == '+') - { - op->type = A_INC_N; - src++; - } - else - { - op->type = A_IND_N; - } - } - return src; -} - -static void -get_operand (ptr, op) - char **ptr; - sh_operand_info *op; -{ - char *src = *ptr; - int mode = -1; - unsigned int len; - - if (src[0] == '#') - { - src++; - *ptr = parse_exp (src); - op->type = A_IMM; - return; - } - - else if (src[0] == '@') - { - *ptr = parse_at (src, op); - return; - } - len = parse_reg (src, &mode, &(op->reg)); - if (len) - { - *ptr = src + len; - op->type = mode; - return; - } - else - { - /* Not a reg, the only thing left is a displacement */ - *ptr = parse_exp (src); - op->type = A_DISP_PC; - return; - } -} - -static -char * -get_operands (info, args, operand) - sh_opcode_info *info; - char *args; - sh_operand_info *operand; - -{ - char *ptr = args; - if (info->arg[0]) - { - ptr++; - - get_operand (&ptr, operand + 0); - if (info->arg[1]) - { - if (*ptr == ',') - { - ptr++; - } - get_operand (&ptr, operand + 1); - if (info->arg[2]) - { - if (*ptr == ',') - { - ptr++; - } - get_operand (&ptr, operand + 2); - } - else - { - operand[2].type = 0; - } - } - else - { - operand[1].type = 0; - operand[2].type = 0; - } - } - else - { - operand[0].type = 0; - operand[1].type = 0; - operand[2].type = 0; - } - return ptr; -} - -/* Passed a pointer to a list of opcodes which use different - addressing modes, return the opcode which matches the opcodes - provided - */ - -static -sh_opcode_info * -get_specific (opcode, operands) - sh_opcode_info *opcode; - sh_operand_info *operands; -{ - sh_opcode_info *this_try = opcode; - char *name = opcode->name; - int n = 0; - while (opcode->name) - { - this_try = opcode++; - if (this_try->name != name) - { - /* We've looked so far down the table that we've run out of - opcodes with the same name */ - return 0; - } - /* look at both operands needed by the opcodes and provided by - the user - since an arg test will often fail on the same arg - again and again, we'll try and test the last failing arg the - first on each opcode try */ - - for (n = 0; this_try->arg[n]; n++) - { - sh_operand_info *user = operands + n; - sh_arg_type arg = this_try->arg[n]; - switch (arg) - { - case A_IMM: - case A_BDISP12: - case A_BDISP8: - case A_DISP_GBR: - case A_DISP_PC: - case A_MACH: - case A_PR: - case A_MACL: - if (user->type != arg) - goto fail; - break; - case A_R0: - /* opcode needs r0 */ - if (user->type != A_REG_N || user->reg != 0) - goto fail; - break; - case A_R0_GBR: - if (user->type != A_R0_GBR || user->reg != 0) - goto fail; - break; - case F_FR0: - if (user->type != F_REG_N || user->reg != 0) - goto fail; - break; - - case A_REG_N: - case A_INC_N: - case A_DEC_N: - case A_IND_N: - case A_IND_R0_REG_N: - case A_DISP_REG_N: - case F_REG_N: - case D_REG_N: - case X_REG_N: - case V_REG_N: - case FPUL_N: - case FPSCR_N: - /* Opcode needs rn */ - if (user->type != arg) - goto fail; - reg_n = user->reg; - break; - case FD_REG_N: - if (user->type != F_REG_N && user->type != D_REG_N) - goto fail; - reg_n = user->reg; - break; - case DX_REG_N: - if (user->type != D_REG_N && user->type != X_REG_N) - goto fail; - reg_n = user->reg; - break; - case A_GBR: - case A_SR: - case A_VBR: - case A_SSR: - case A_SPC: - case A_SGR: - case A_DBR: - if (user->type != arg) - goto fail; - break; - - case A_REG_B: - if (user->type != arg) - goto fail; - reg_b = user->reg; - break; - - case A_REG_M: - case A_INC_M: - case A_DEC_M: - case A_IND_M: - case A_IND_R0_REG_M: - case A_DISP_REG_M: - /* Opcode needs rn */ - if (user->type != arg - A_REG_M + A_REG_N) - goto fail; - reg_m = user->reg; - break; - - case F_REG_M: - case D_REG_M: - case X_REG_M: - case V_REG_M: - case FPUL_M: - case FPSCR_M: - /* Opcode needs rn */ - if (user->type != arg - F_REG_M + F_REG_N) - goto fail; - reg_m = user->reg; - break; - case DX_REG_M: - if (user->type != D_REG_N && user->type != X_REG_N) - goto fail; - reg_m = user->reg; - break; - case XMTRX_M4: - if (user->type != XMTRX_M4) - goto fail; - reg_m = 4; - break; - - default: - printf ("unhandled %d\n", arg); - goto fail; - } - } - return this_try; - fail:; - } - - return 0; -} - -int -check (operand, low, high) - expressionS *operand; - int low; - int high; -{ - if (operand->X_op != O_constant - || operand->X_add_number < low - || operand->X_add_number > high) - { - as_bad ("operand must be absolute in range %d..%d", low, high); - } - return operand->X_add_number; -} - - -static void -insert (where, how, pcrel) - char *where; - int how; - int pcrel; -{ - fix_new_exp (frag_now, - where - frag_now->fr_literal, - 2, - &immediate, - pcrel, - how); -} - -static void -build_relax (opcode) - sh_opcode_info *opcode; -{ - int high_byte = target_big_endian ? 0 : 1; - char *p; - - if (opcode->arg[0] == A_BDISP8) - { - p = frag_var (rs_machine_dependent, - md_relax_table[C (COND_JUMP, COND32)].rlx_length, - md_relax_table[C (COND_JUMP, COND8)].rlx_length, - C (COND_JUMP, 0), - immediate.X_add_symbol, - immediate.X_add_number, - 0); - p[high_byte] = (opcode->nibbles[0] << 4) | (opcode->nibbles[1]); - } - else if (opcode->arg[0] == A_BDISP12) - { - p = frag_var (rs_machine_dependent, - md_relax_table[C (UNCOND_JUMP, UNCOND32)].rlx_length, - md_relax_table[C (UNCOND_JUMP, UNCOND12)].rlx_length, - C (UNCOND_JUMP, 0), - immediate.X_add_symbol, - immediate.X_add_number, - 0); - p[high_byte] = (opcode->nibbles[0] << 4); - } - -} - -/* Now we know what sort of opcodes it is, lets build the bytes - - */ -static void -build_Mytes (opcode, operand) - sh_opcode_info *opcode; - sh_operand_info *operand; - -{ - int index; - char nbuf[4]; - char *output = frag_more (2); - int low_byte = target_big_endian ? 1 : 0; - nbuf[0] = 0; - nbuf[1] = 0; - nbuf[2] = 0; - nbuf[3] = 0; - - for (index = 0; index < 4; index++) - { - sh_nibble_type i = opcode->nibbles[index]; - if (i < 16) - { - nbuf[index] = i; - } - else - { - switch (i) - { - case REG_N: - nbuf[index] = reg_n; - break; - case REG_M: - nbuf[index] = reg_m; - break; - case REG_NM: - nbuf[index] = reg_n | (reg_m >> 2); - break; - case REG_B: - nbuf[index] = reg_b | 0x08; - break; - case DISP_4: - insert (output + low_byte, BFD_RELOC_SH_IMM4, 0); - break; - case IMM_4BY4: - insert (output + low_byte, BFD_RELOC_SH_IMM4BY4, 0); - break; - case IMM_4BY2: - insert (output + low_byte, BFD_RELOC_SH_IMM4BY2, 0); - break; - case IMM_4: - insert (output + low_byte, BFD_RELOC_SH_IMM4, 0); - break; - case IMM_8BY4: - insert (output + low_byte, BFD_RELOC_SH_IMM8BY4, 0); - break; - case IMM_8BY2: - insert (output + low_byte, BFD_RELOC_SH_IMM8BY2, 0); - break; - case IMM_8: - insert (output + low_byte, BFD_RELOC_SH_IMM8, 0); - break; - case PCRELIMM_8BY4: - insert (output, BFD_RELOC_SH_PCRELIMM8BY4, 1); - break; - case PCRELIMM_8BY2: - insert (output, BFD_RELOC_SH_PCRELIMM8BY2, 1); - break; - default: - printf ("failed for %d\n", i); - } - } - } - if (! target_big_endian) { - output[1] = (nbuf[0] << 4) | (nbuf[1]); - output[0] = (nbuf[2] << 4) | (nbuf[3]); - } - else { - output[0] = (nbuf[0] << 4) | (nbuf[1]); - output[1] = (nbuf[2] << 4) | (nbuf[3]); - } -} - -/* This is the guts of the machine-dependent assembler. STR points to a - machine dependent instruction. This function is supposed to emit - the frags/bytes it assembles to. - */ - -void -md_assemble (str) - char *str; -{ - unsigned char *op_start; - unsigned char *op_end; - sh_operand_info operand[3]; - sh_opcode_info *opcode; - char name[20]; - int nlen = 0; - /* Drop leading whitespace */ - while (*str == ' ') - str++; - - /* find the op code end */ - for (op_start = op_end = (unsigned char *) (str); - *op_end - && nlen < 20 - && !is_end_of_line[*op_end] && *op_end != ' '; - op_end++) - { - name[nlen] = op_start[nlen]; - nlen++; - } - name[nlen] = 0; - - if (nlen == 0) - { - as_bad ("can't find opcode "); - } - - opcode = (sh_opcode_info *) hash_find (opcode_hash_control, name); - - if (opcode == NULL) - { - as_bad ("unknown opcode"); - return; - } - - if (sh_relax - && ! seg_info (now_seg)->tc_segment_info_data.in_code) - { - /* Output a CODE reloc to tell the linker that the following - bytes are instructions, not data. */ - fix_new (frag_now, frag_now_fix (), 2, &abs_symbol, 0, 0, - BFD_RELOC_SH_CODE); - seg_info (now_seg)->tc_segment_info_data.in_code = 1; - } - - if (opcode->arg[0] == A_BDISP12 - || opcode->arg[0] == A_BDISP8) - { - parse_exp (op_end + 1); - build_relax (opcode); - } - else - { - if (opcode->arg[0] != A_END) - { - get_operands (opcode, op_end, operand); - } - opcode = get_specific (opcode, operand); - - if (opcode == 0) - { - /* Couldn't find an opcode which matched the operands */ - char *where = frag_more (2); - - where[0] = 0x0; - where[1] = 0x0; - as_bad ("invalid operands for opcode"); - return; - } - - build_Mytes (opcode, operand); - } - -} - -/* This routine is called each time a label definition is seen. It - emits a BFD_RELOC_SH_LABEL reloc if necessary. */ - -void -sh_frob_label () -{ - static fragS *last_label_frag; - static int last_label_offset; - - if (sh_relax - && seg_info (now_seg)->tc_segment_info_data.in_code) - { - int offset; - - offset = frag_now_fix (); - if (frag_now != last_label_frag - || offset != last_label_offset) - { - fix_new (frag_now, offset, 2, &abs_symbol, 0, 0, BFD_RELOC_SH_LABEL); - last_label_frag = frag_now; - last_label_offset = offset; - } - } -} - -/* This routine is called when the assembler is about to output some - data. It emits a BFD_RELOC_SH_DATA reloc if necessary. */ - -void -sh_flush_pending_output () -{ - if (sh_relax - && seg_info (now_seg)->tc_segment_info_data.in_code) - { - fix_new (frag_now, frag_now_fix (), 2, &abs_symbol, 0, 0, - BFD_RELOC_SH_DATA); - seg_info (now_seg)->tc_segment_info_data.in_code = 0; - } -} - -symbolS * -DEFUN (md_undefined_symbol, (name), - char *name) -{ - return 0; -} - -#ifdef OBJ_COFF - -void -DEFUN (tc_crawl_symbol_chain, (headers), - object_headers * headers) -{ - printf ("call to tc_crawl_symbol_chain \n"); -} - -void -DEFUN (tc_headers_hook, (headers), - object_headers * headers) -{ - printf ("call to tc_headers_hook \n"); -} - -#endif - -/* Various routines to kill one day */ -/* Equal to MAX_PRECISION in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -/* Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. - */ -char * -md_atof (type, litP, sizeP) - int type; - char *litP; - int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[4]; - char *t; - int i; - - switch (type) - { - case 'f': - prec = 2; - break; - - case 'd': - prec = 4; - break; - - default: - *sizeP = 0; - return "bad call to md_atof"; - } - - t = atof_ieee (input_line_pointer, type, words); - if (t) - input_line_pointer = t; - - *sizeP = prec * 2; - - if (! target_big_endian) - { - for (i = prec - 1; i >= 0; i--) - { - md_number_to_chars (litP, (valueT) words[i], 2); - litP += 2; - } - } - else - { - for (i = 0; i < prec; i++) - { - md_number_to_chars (litP, (valueT) words[i], 2); - litP += 2; - } - } - - return NULL; -} - -/* Handle the .uses pseudo-op. This pseudo-op is used just before a - call instruction. It refers to a label of the instruction which - loads the register which the call uses. We use it to generate a - special reloc for the linker. */ - -static void -s_uses (ignore) - int ignore; -{ - expressionS ex; - - if (! sh_relax) - as_warn (".uses pseudo-op seen when not relaxing"); - - expression (&ex); - - if (ex.X_op != O_symbol || ex.X_add_number != 0) - { - as_bad ("bad .uses format"); - ignore_rest_of_line (); - return; - } - - fix_new_exp (frag_now, frag_now_fix (), 2, &ex, 1, BFD_RELOC_SH_USES); - - demand_empty_rest_of_line (); -} - -CONST char *md_shortopts = ""; -struct option md_longopts[] = { - -#define OPTION_RELAX (OPTION_MD_BASE) -#define OPTION_LITTLE (OPTION_MD_BASE + 1) -#define OPTION_SMALL (OPTION_LITTLE + 1) - - {"relax", no_argument, NULL, OPTION_RELAX}, - {"little", no_argument, NULL, OPTION_LITTLE}, - {"small", no_argument, NULL, OPTION_SMALL}, - {NULL, no_argument, NULL, 0} -}; -size_t md_longopts_size = sizeof(md_longopts); - -int -md_parse_option (c, arg) - int c; - char *arg; -{ - switch (c) - { - case OPTION_RELAX: - sh_relax = 1; - break; - - case OPTION_LITTLE: - shl = 1; - target_big_endian = 0; - break; - - case OPTION_SMALL: - sh_small = 1; - break; - - default: - return 0; - } - - return 1; -} - -void -md_show_usage (stream) - FILE *stream; -{ - fprintf(stream, "\ -SH options:\n\ --little generate little endian code\n\ --relax alter jump instructions for long displacements\n\ --small align sections to 4 byte boundaries, not 16\n"); -} - -int md_short_jump_size; - -void -tc_Nout_fix_to_chars () -{ - printf ("call to tc_Nout_fix_to_chars \n"); - abort (); -} - -void -md_create_short_jump (ptr, from_Nddr, to_Nddr, frag, to_symbol) - char *ptr; - addressT from_Nddr; - addressT to_Nddr; - fragS *frag; - symbolS *to_symbol; -{ - as_fatal ("failed sanity check."); -} - -void -md_create_long_jump (ptr, from_Nddr, to_Nddr, frag, to_symbol) - char *ptr; - addressT from_Nddr, to_Nddr; - fragS *frag; - symbolS *to_symbol; -{ - as_fatal ("failed sanity check."); -} - -/* This struct is used to pass arguments to sh_count_relocs through - bfd_map_over_sections. */ - -struct sh_count_relocs -{ - /* Symbol we are looking for. */ - symbolS *sym; - /* Count of relocs found. */ - int count; -}; - -/* Count the number of fixups in a section which refer to a particular - symbol. When using BFD_ASSEMBLER, this is called via - bfd_map_over_sections. */ - -/*ARGSUSED*/ -static void -sh_count_relocs (abfd, sec, data) - bfd *abfd; - segT sec; - PTR data; -{ - struct sh_count_relocs *info = (struct sh_count_relocs *) data; - segment_info_type *seginfo; - symbolS *sym; - fixS *fix; - - seginfo = seg_info (sec); - if (seginfo == NULL) - return; - - sym = info->sym; - for (fix = seginfo->fix_root; fix != NULL; fix = fix->fx_next) - { - if (fix->fx_addsy == sym) - { - ++info->count; - fix->fx_tcbit = 1; - } - } -} - -/* Handle the count relocs for a particular section. When using - BFD_ASSEMBLER, this is called via bfd_map_over_sections. */ - -/*ARGSUSED*/ -static void -sh_frob_section (abfd, sec, ignore) - bfd *abfd; - segT sec; - PTR ignore; -{ - segment_info_type *seginfo; - fixS *fix; - - seginfo = seg_info (sec); - if (seginfo == NULL) - return; - - for (fix = seginfo->fix_root; fix != NULL; fix = fix->fx_next) - { - symbolS *sym; - bfd_vma val; - fixS *fscan; - struct sh_count_relocs info; - - if (fix->fx_r_type != BFD_RELOC_SH_USES) - continue; - - /* The BFD_RELOC_SH_USES reloc should refer to a defined local - symbol in the same section. */ - sym = fix->fx_addsy; - if (sym == NULL - || fix->fx_subsy != NULL - || fix->fx_addnumber != 0 - || S_GET_SEGMENT (sym) != sec -#if ! defined (BFD_ASSEMBLER) && defined (OBJ_COFF) - || S_GET_STORAGE_CLASS (sym) == C_EXT -#endif - || S_IS_EXTERNAL (sym)) - { - as_warn_where (fix->fx_file, fix->fx_line, - ".uses does not refer to a local symbol in the same section"); - continue; - } - - /* Look through the fixups again, this time looking for one - at the same location as sym. */ - val = S_GET_VALUE (sym); - for (fscan = seginfo->fix_root; - fscan != NULL; - fscan = fscan->fx_next) - if (val == fscan->fx_frag->fr_address + fscan->fx_where - && fscan->fx_r_type != BFD_RELOC_SH_ALIGN - && fscan->fx_r_type != BFD_RELOC_SH_CODE - && fscan->fx_r_type != BFD_RELOC_SH_DATA - && fscan->fx_r_type != BFD_RELOC_SH_LABEL) - break; - if (fscan == NULL) - { - as_warn_where (fix->fx_file, fix->fx_line, - "can't find fixup pointed to by .uses"); - continue; - } - - if (fscan->fx_tcbit) - { - /* We've already done this one. */ - continue; - } - - /* fscan should also be a fixup to a local symbol in the same - section. */ - sym = fscan->fx_addsy; - if (sym == NULL - || fscan->fx_subsy != NULL - || fscan->fx_addnumber != 0 - || S_GET_SEGMENT (sym) != sec -#if ! defined (BFD_ASSEMBLER) && defined (OBJ_COFF) - || S_GET_STORAGE_CLASS (sym) == C_EXT -#endif - || S_IS_EXTERNAL (sym)) - { - as_warn_where (fix->fx_file, fix->fx_line, - ".uses target does not refer to a local symbol in the same section"); - continue; - } - - /* Now we look through all the fixups of all the sections, - counting the number of times we find a reference to sym. */ - info.sym = sym; - info.count = 0; -#ifdef BFD_ASSEMBLER - bfd_map_over_sections (stdoutput, sh_count_relocs, (PTR) &info); -#else - { - int iscan; - - for (iscan = SEG_E0; iscan < SEG_UNKNOWN; iscan++) - sh_count_relocs ((bfd *) NULL, iscan, (PTR) &info); - } -#endif - - if (info.count < 1) - abort (); - - /* Generate a BFD_RELOC_SH_COUNT fixup at the location of sym. - We have already adjusted the value of sym to include the - fragment address, so we undo that adjustment here. */ - subseg_change (sec, 0); - fix_new (sym->sy_frag, S_GET_VALUE (sym) - sym->sy_frag->fr_address, - 4, &abs_symbol, info.count, 0, BFD_RELOC_SH_COUNT); - } -} - -/* This function is called after the symbol table has been completed, - but before the relocs or section contents have been written out. - If we have seen any .uses pseudo-ops, they point to an instruction - which loads a register with the address of a function. We look - through the fixups to find where the function address is being - loaded from. We then generate a COUNT reloc giving the number of - times that function address is referred to. The linker uses this - information when doing relaxing, to decide when it can eliminate - the stored function address entirely. */ - -void -sh_frob_file () -{ - if (! sh_relax) - return; - -#ifdef BFD_ASSEMBLER - bfd_map_over_sections (stdoutput, sh_frob_section, (PTR) NULL); -#else - { - int iseg; - - for (iseg = SEG_E0; iseg < SEG_UNKNOWN; iseg++) - sh_frob_section ((bfd *) NULL, iseg, (PTR) NULL); - } -#endif -} - -/* Called after relaxing. Set the correct sizes of the fragments, and - create relocs so that md_apply_fix will fill in the correct values. */ - -void -md_convert_frag (headers, seg, fragP) -#ifdef BFD_ASSEMBLER - bfd *headers; -#else - object_headers *headers; -#endif - segT seg; - fragS *fragP; -{ - int donerelax = 0; - - switch (fragP->fr_subtype) - { - case C (COND_JUMP, COND8): - subseg_change (seg, 0); - fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset, - 1, BFD_RELOC_SH_PCDISP8BY2); - fragP->fr_fix += 2; - fragP->fr_var = 0; - break; - - case C (UNCOND_JUMP, UNCOND12): - subseg_change (seg, 0); - fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset, - 1, BFD_RELOC_SH_PCDISP12BY2); - fragP->fr_fix += 2; - fragP->fr_var = 0; - break; - - case C (UNCOND_JUMP, UNCOND32): - case C (UNCOND_JUMP, UNDEF_WORD_DISP): - if (fragP->fr_symbol == NULL) - as_bad ("at 0x%lx, displacement overflows 12-bit field", - (unsigned long) fragP->fr_address); - else - as_bad ("at 0x%lx, displacement to %sdefined symbol %s overflows 12-bit field", - (unsigned long) fragP->fr_address, - S_IS_DEFINED (fragP->fr_symbol) ? "" : "un", - S_GET_NAME (fragP->fr_symbol)); - -#if 0 /* This code works, but generates poor code and the compiler - should never produce a sequence that requires it to be used. */ - - /* A jump wont fit in 12 bits, make code which looks like - bra foo - mov.w @(0, PC), r14 - .long disp - foo: bra @r14 - */ - int t = buffer[0] & 0x10; - - buffer[highbyte] = 0xa0; /* branch over move and disp */ - buffer[lowbyte] = 3; - buffer[highbyte+2] = 0xd0 | JREG; /* Build mov insn */ - buffer[lowbyte+2] = 0x00; - - buffer[highbyte+4] = 0; /* space for 32 bit jump disp */ - buffer[lowbyte+4] = 0; - buffer[highbyte+6] = 0; - buffer[lowbyte+6] = 0; - - buffer[highbyte+8] = 0x40 | JREG; /* Build jmp @JREG */ - buffer[lowbyte+8] = t ? 0xb : 0x2b; - - buffer[highbyte+10] = 0x20; /* build nop */ - buffer[lowbyte+10] = 0x0b; - - /* Make reloc for the long disp */ - fix_new (fragP, - fragP->fr_fix + 4, - 4, - fragP->fr_symbol, - fragP->fr_offset, - 0, - BFD_RELOC_32); - fragP->fr_fix += UNCOND32_LENGTH; - fragP->fr_var = 0; - donerelax = 1; -#endif - - break; - - case C (COND_JUMP, COND12): - /* A bcond won't fit, so turn it into a b!cond; bra disp; nop */ - { - unsigned char *buffer = - (unsigned char *) (fragP->fr_fix + fragP->fr_literal); - int highbyte = target_big_endian ? 0 : 1; - int lowbyte = target_big_endian ? 1 : 0; - - /* Toggle the true/false bit of the bcond. */ - buffer[highbyte] ^= 0x2; - - /* Build a relocation to six bytes farther on. */ - subseg_change (seg, 0); - fix_new (fragP, fragP->fr_fix, 2, -#ifdef BFD_ASSEMBLER - section_symbol (seg), -#else - seg_info (seg)->dot, -#endif - fragP->fr_address + fragP->fr_fix + 6, - 1, BFD_RELOC_SH_PCDISP8BY2); - - /* Set up a jump instruction. */ - buffer[highbyte + 2] = 0xa0; - buffer[lowbyte + 2] = 0; - fix_new (fragP, fragP->fr_fix + 2, 2, fragP->fr_symbol, - fragP->fr_offset, 1, BFD_RELOC_SH_PCDISP12BY2); - - /* Fill in a NOP instruction. */ - buffer[highbyte + 4] = 0x0; - buffer[lowbyte + 4] = 0x9; - - fragP->fr_fix += 6; - fragP->fr_var = 0; - donerelax = 1; - } - break; - - case C (COND_JUMP, COND32): - case C (COND_JUMP, UNDEF_WORD_DISP): - if (fragP->fr_symbol == NULL) - as_bad ("at 0x%lx, displacement overflows 8-bit field", - (unsigned long) fragP->fr_address); - else - as_bad ("at 0x%lx, displacement to %sdefined symbol %s overflows 8-bit field ", - (unsigned long) fragP->fr_address, - S_IS_DEFINED (fragP->fr_symbol) ? "" : "un", - S_GET_NAME (fragP->fr_symbol)); - -#if 0 /* This code works, but generates poor code, and the compiler - should never produce a sequence that requires it to be used. */ - - /* A bcond won't fit and it won't go into a 12 bit - displacement either, the code sequence looks like: - b!cond foop - mov.w @(n, PC), r14 - jmp @r14 - nop - .long where - foop: - */ - - buffer[0] ^= 0x2; /* Toggle T/F bit */ -#define JREG 14 - buffer[1] = 5; /* branch over mov, jump, nop and ptr */ - buffer[2] = 0xd0 | JREG; /* Build mov insn */ - buffer[3] = 0x2; - buffer[4] = 0x40 | JREG; /* Build jmp @JREG */ - buffer[5] = 0x0b; - buffer[6] = 0x20; /* build nop */ - buffer[7] = 0x0b; - buffer[8] = 0; /* space for 32 bit jump disp */ - buffer[9] = 0; - buffer[10] = 0; - buffer[11] = 0; - buffer[12] = 0; - buffer[13] = 0; - /* Make reloc for the long disp */ - fix_new (fragP, - fragP->fr_fix + 8, - 4, - fragP->fr_symbol, - fragP->fr_offset, - 0, - BFD_RELOC_32); - fragP->fr_fix += COND32_LENGTH; - fragP->fr_var = 0; - donerelax = 1; -#endif - - break; - - default: - abort (); - } - - if (donerelax && !sh_relax) - as_warn_where (fragP->fr_file, fragP->fr_line, - "overflow in branch to %s; converted into longer instruction sequence", - (fragP->fr_symbol != NULL - ? S_GET_NAME (fragP->fr_symbol) - : "")); -} - -valueT -DEFUN (md_section_align, (seg, size), - segT seg AND - valueT size) -{ -#ifdef BFD_ASSEMBLER -#ifdef OBJ_ELF - return size; -#else /* ! OBJ_ELF */ - return ((size + (1 << bfd_get_section_alignment (stdoutput, seg)) - 1) - & (-1 << bfd_get_section_alignment (stdoutput, seg))); -#endif /* ! OBJ_ELF */ -#else /* ! BFD_ASSEMBLER */ - return ((size + (1 << section_alignment[(int) seg]) - 1) - & (-1 << section_alignment[(int) seg])); -#endif /* ! BFD_ASSEMBLER */ -} - -/* This static variable is set by s_uacons to tell sh_cons_align that - the expession does not need to be aligned. */ - -static int sh_no_align_cons = 0; - -/* This handles the unaligned space allocation pseudo-ops, such as - .uaword. .uaword is just like .word, but the value does not need - to be aligned. */ - -static void -s_uacons (bytes) - int bytes; -{ - /* Tell sh_cons_align not to align this value. */ - sh_no_align_cons = 1; - cons (bytes); -} - -/* If a .word, et. al., pseud-op is seen, warn if the value is not - aligned correctly. Note that this can cause warnings to be issued - when assembling initialized structured which were declared with the - packed attribute. FIXME: Perhaps we should require an option to - enable this warning? */ - -void -sh_cons_align (nbytes) - int nbytes; -{ - int nalign; - char *p; - - if (sh_no_align_cons) - { - /* This is an unaligned pseudo-op. */ - sh_no_align_cons = 0; - return; - } - - nalign = 0; - while ((nbytes & 1) == 0) - { - ++nalign; - nbytes >>= 1; - } - - if (nalign == 0) - return; - - if (now_seg == absolute_section) - { - if ((abs_section_offset & ((1 << nalign) - 1)) != 0) - as_warn ("misaligned data"); - return; - } - - p = frag_var (rs_align_code, 1, 1, (relax_substateT) 0, - (symbolS *) NULL, (offsetT) nalign, (char *) NULL); - - record_alignment (now_seg, nalign); -} - -/* When relaxing, we need to output a reloc for any .align directive - that requests alignment to a four byte boundary or larger. This is - also where we check for misaligned data. */ - -void -sh_handle_align (frag) - fragS *frag; -{ - if (sh_relax - && frag->fr_type == rs_align - && frag->fr_address + frag->fr_fix > 0 - && frag->fr_offset > 1 - && now_seg != bss_section) - fix_new (frag, frag->fr_fix, 2, &abs_symbol, frag->fr_offset, 0, - BFD_RELOC_SH_ALIGN); - - if (frag->fr_type == rs_align_code - && frag->fr_next->fr_address - frag->fr_address - frag->fr_fix != 0) - as_warn_where (frag->fr_file, frag->fr_line, "misaligned data"); -} - -/* This macro decides whether a particular reloc is an entry in a - switch table. It is used when relaxing, because the linker needs - to know about all such entries so that it can adjust them if - necessary. */ - -#ifdef BFD_ASSEMBLER -#define SWITCH_TABLE_CONS(fix) (0) -#else -#define SWITCH_TABLE_CONS(fix) \ - ((fix)->fx_r_type == 0 \ - && ((fix)->fx_size == 2 \ - || (fix)->fx_size == 1 \ - || (fix)->fx_size == 4)) -#endif - -#define SWITCH_TABLE(fix) \ - ((fix)->fx_addsy != NULL \ - && (fix)->fx_subsy != NULL \ - && S_GET_SEGMENT ((fix)->fx_addsy) == text_section \ - && S_GET_SEGMENT ((fix)->fx_subsy) == text_section \ - && ((fix)->fx_r_type == BFD_RELOC_32 \ - || (fix)->fx_r_type == BFD_RELOC_16 \ - || (fix)->fx_r_type == BFD_RELOC_8 \ - || SWITCH_TABLE_CONS (fix))) - -/* See whether we need to force a relocation into the output file. - This is used to force out switch and PC relative relocations when - relaxing. */ - -int -sh_force_relocation (fix) - fixS *fix; -{ - if (! sh_relax) - return 0; - - return (fix->fx_pcrel - || SWITCH_TABLE (fix) - || fix->fx_r_type == BFD_RELOC_SH_COUNT - || fix->fx_r_type == BFD_RELOC_SH_ALIGN - || fix->fx_r_type == BFD_RELOC_SH_CODE - || fix->fx_r_type == BFD_RELOC_SH_DATA - || fix->fx_r_type == BFD_RELOC_SH_LABEL); -} - -/* Apply a fixup to the object file. */ - -#ifdef BFD_ASSEMBLER -int -md_apply_fix (fixP, valp) - fixS *fixP; - valueT *valp; -#else -void -md_apply_fix (fixP, val) - fixS *fixP; - long val; -#endif -{ - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - int lowbyte = target_big_endian ? 1 : 0; - int highbyte = target_big_endian ? 0 : 1; -#ifdef BFD_ASSEMBLER - long val = *valp; -#endif - long max, min; - int shift; - -#ifndef BFD_ASSEMBLER - if (fixP->fx_r_type == 0) - { - if (fixP->fx_size == 2) - fixP->fx_r_type = BFD_RELOC_16; - else if (fixP->fx_size == 4) - fixP->fx_r_type = BFD_RELOC_32; - else if (fixP->fx_size == 1) - fixP->fx_r_type = BFD_RELOC_8; - else - abort (); - } -#endif - - max = min = 0; - shift = 0; - switch (fixP->fx_r_type) - { - case BFD_RELOC_SH_IMM4: - max = 0xf; - *buf = (*buf & 0xf0) | (val & 0xf); - break; - - case BFD_RELOC_SH_IMM4BY2: - max = 0xf; - shift = 1; - *buf = (*buf & 0xf0) | ((val >> 1) & 0xf); - break; - - case BFD_RELOC_SH_IMM4BY4: - max = 0xf; - shift = 2; - *buf = (*buf & 0xf0) | ((val >> 2) & 0xf); - break; - - case BFD_RELOC_SH_IMM8BY2: - max = 0xff; - shift = 1; - *buf = val >> 1; - break; - - case BFD_RELOC_SH_IMM8BY4: - max = 0xff; - shift = 2; - *buf = val >> 2; - break; - - case BFD_RELOC_8: - case BFD_RELOC_SH_IMM8: - /* Sometimes the 8 bit value is sign extended (e.g., add) and - sometimes it is not (e.g., and). We permit any 8 bit value. - Note that adding further restrictions may invalidate - reasonable looking assembly code, such as ``and -0x1,r0''. */ - max = 0xff; - min = - 0xff; - *buf++ = val; - break; - - case BFD_RELOC_SH_PCRELIMM8BY4: - /* The lower two bits of the PC are cleared before the - displacement is added in. We can assume that the destination - is on a 4 byte bounday. If this instruction is also on a 4 - byte boundary, then we want - (target - here) / 4 - and target - here is a multiple of 4. - Otherwise, we are on a 2 byte boundary, and we want - (target - (here - 2)) / 4 - and target - here is not a multiple of 4. Computing - (target - (here - 2)) / 4 == (target - here + 2) / 4 - works for both cases, since in the first case the addition of - 2 will be removed by the division. target - here is in the - variable val. */ - val = (val + 2) / 4; - if (val & ~0xff) - as_bad_where (fixP->fx_file, fixP->fx_line, "pcrel too far"); - buf[lowbyte] = val; - break; - - case BFD_RELOC_SH_PCRELIMM8BY2: - val /= 2; - if (val & ~0xff) - as_bad_where (fixP->fx_file, fixP->fx_line, "pcrel too far"); - buf[lowbyte] = val; - break; - - case BFD_RELOC_SH_PCDISP8BY2: - val /= 2; - if (val < -0x80 || val > 0x7f) - as_bad_where (fixP->fx_file, fixP->fx_line, "pcrel too far"); - buf[lowbyte] = val; - break; - - case BFD_RELOC_SH_PCDISP12BY2: - val /= 2; - if (val < -0x800 || val >= 0x7ff) - as_bad_where (fixP->fx_file, fixP->fx_line, "pcrel too far"); - buf[lowbyte] = val & 0xff; - buf[highbyte] |= (val >> 8) & 0xf; - break; - - case BFD_RELOC_32: - if (! target_big_endian) - { - *buf++ = val >> 0; - *buf++ = val >> 8; - *buf++ = val >> 16; - *buf++ = val >> 24; - } - else - { - *buf++ = val >> 24; - *buf++ = val >> 16; - *buf++ = val >> 8; - *buf++ = val >> 0; - } - break; - - case BFD_RELOC_16: - if (! target_big_endian) - { - *buf++ = val >> 0; - *buf++ = val >> 8; - } - else - { - *buf++ = val >> 8; - *buf++ = val >> 0; - } - break; - - case BFD_RELOC_SH_USES: - /* Pass the value into sh_coff_reloc_mangle. */ - fixP->fx_addnumber = val; - break; - - case BFD_RELOC_SH_COUNT: - case BFD_RELOC_SH_ALIGN: - case BFD_RELOC_SH_CODE: - case BFD_RELOC_SH_DATA: - case BFD_RELOC_SH_LABEL: - /* Nothing to do here. */ - break; - - default: - abort (); - } - - if (shift != 0) - { - if ((val & ((1 << shift) - 1)) != 0) - as_bad_where (fixP->fx_file, fixP->fx_line, "misaligned offset"); - if (val >= 0) - val >>= shift; - else - val = ((val >> shift) - | ((long) -1 & ~ ((long) -1 >> shift))); - } - if (max != 0 && (val < min || val > max)) - as_bad_where (fixP->fx_file, fixP->fx_line, "offset out of range"); - -#ifdef BFD_ASSEMBLER - return 0; -#endif -} - -int md_long_jump_size; - -/* Called just before address relaxation. Return the length - by which a fragment must grow to reach it's destination. */ - -int -md_estimate_size_before_relax (fragP, segment_type) - register fragS *fragP; - register segT segment_type; -{ - switch (fragP->fr_subtype) - { - case C (UNCOND_JUMP, UNDEF_DISP): - /* used to be a branch to somewhere which was unknown */ - if (!fragP->fr_symbol) - { - fragP->fr_subtype = C (UNCOND_JUMP, UNCOND12); - fragP->fr_var = md_relax_table[C (UNCOND_JUMP, UNCOND12)].rlx_length; - } - else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type) - { - fragP->fr_subtype = C (UNCOND_JUMP, UNCOND12); - fragP->fr_var = md_relax_table[C (UNCOND_JUMP, UNCOND12)].rlx_length; - } - else - { - fragP->fr_subtype = C (UNCOND_JUMP, UNDEF_WORD_DISP); - fragP->fr_var = md_relax_table[C (UNCOND_JUMP, UNCOND32)].rlx_length; - return md_relax_table[C (UNCOND_JUMP, UNCOND32)].rlx_length; - } - break; - - default: - abort (); - case C (COND_JUMP, UNDEF_DISP): - /* used to be a branch to somewhere which was unknown */ - if (fragP->fr_symbol - && S_GET_SEGMENT (fragP->fr_symbol) == segment_type) - { - /* Got a symbol and it's defined in this segment, become byte - sized - maybe it will fix up */ - fragP->fr_subtype = C (COND_JUMP, COND8); - fragP->fr_var = md_relax_table[C (COND_JUMP, COND8)].rlx_length; - } - else if (fragP->fr_symbol) - { - /* Its got a segment, but its not ours, so it will always be long */ - fragP->fr_subtype = C (COND_JUMP, UNDEF_WORD_DISP); - fragP->fr_var = md_relax_table[C (COND_JUMP, COND32)].rlx_length; - return md_relax_table[C (COND_JUMP, COND32)].rlx_length; - } - else - { - /* We know the abs value */ - fragP->fr_subtype = C (COND_JUMP, COND8); - fragP->fr_var = md_relax_table[C (COND_JUMP, COND8)].rlx_length; - } - - break; - } - return fragP->fr_var; -} - -/* Put number into target byte order */ - -void -md_number_to_chars (ptr, use, nbytes) - char *ptr; - valueT use; - int nbytes; -{ - if (! target_big_endian) - number_to_chars_littleendian (ptr, use, nbytes); - else - number_to_chars_bigendian (ptr, use, nbytes); -} - -long -md_pcrel_from (fixP) - fixS *fixP; -{ - return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address + 2; -} - -#ifdef OBJ_COFF - -int -tc_coff_sizemachdep (frag) - fragS *frag; -{ - return md_relax_table[frag->fr_subtype].rlx_length; -} - -#endif /* OBJ_COFF */ - -/* When we align the .text section, insert the correct NOP pattern. */ - -int -sh_do_align (n, fill, len, max) - int n; - const char *fill; - int len; - int max; -{ - if (fill == NULL -#ifdef BFD_ASSEMBLER - && (now_seg->flags & SEC_CODE) != 0 -#else - && now_seg != data_section - && now_seg != bss_section -#endif - && n > 1) - { - static const unsigned char big_nop_pattern[] = { 0x00, 0x09 }; - static const unsigned char little_nop_pattern[] = { 0x09, 0x00 }; - - /* First align to a 2 byte boundary, in case there is an odd - .byte. */ - frag_align (1, 0, 0); - if (target_big_endian) - frag_align_pattern (n, big_nop_pattern, sizeof big_nop_pattern, max); - else - frag_align_pattern (n, little_nop_pattern, sizeof little_nop_pattern, - max); - return 1; - } - - return 0; -} - -#ifndef BFD_ASSEMBLER -#ifdef OBJ_COFF - -/* Map BFD relocs to SH COFF relocs. */ - -struct reloc_map -{ - bfd_reloc_code_real_type bfd_reloc; - int sh_reloc; -}; - -static const struct reloc_map coff_reloc_map[] = -{ - { BFD_RELOC_32, R_SH_IMM32 }, - { BFD_RELOC_16, R_SH_IMM16 }, - { BFD_RELOC_8, R_SH_IMM8 }, - { BFD_RELOC_SH_PCDISP8BY2, R_SH_PCDISP8BY2 }, - { BFD_RELOC_SH_PCDISP12BY2, R_SH_PCDISP }, - { BFD_RELOC_SH_IMM4, R_SH_IMM4 }, - { BFD_RELOC_SH_IMM4BY2, R_SH_IMM4BY2 }, - { BFD_RELOC_SH_IMM4BY4, R_SH_IMM4BY4 }, - { BFD_RELOC_SH_IMM8, R_SH_IMM8 }, - { BFD_RELOC_SH_IMM8BY2, R_SH_IMM8BY2 }, - { BFD_RELOC_SH_IMM8BY4, R_SH_IMM8BY4 }, - { BFD_RELOC_SH_PCRELIMM8BY2, R_SH_PCRELIMM8BY2 }, - { BFD_RELOC_SH_PCRELIMM8BY4, R_SH_PCRELIMM8BY4 }, - { BFD_RELOC_8_PCREL, R_SH_SWITCH8 }, - { BFD_RELOC_SH_SWITCH16, R_SH_SWITCH16 }, - { BFD_RELOC_SH_SWITCH32, R_SH_SWITCH32 }, - { BFD_RELOC_SH_USES, R_SH_USES }, - { BFD_RELOC_SH_COUNT, R_SH_COUNT }, - { BFD_RELOC_SH_ALIGN, R_SH_ALIGN }, - { BFD_RELOC_SH_CODE, R_SH_CODE }, - { BFD_RELOC_SH_DATA, R_SH_DATA }, - { BFD_RELOC_SH_LABEL, R_SH_LABEL }, - { BFD_RELOC_UNUSED, 0 } -}; - -/* Adjust a reloc for the SH. This is similar to the generic code, - but does some minor tweaking. */ - -void -sh_coff_reloc_mangle (seg, fix, intr, paddr) - segment_info_type *seg; - fixS *fix; - struct internal_reloc *intr; - unsigned int paddr; -{ - symbolS *symbol_ptr = fix->fx_addsy; - symbolS *dot; - - intr->r_vaddr = paddr + fix->fx_frag->fr_address + fix->fx_where; - - if (! SWITCH_TABLE (fix)) - { - const struct reloc_map *rm; - - for (rm = coff_reloc_map; rm->bfd_reloc != BFD_RELOC_UNUSED; rm++) - if (rm->bfd_reloc == (bfd_reloc_code_real_type) fix->fx_r_type) - break; - if (rm->bfd_reloc == BFD_RELOC_UNUSED) - as_bad_where (fix->fx_file, fix->fx_line, - "Can not represent %s relocation in this object file format", - bfd_get_reloc_code_name (fix->fx_r_type)); - intr->r_type = rm->sh_reloc; - intr->r_offset = 0; - } - else - { - know (sh_relax); - - if (fix->fx_r_type == BFD_RELOC_16) - intr->r_type = R_SH_SWITCH16; - else if (fix->fx_r_type == BFD_RELOC_8) - intr->r_type = R_SH_SWITCH8; - else if (fix->fx_r_type == BFD_RELOC_32) - intr->r_type = R_SH_SWITCH32; - else - abort (); - - /* For a switch reloc, we set r_offset to the difference between - the reloc address and the subtrahend. When the linker is - doing relaxing, it can use the determine the starting and - ending points of the switch difference expression. */ - intr->r_offset = intr->r_vaddr - S_GET_VALUE (fix->fx_subsy); - } - - /* PC relative relocs are always against the current section. */ - if (symbol_ptr == NULL) - { - switch (fix->fx_r_type) - { - case BFD_RELOC_SH_PCRELIMM8BY2: - case BFD_RELOC_SH_PCRELIMM8BY4: - case BFD_RELOC_SH_PCDISP8BY2: - case BFD_RELOC_SH_PCDISP12BY2: - case BFD_RELOC_SH_USES: - symbol_ptr = seg->dot; - break; - default: - break; - } - } - - if (fix->fx_r_type == BFD_RELOC_SH_USES) - { - /* We can't store the offset in the object file, since this - reloc does not take up any space, so we store it in r_offset. - The fx_addnumber field was set in md_apply_fix. */ - intr->r_offset = fix->fx_addnumber; - } - else if (fix->fx_r_type == BFD_RELOC_SH_COUNT) - { - /* We can't store the count in the object file, since this reloc - does not take up any space, so we store it in r_offset. The - fx_offset field was set when the fixup was created in - sh_coff_frob_file. */ - intr->r_offset = fix->fx_offset; - /* This reloc is always absolute. */ - symbol_ptr = NULL; - } - else if (fix->fx_r_type == BFD_RELOC_SH_ALIGN) - { - /* Store the alignment in the r_offset field. */ - intr->r_offset = fix->fx_offset; - /* This reloc is always absolute. */ - symbol_ptr = NULL; - } - else if (fix->fx_r_type == BFD_RELOC_SH_CODE - || fix->fx_r_type == BFD_RELOC_SH_DATA - || fix->fx_r_type == BFD_RELOC_SH_LABEL) - { - /* These relocs are always absolute. */ - symbol_ptr = NULL; - } - - /* Turn the segment of the symbol into an offset. */ - if (symbol_ptr != NULL) - { - dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot; - if (dot != NULL) - intr->r_symndx = dot->sy_number; - else - intr->r_symndx = symbol_ptr->sy_number; - } - else - intr->r_symndx = -1; -} - -#endif /* OBJ_COFF */ -#endif /* ! BFD_ASSEMBLER */ - -#ifdef BFD_ASSEMBLER - -/* Create a reloc. */ - -arelent * -tc_gen_reloc (section, fixp) - asection *section; - fixS *fixp; -{ - arelent *rel; - bfd_reloc_code_real_type r_type; - - rel = (arelent *) xmalloc (sizeof (arelent)); - rel->sym_ptr_ptr = &fixp->fx_addsy->bsym; - rel->address = fixp->fx_frag->fr_address + fixp->fx_where; - - r_type = fixp->fx_r_type; - - if (SWITCH_TABLE (fixp)) - { - rel->addend = rel->address - S_GET_VALUE (fixp->fx_subsy); - if (r_type == BFD_RELOC_16) - r_type = BFD_RELOC_SH_SWITCH16; - else if (r_type == BFD_RELOC_8) - r_type = BFD_RELOC_8_PCREL; - else if (r_type == BFD_RELOC_32) - r_type = BFD_RELOC_SH_SWITCH32; - else - abort (); - } - else if (r_type == BFD_RELOC_SH_USES) - rel->addend = fixp->fx_addnumber; - else if (r_type == BFD_RELOC_SH_COUNT) - rel->addend = fixp->fx_offset; - else if (r_type == BFD_RELOC_SH_ALIGN) - rel->addend = fixp->fx_offset; - else if (fixp->fx_pcrel) - rel->addend = fixp->fx_addnumber; - else - rel->addend = 0; - - rel->howto = bfd_reloc_type_lookup (stdoutput, r_type); - if (rel->howto == NULL) - { - as_bad_where (fixp->fx_file, fixp->fx_line, - "Cannot represent relocation type %s", - bfd_get_reloc_code_name (r_type)); - /* Set howto to a garbage value so that we can keep going. */ - rel->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32); - assert (rel->howto != NULL); - } - - return rel; -} - -#endif /* BFD_ASSEMBLER */ diff --git a/contrib/binutils/gas/config/tc-sh.h b/contrib/binutils/gas/config/tc-sh.h deleted file mode 100644 index a18029b020d6..000000000000 --- a/contrib/binutils/gas/config/tc-sh.h +++ /dev/null @@ -1,141 +0,0 @@ -/* This file is tc-sh.h - Copyright (C) 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. - - This file is part of GAS, the GNU Assembler. - - GAS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GAS is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GAS; see the file COPYING. If not, write to - the Free Software Foundation, 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#define TC_SH - -#define TARGET_BYTES_BIG_ENDIAN 0 - -#define TARGET_ARCH bfd_arch_sh - -/* Whether in little endian mode. */ -extern int shl; - -/* Whether -relax was used. */ -extern int sh_relax; - -/* Whether -small was used. */ -extern int sh_small; - -/* Don't try to break words. */ -#define WORKING_DOT_WORD - -/* We require .long, et. al., to be aligned correctly. */ -#define md_cons_align(nbytes) sh_cons_align (nbytes) -extern void sh_cons_align PARAMS ((int)); - -/* When relaxing, we need to generate relocations for alignment - directives. */ -#define HANDLE_ALIGN(frag) sh_handle_align (frag) -extern void sh_handle_align PARAMS ((fragS *)); - -/* We need to force out some relocations when relaxing. */ -#define TC_FORCE_RELOCATION(fix) sh_force_relocation (fix) -extern int sh_force_relocation (); - -#define IGNORE_NONSTANDARD_ESCAPES - -#define LISTING_HEADER (shl ? "Hitachi Super-H GAS Little Endian" : "Hitachi Super-H GAS Big Endian") - -#define md_operand(x) - -extern const struct relax_type md_relax_table[]; -#define TC_GENERIC_RELAX_TABLE md_relax_table - -/* We use a special alignment function to insert the correct nop - pattern. */ -extern int sh_do_align PARAMS ((int, const char *, int, int)); -#define md_do_align(n,fill,len,max,l) if (sh_do_align (n,fill,len,max)) goto l - -/* We record, for each section, whether we have most recently output a - CODE reloc or a DATA reloc. */ -struct sh_segment_info_type -{ - int in_code : 1; -}; -#define TC_SEGMENT_INFO_TYPE struct sh_segment_info_type - -/* We call a routine to emit a reloc for a label, so that the linker - can align loads and stores without crossing a label. */ -extern void sh_frob_label PARAMS ((void)); -#define tc_frob_label(sym) sh_frob_label () - -/* We call a routine to flush pending output in order to output a DATA - reloc when required. */ -extern void sh_flush_pending_output PARAMS ((void)); -#define md_flush_pending_output() sh_flush_pending_output () - -#ifdef BFD_ASSEMBLER -#define tc_frob_file_before_adjust sh_frob_file -#else -#define tc_frob_file sh_frob_file -#endif -extern void sh_frob_file PARAMS ((void)); - -#ifdef OBJ_COFF -/* COFF specific definitions. */ - -#define DO_NOT_STRIP 0 - -/* This macro translates between an internal fix and an coff reloc type */ -#define TC_COFF_FIX2RTYPE(fix) ((fix)->fx_r_type) - -#define BFD_ARCH TARGET_ARCH - -#define COFF_MAGIC (shl ? SH_ARCH_MAGIC_LITTLE : SH_ARCH_MAGIC_BIG) - -/* We need to write out relocs which have not been completed. */ -#define TC_COUNT_RELOC(fix) ((fix)->fx_addsy != NULL) - -#define TC_RELOC_MANGLE(seg, fix, int, paddr) \ - sh_coff_reloc_mangle ((seg), (fix), (int), (paddr)) -extern void sh_coff_reloc_mangle (); - -#define tc_coff_symbol_emit_hook(a) ; /* not used */ - -#define NEED_FX_R_TYPE 1 - -#define TC_KEEP_FX_OFFSET 1 - -#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag) -extern int tc_coff_sizemachdep PARAMS ((fragS *)); - -/* We align most sections to a 16 byte boundary. */ -#define SUB_SEGMENT_ALIGN(SEG) \ - (strncmp (obj_segment_name (SEG), ".stabstr", 8) == 0 \ - ? 0 \ - : ((strncmp (obj_segment_name (SEG), ".stab", 5) == 0 \ - || strcmp (obj_segment_name (SEG), ".ctors") == 0 \ - || strcmp (obj_segment_name (SEG), ".dtors") == 0) \ - ? 2 \ - : (sh_small ? 2 : 4))) - -#endif /* OBJ_COFF */ - -#ifdef OBJ_ELF -/* ELF specific definitions. */ - -/* Whether or not the target is big endian */ -extern int target_big_endian; - -#define TARGET_FORMAT (shl ? "elf32-shl" : "elf32-sh") - -#endif /* OBJ_ELF */ - -/* end of tc-sh.h */ diff --git a/contrib/binutils/gas/config/te-freebsd.h b/contrib/binutils/gas/config/te-freebsd.h deleted file mode 100644 index 13142359dcd7..000000000000 --- a/contrib/binutils/gas/config/te-freebsd.h +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Target environment for FreeBSD. It is the same as the generic - * target, except it arranges to suppress the use of "/" as a comment - * character. Some code in the FreeBSD kernel uses "/" to mean - * division. (What a concept.) - */ -#define TE_FreeBSD 1 -#include "te-generic.h" diff --git a/contrib/binutils/gas/config/te-multi.h b/contrib/binutils/gas/config/te-multi.h deleted file mode 100644 index b8eda4505fb7..000000000000 --- a/contrib/binutils/gas/config/te-multi.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * This file is te-generic.h and is intended to be a template for - * target environment specific header files. - * - * It is my intent that this file will evolve into a file suitable for config, - * compile, and copying as an aid for testing and porting. xoxorich. - */ - -/* Added these, because if we don't know what we're targetting we may - need an assembler version of libgcc, and that will use local - labels. */ -#define LOCAL_LABELS_DOLLAR 1 -#define LOCAL_LABELS_FB 1 - -/* these define interfaces */ -#ifdef OBJ_HEADER -#include OBJ_HEADER -#else -#include "obj-format.h" -#endif - -/* end of te-generic.h */ diff --git a/contrib/binutils/gas/doc/c-sh.texi b/contrib/binutils/gas/doc/c-sh.texi deleted file mode 100644 index e20f55437883..000000000000 --- a/contrib/binutils/gas/doc/c-sh.texi +++ /dev/null @@ -1,272 +0,0 @@ -@c Copyright (C) 1991, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. -@c This is part of the GAS manual. -@c For copying conditions, see the file as.texinfo. -@page -@node SH-Dependent -@chapter Hitachi SH Dependent Features - -@cindex SH support -@menu -* SH Options:: Options -* SH Syntax:: Syntax -* SH Floating Point:: Floating Point -* SH Directives:: SH Machine Directives -* SH Opcodes:: Opcodes -@end menu - -@node SH Options -@section Options - -@cindex SH options (none) -@cindex options, SH (none) -@code{@value{AS}} has no additional command-line options for the Hitachi -SH family. - -@node SH Syntax -@section Syntax - -@menu -* SH-Chars:: Special Characters -* SH-Regs:: Register Names -* SH-Addressing:: Addressing Modes -@end menu - -@node SH-Chars -@subsection Special Characters - -@cindex line comment character, SH -@cindex SH line comment character -@samp{!} is the line comment character. - -@cindex line separator, SH -@cindex statement separator, SH -@cindex SH line separator -You can use @samp{;} instead of a newline to separate statements. - -@cindex symbol names, @samp{$} in -@cindex @code{$} in symbol names -Since @samp{$} has no special meaning, you may use it in symbol names. - -@node SH-Regs -@subsection Register Names - -@cindex SH registers -@cindex registers, SH -You can use the predefined symbols @samp{r0}, @samp{r1}, @samp{r2}, -@samp{r3}, @samp{r4}, @samp{r5}, @samp{r6}, @samp{r7}, @samp{r8}, -@samp{r9}, @samp{r10}, @samp{r11}, @samp{r12}, @samp{r13}, @samp{r14}, -and @samp{r15} to refer to the SH registers. - -The SH also has these control registers: - -@table @code -@item pr -procedure register (holds return address) - -@item pc -program counter - -@item mach -@itemx macl -high and low multiply accumulator registers - -@item sr -status register - -@item gbr -global base register - -@item vbr -vector base register (for interrupt vectors) -@end table - -@node SH-Addressing -@subsection Addressing Modes - -@cindex addressing modes, SH -@cindex SH addressing modes -@code{@value{AS}} understands the following addressing modes for the SH. -@code{R@var{n}} in the following refers to any of the numbered -registers, but @emph{not} the control registers. - -@table @code -@item R@var{n} -Register direct - -@item @@R@var{n} -Register indirect - -@item @@-R@var{n} -Register indirect with pre-decrement - -@item @@R@var{n}+ -Register indirect with post-increment - -@item @@(@var{disp}, R@var{n}) -Register indirect with displacement - -@item @@(R0, R@var{n}) -Register indexed - -@item @@(@var{disp}, GBR) -@code{GBR} offset - -@item @@(R0, GBR) -GBR indexed - -@item @var{addr} -@itemx @@(@var{disp}, PC) -PC relative address (for branch or for addressing memory). The -@code{@value{AS}} implementation allows you to use the simpler form -@var{addr} anywhere a PC relative address is called for; the alternate -form is supported for compatibility with other assemblers. - -@item #@var{imm} -Immediate data -@end table - -@node SH Floating Point -@section Floating Point - -@cindex floating point, SH (@sc{ieee}) -@cindex SH floating point (@sc{ieee}) -The SH family has no hardware floating point, but the @code{.float} -directive generates @sc{ieee} floating-point numbers for compatibility -with other development tools. - -@node SH Directives -@section SH Machine Directives - -@cindex SH machine directives -@cindex machine directives, SH -@cindex @code{uaword} directive, SH -@cindex @code{ualong} directive, SH - -@table @code -@item uaword -@itemx ualong -@code{@value{AS}} will issue a warning when a misaligned @code{.word} or -@code{.long} directive is used. You may use @code{.uaword} or -@code{.ualong} to indicate that the value is intentionally misaligned. -@end table - -@node SH Opcodes -@section Opcodes - -@cindex SH opcode summary -@cindex opcode summary, SH -@cindex mnemonics, SH -@cindex instruction summary, SH -For detailed information on the SH machine instruction set, see -@cite{SH-Microcomputer User's Manual} (Hitachi Micro Systems, Inc.). - -@code{@value{AS}} implements all the standard SH opcodes. No additional -pseudo-instructions are needed on this family. Note, however, that -because @code{@value{AS}} supports a simpler form of PC-relative -addressing, you may simply write (for example) - -@example -mov.l bar,r0 -@end example - -@noindent -where other assemblers might require an explicit displacement to -@code{bar} from the program counter: - -@example -mov.l @@(@var{disp}, PC) -@end example - -@ifset SMALL -@c this table, due to the multi-col faking and hardcoded order, looks silly -@c except in smallbook. See comments below "@set SMALL" near top of this file. - -Here is a summary of SH opcodes: - -@page -@smallexample -@i{Legend:} -Rn @r{a numbered register} -Rm @r{another numbered register} -#imm @r{immediate data} -disp @r{displacement} -disp8 @r{8-bit displacement} -disp12 @r{12-bit displacement} - -add #imm,Rn lds.l @@Rn+,PR -add Rm,Rn mac.w @@Rm+,@@Rn+ -addc Rm,Rn mov #imm,Rn -addv Rm,Rn mov Rm,Rn -and #imm,R0 mov.b Rm,@@(R0,Rn) -and Rm,Rn mov.b Rm,@@-Rn -and.b #imm,@@(R0,GBR) mov.b Rm,@@Rn -bf disp8 mov.b @@(disp,Rm),R0 -bra disp12 mov.b @@(disp,GBR),R0 -bsr disp12 mov.b @@(R0,Rm),Rn -bt disp8 mov.b @@Rm+,Rn -clrmac mov.b @@Rm,Rn -clrt mov.b R0,@@(disp,Rm) -cmp/eq #imm,R0 mov.b R0,@@(disp,GBR) -cmp/eq Rm,Rn mov.l Rm,@@(disp,Rn) -cmp/ge Rm,Rn mov.l Rm,@@(R0,Rn) -cmp/gt Rm,Rn mov.l Rm,@@-Rn -cmp/hi Rm,Rn mov.l Rm,@@Rn -cmp/hs Rm,Rn mov.l @@(disp,Rn),Rm -cmp/pl Rn mov.l @@(disp,GBR),R0 -cmp/pz Rn mov.l @@(disp,PC),Rn -cmp/str Rm,Rn mov.l @@(R0,Rm),Rn -div0s Rm,Rn mov.l @@Rm+,Rn -div0u mov.l @@Rm,Rn -div1 Rm,Rn mov.l R0,@@(disp,GBR) -exts.b Rm,Rn mov.w Rm,@@(R0,Rn) -exts.w Rm,Rn mov.w Rm,@@-Rn -extu.b Rm,Rn mov.w Rm,@@Rn -extu.w Rm,Rn mov.w @@(disp,Rm),R0 -jmp @@Rn mov.w @@(disp,GBR),R0 -jsr @@Rn mov.w @@(disp,PC),Rn -ldc Rn,GBR mov.w @@(R0,Rm),Rn -ldc Rn,SR mov.w @@Rm+,Rn -ldc Rn,VBR mov.w @@Rm,Rn -ldc.l @@Rn+,GBR mov.w R0,@@(disp,Rm) -ldc.l @@Rn+,SR mov.w R0,@@(disp,GBR) -ldc.l @@Rn+,VBR mova @@(disp,PC),R0 -lds Rn,MACH movt Rn -lds Rn,MACL muls Rm,Rn -lds Rn,PR mulu Rm,Rn -lds.l @@Rn+,MACH neg Rm,Rn -lds.l @@Rn+,MACL negc Rm,Rn -@page -nop stc VBR,Rn -not Rm,Rn stc.l GBR,@@-Rn -or #imm,R0 stc.l SR,@@-Rn -or Rm,Rn stc.l VBR,@@-Rn -or.b #imm,@@(R0,GBR) sts MACH,Rn -rotcl Rn sts MACL,Rn -rotcr Rn sts PR,Rn -rotl Rn sts.l MACH,@@-Rn -rotr Rn sts.l MACL,@@-Rn -rte sts.l PR,@@-Rn -rts sub Rm,Rn -sett subc Rm,Rn -shal Rn subv Rm,Rn -shar Rn swap.b Rm,Rn -shll Rn swap.w Rm,Rn -shll16 Rn tas.b @@Rn -shll2 Rn trapa #imm -shll8 Rn tst #imm,R0 -shlr Rn tst Rm,Rn -shlr16 Rn tst.b #imm,@@(R0,GBR) -shlr2 Rn xor #imm,R0 -shlr8 Rn xor Rm,Rn -sleep xor.b #imm,@@(R0,GBR) -stc GBR,Rn xtrct Rm,Rn -stc SR,Rn -@end smallexample -@end ifset - -@ifset Hitachi-all -@ifclear GENERIC -@raisesections -@end ifclear -@end ifset - diff --git a/contrib/binutils/include/aout/sun4.h b/contrib/binutils/include/aout/sun4.h deleted file mode 100644 index f42a0dd45988..000000000000 --- a/contrib/binutils/include/aout/sun4.h +++ /dev/null @@ -1,219 +0,0 @@ -/* SPARC-specific values for a.out files */ - -/* Some systems, e.g., AIX, may have defined this in header files already - included. */ -#undef TARGET_PAGE_SIZE -#define TARGET_PAGE_SIZE 0x2000 /* 8K. aka NBPG in */ -/* Note that some SPARCs have 4K pages, some 8K, some others. */ - -#define SEG_SIZE_SPARC TARGET_PAGE_SIZE -#define SEG_SIZE_SUN3 0x20000 /* Resolution of r/w protection hw */ - -#define TEXT_START_ADDR TARGET_PAGE_SIZE /* Location 0 is not accessible */ -#define N_HEADER_IN_TEXT(x) 1 - -/* Non-default definitions of the accessor macros... */ - -/* Segment size varies on Sun-3 versus Sun-4. */ - -#define N_SEGSIZE(x) (N_MACHTYPE(x) == M_SPARC? SEG_SIZE_SPARC: \ - N_MACHTYPE(x) == M_68020? SEG_SIZE_SUN3: \ - /* Guess? */ TARGET_PAGE_SIZE) - -/* Virtual Address of text segment from the a.out file. For OMAGIC, - (almost always "unlinked .o's" these days), should be zero. - Sun added a kludge so that shared libraries linked ZMAGIC get - an address of zero if a_entry (!!!) is lower than the otherwise - expected text address. These kludges have gotta go! - For linked files, should reflect reality if we know it. */ - -/* This differs from the version in aout64.h (which we override by defining - it here) only for NMAGIC (we return TEXT_START_ADDR+EXEC_BYTES_SIZE; - they return 0). */ - -#define N_TXTADDR(x) \ - (N_MAGIC(x)==OMAGIC? 0 \ - : (N_MAGIC(x) == ZMAGIC && (x).a_entry < TEXT_START_ADDR)? 0 \ - : TEXT_START_ADDR+EXEC_BYTES_SIZE) - -/* When a file is linked against a shared library on SunOS 4, the - dynamic bit in the exec header is set, and the first symbol in the - symbol table is __DYNAMIC. Its value is the address of the - following structure. */ - -struct external_sun4_dynamic -{ - /* The version number of the structure. SunOS 4.1.x creates files - with version number 3, which is what this structure is based on. - According to gdb, version 2 is similar. I believe that version 2 - used a different type of procedure linkage table, and there may - have been other differences. */ - bfd_byte ld_version[4]; - /* The virtual address of a 28 byte structure used in debugging. - The contents are filled in at run time by ld.so. */ - bfd_byte ldd[4]; - /* The virtual address of another structure with information about - how to relocate the executable at run time. */ - bfd_byte ld[4]; -}; - -/* The size of the debugging structure pointed to by the debugger - field of __DYNAMIC. */ -#define EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE (24) - -/* The structure pointed to by the linker field of __DYNAMIC. As far - as I can tell, most of the addresses in this structure are offsets - within the file, but some are actually virtual addresses. */ - -struct internal_sun4_dynamic_link -{ - /* Linked list of loaded objects. This is filled in at runtime by - ld.so and probably by dlopen. */ - unsigned long ld_loaded; - - /* The address of the list of names of shared objects which must be - included at runtime. Each entry in the list is 16 bytes: the 4 - byte address of the string naming the object (e.g., for -lc this - is "c"); 4 bytes of flags--the high bit is whether to search for - the object using the library path; the 2 byte major version - number; the 2 byte minor version number; the 4 byte address of - the next entry in the list (zero if this is the last entry). The - version numbers seem to only be non-zero when doing library - searching. */ - unsigned long ld_need; - - /* The address of the path to search for the shared objects which - must be included. This points to a string in PATH format which - is generated from the -L arguments to the linker. According to - the man page, ld.so implicitly adds ${LD_LIBRARY_PATH} to the - beginning of this string and /lib:/usr/lib:/usr/local/lib to the - end. The string is terminated by a null byte. This field is - zero if there is no additional path. */ - unsigned long ld_rules; - - /* The address of the global offset table. This appears to be a - virtual address, not a file offset. The first entry in the - global offset table seems to be the virtual address of the - sun4_dynamic structure (the same value as the __DYNAMIC symbol). - The global offset table is used for PIC code to hold the - addresses of variables. A dynamically linked file which does not - itself contain PIC code has a four byte global offset table. */ - unsigned long ld_got; - - /* The address of the procedure linkage table. This appears to be a - virtual address, not a file offset. - - On a SPARC, the table is composed of 12 byte entries, each of - which consists of three instructions. The first entry is - sethi %hi(0),%g1 - jmp %g1 - nop - These instructions are changed by ld.so into a jump directly into - ld.so itself. Each subsequent entry is - save %sp, -96, %sp - call
- - The reloc_number is the number of the reloc to use to resolve - this entry. The reloc will be a JMP_SLOT reloc against some - symbol that is not defined in this object file but should be - defined in a shared object (if it is not, ld.so will report a - runtime error and exit). The constant 0x010000000 turns the - reloc number into a sethi of %g0, which does nothing since %g0 is - hardwired to zero. - - When one of these entries is executed, it winds up calling into - ld.so. ld.so looks at the reloc number, available via the return - address, to determine which entry this is. It then looks at the - reloc and patches up the entry in the table into a sethi and jmp - to the real address followed by a nop. This means that the reloc - lookup only has to happen once, and it also means that the - relocation only needs to be done if the function is actually - called. The relocation is expensive because ld.so must look up - the symbol by name. - - The size of the procedure linkage table is given by the ld_plt_sz - field. */ - unsigned long ld_plt; - - /* The address of the relocs. These are in the same format as - ordinary relocs. Symbol index numbers refer to the symbols - pointed to by ld_stab. I think the only way to determine the - number of relocs is to assume that all the bytes from ld_rel to - ld_hash contain reloc entries. */ - unsigned long ld_rel; - - /* The address of a hash table of symbols. The hash table has - roughly the same number of entries as there are dynamic symbols; - I think the only way to get the exact size is to assume that - every byte from ld_hash to ld_stab is devoted to the hash table. - - Each entry in the hash table is eight bytes. The first four - bytes are a symbol index into the dynamic symbols. The second - four bytes are the index of the next hash table entry in the - bucket. The ld_buckets field gives the number of buckets, say B. - The first B entries in the hash table each start a bucket which - is chained through the second four bytes of each entry. A value - of zero ends the chain. - - The hash function is simply - h = 0; - while (*string != '\0') - h = (h << 1) + *string++; - h &= 0x7fffffff; - - To look up a symbol, compute the hash value of the name. Take - the modulos of hash value and the number of buckets. Start at - that entry in the hash table. See if the symbol (from the first - four bytes of the hash table entry) has the name you are looking - for. If not, use the chain field (the second four bytes of the - hash table entry) to move on to the next entry in this bucket. - If the chain field is zero you have reached the end of the - bucket, and the symbol is not in the hash table. */ - unsigned long ld_hash; - - /* The address of the symbol table. This is a list of - external_nlist structures. The string indices are relative to - the ld_symbols field. I think the only way to determine the - number of symbols is to assume that all the bytes between ld_stab - and ld_symbols are external_nlist structures. */ - unsigned long ld_stab; - - /* I don't know what this is for. It seems to always be zero. */ - unsigned long ld_stab_hash; - - /* The number of buckets in the hash table. */ - unsigned long ld_buckets; - - /* The address of the symbol string table. The first string in this - string table need not be the empty string. */ - unsigned long ld_symbols; - - /* The size in bytes of the symbol string table. */ - unsigned long ld_symb_size; - - /* The size in bytes of the text segment. */ - unsigned long ld_text; - - /* The size in bytes of the procedure linkage table. */ - unsigned long ld_plt_sz; -}; - -/* The external form of the structure. */ - -struct external_sun4_dynamic_link -{ - bfd_byte ld_loaded[4]; - bfd_byte ld_need[4]; - bfd_byte ld_rules[4]; - bfd_byte ld_got[4]; - bfd_byte ld_plt[4]; - bfd_byte ld_rel[4]; - bfd_byte ld_hash[4]; - bfd_byte ld_stab[4]; - bfd_byte ld_stab_hash[4]; - bfd_byte ld_buckets[4]; - bfd_byte ld_symbols[4]; - bfd_byte ld_symb_size[4]; - bfd_byte ld_text[4]; - bfd_byte ld_plt_sz[4]; -}; diff --git a/contrib/binutils/include/wait.h b/contrib/binutils/include/wait.h deleted file mode 100644 index fa3c9ccb1d7e..000000000000 --- a/contrib/binutils/include/wait.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Define how to access the int that the wait system call stores. - This has been compatible in all Unix systems since time immemorial, - but various well-meaning people have defined various different - words for the same old bits in the same old int (sometimes claimed - to be a struct). We just know it's an int and we use these macros - to access the bits. */ - -/* The following macros are defined equivalently to their definitions - in POSIX.1. We fail to define WNOHANG and WUNTRACED, which POSIX.1 - defines, since our code does not use waitpid(). We - also fail to declare wait() and waitpid(). */ - -#ifndef WIFEXITED -#define WIFEXITED(w) (((w)&0377) == 0) -#endif - -#ifndef WIFSIGNALED -#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0) -#endif - -#ifndef WIFSTOPPED -#ifdef IBM6000 - -/* Unfortunately, the above comment (about being compatible in all Unix - systems) is not quite correct for AIX, sigh. And AIX 3.2 can generate - status words like 0x57c (sigtrap received after load), and gdb would - choke on it. */ - -#define WIFSTOPPED(w) ((w)&0x40) - -#else -#define WIFSTOPPED(w) (((w)&0377) == 0177) -#endif -#endif - -#ifndef WEXITSTATUS -#define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */ -#endif - -#ifndef WTERMSIG -#define WTERMSIG(w) ((w) & 0177) -#endif - -#ifndef WSTOPSIG -#define WSTOPSIG WEXITSTATUS -#endif - -/* These are not defined in POSIX, but are used by our programs. */ - -#define WAITTYPE int - -#ifndef WCOREDUMP -#define WCOREDUMP(w) (((w)&0200) != 0) -#endif - -#ifndef WSETEXIT -#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8))) -#endif - -#ifndef WSETSTOP -#define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8))) -#endif - diff --git a/contrib/binutils/install.sh b/contrib/binutils/install.sh deleted file mode 100755 index 4b883b386de2..000000000000 --- a/contrib/binutils/install.sh +++ /dev/null @@ -1,247 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# 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=: - chmodcmd="" - 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/binutils/ld/acconfig.h b/contrib/binutils/ld/acconfig.h deleted file mode 100644 index c627d7faa97a..000000000000 --- a/contrib/binutils/ld/acconfig.h +++ /dev/null @@ -1,22 +0,0 @@ - -/* Name of package. */ -#undef PACKAGE - -/* Version of package. */ -#undef VERSION - -/* Whether strstr must be declared even if is included. */ -#undef NEED_DECLARATION_STRSTR - -/* Whether free must be declared even if is included. */ -#undef NEED_DECLARATION_FREE - -/* Whether sbrk must be declared even if is included. */ -#undef NEED_DECLARATION_SBRK - -/* Whether getenv must be declared even if is included. */ -#undef NEED_DECLARATION_GETENV -@TOP@ - -/* Do we need to use the b modifier when opening binary files? */ -#undef USE_BINARY_FOPEN diff --git a/contrib/binutils/ld/configdoc.texi b/contrib/binutils/ld/configdoc.texi deleted file mode 100644 index 3a367277e501..000000000000 --- a/contrib/binutils/ld/configdoc.texi +++ /dev/null @@ -1,13 +0,0 @@ -@c ------------------------------ CONFIGURATION VARS: -@c 1. Inclusiveness of this manual -@set GENERIC - -@c 2. Specific target machines -@set H8300 -@set I960 - -@c 3. Properties of this configuration -@clear SingleFormat -@set UsesEnvVars -@c ------------------------------ end CONFIGURATION VARS - diff --git a/contrib/binutils/ld/emultempl/stringify.sed b/contrib/binutils/ld/emultempl/stringify.sed deleted file mode 100644 index a526d3ffc4c5..000000000000 --- a/contrib/binutils/ld/emultempl/stringify.sed +++ /dev/null @@ -1,4 +0,0 @@ -s/["\\]/\\&/g -s/$/\\n\\/ -1 s/^/"/ -$ s/$/n"/ diff --git a/contrib/binutils/libiberty/alloca-botch.h b/contrib/binutils/libiberty/alloca-botch.h deleted file mode 100644 index c909573f58c6..000000000000 --- a/contrib/binutils/libiberty/alloca-botch.h +++ /dev/null @@ -1,5 +0,0 @@ -/* RS/6000 AIX botched alloca and requires a pragma, which ordinary compilers - throw up about, so we have to put it in a specially-configured file. - Like this one. */ - -#pragma alloca diff --git a/contrib/binutils/libiberty/alloca-norm.h b/contrib/binutils/libiberty/alloca-norm.h deleted file mode 100644 index bda4fc049adf..000000000000 --- a/contrib/binutils/libiberty/alloca-norm.h +++ /dev/null @@ -1,25 +0,0 @@ -/* "Normal" configuration for alloca. */ - -#ifdef __GNUC__ -#ifndef alloca -#define alloca __builtin_alloca -#endif -#else /* ! defined (__GNUC__) */ -#if defined (sparc) && defined (sun) -#include -#ifdef __STDC__ -extern void *__builtin_alloca(); -#else /* ! defined (__STDC__) */ -extern char *__builtin_alloca(); /* Stupid include file doesn't declare it */ -#endif /* ! defined (__STDC__) */ -#else /* ! defined (sparc) || ! defined (sun) */ -#ifdef __STDC__ -PTR alloca (size_t); -#else /* ! defined (__STDC__) */ -PTR alloca (); /* must agree with functions.def */ -#endif /* ! defined (__STDC__) */ -#endif /* ! defined (sparc) || ! defined (sun) */ -#ifdef _WIN32 -#include -#endif -#endif /* ! defined (__GNUC__) */ diff --git a/contrib/binutils/libiberty/config/mh-sysv b/contrib/binutils/libiberty/config/mh-sysv deleted file mode 100644 index eb102d550108..000000000000 --- a/contrib/binutils/libiberty/config/mh-sysv +++ /dev/null @@ -1 +0,0 @@ -RANLIB=true diff --git a/contrib/binutils/libiberty/config/mh-sysv4 b/contrib/binutils/libiberty/config/mh-sysv4 deleted file mode 100644 index 4d1aa3cd61d5..000000000000 --- a/contrib/binutils/libiberty/config/mh-sysv4 +++ /dev/null @@ -1,3 +0,0 @@ -HDEFINES = -DHAVE_SYSCONF -RANLIB=true -INSTALL = cp diff --git a/contrib/binutils/libiberty/config/mt-mingw32 b/contrib/binutils/libiberty/config/mt-mingw32 deleted file mode 100644 index 2fb17d783d03..000000000000 --- a/contrib/binutils/libiberty/config/mt-mingw32 +++ /dev/null @@ -1,27 +0,0 @@ -# Mingw32 target Makefile fragment. -# The autoconfiguration fails for a Mingw32 target, because of an -# incompatible definition of sys_errlist, which is imported from a DLL. -# Therefore, we compute the dependencies by hand. - -HDEFINES = -DNO_SYS_PARAM_H -DNO_SYS_FILE_H -CONFIG_H = mgconfig.h -NEEDED_LIST = mgneeded-list - -mgconfig.h: Makefile - if [ -f ../newlib/Makefile ]; then \ - $(MAKE) $(FLAGS_TO_PASS) xconfig.h; \ - cp xconfig.h mgconfig.h; \ - else \ - echo "#define NEED_sys_siglist 1" >>mgconfig.h; \ - echo "#define NEED_strsignal 1" >>mgconfig.h; \ - echo "#define NEED_psignal 1" >>mgconfig.h; \ - echo "#define NEED_basename 1" >>mgconfig.h; \ - fi - -mgneeded-list: Makefile - if [ -f ../newlib/Makefile ]; then \ - $(MAKE) $(FLAGS_TO_PASS) xneeded-list; \ - cp xneeded-list mgneeded-list; \ - else \ - echo getopt.o vasprintf.o >mgneeded-list; \ - fi diff --git a/contrib/binutils/libiberty/dummy.c b/contrib/binutils/libiberty/dummy.c deleted file mode 100644 index 08da647e30eb..000000000000 --- a/contrib/binutils/libiberty/dummy.c +++ /dev/null @@ -1,49 +0,0 @@ -#include - -#ifdef __STDC__ -#include -#define clock_t unsigned long -#define DEF(NAME, RETURN_TYPE, ARGLIST, ARGS) extern RETURN_TYPE NAME (ARGS); -#define DEFFUNC(NAME, RETURN_TYPE, ARGLIST, ARGS) extern RETURN_TYPE NAME (ARGS); -#else -#define void int -#define size_t unsigned long -#define clock_t unsigned long -#define DEF(NAME, RETURN_TYPE, ARGLIST, ARGS) extern RETURN_TYPE NAME (); -#define DEFFUNC(NAME, RETURN_TYPE, ARGLIST, ARGS) extern RETURN_TYPE NAME (); -#endif - -#define DEFVAR(NAME,DECL,USE) extern DECL; - -#define NOTHING /*nothing*/ - -#include "alloca-conf.h" -#include "functions.def" - -/* Always use our: getopt.o getopt1.o obstack.o spaces.o */ - -int -main (argc, argv) - int argc; char **argv; -{ - -/* Create a dummy function call for each DEF-defined function. */ - -#undef DEF -#undef DEFVAR -#undef DEFFUNC -#undef AND -#define AND = 0; -/* ARGS expands into a set of declaration. NAME ARG_LIST expands - info a function call that uses those variables as actual parameters. - If the function has been DEF'ed correctly, we can pass the right - number and types of parameters, which is nice. (E.g. gcc may - otherwise complain about the wrong number of parameters to certain - builtins.) */ -#define DEF(NAME, RETURN_TYPE, ARG_LIST, ARGS) { ARGS; NAME ARG_LIST; } -#define DEFVAR(NAME, DECL, USE) { USE; } -#define DEFFUNC(NAME, RETURN_TYPE, ARG_LIST, ARGS) { ARGS; NAME ARG_LIST; } -#include "functions.def" - - return (0); -} diff --git a/contrib/binutils/libiberty/functions.def b/contrib/binutils/libiberty/functions.def deleted file mode 100644 index 0f13f107868e..000000000000 --- a/contrib/binutils/libiberty/functions.def +++ /dev/null @@ -1,70 +0,0 @@ -/* - * List of function definitions that may *optionally* be included - * in libiberty.a. The function names must match the filenames, - * e.g. bzero() is defined in bzero.c. (While each file can contain - * extra functions, do not list them.) - * - * In the default libiberty configuration, these object files - * (e.g bzero.o) are included if and only if cc fails to find - * the corresponding function in libc. - */ - -DEF(asprintf, int, (), NOTHING) -DEF(atexit, int, (f), void (*f)()) -DEF(bcmp, int, (s1, s2, length), char *s1 AND char *s2 AND int length ) -DEF(bcopy, void, (s1, s2, length), char *s1 AND char *s2 AND int length ) -DEF(bzero, void, (s, length), char *s AND int length) -DEF(clock, clock_t, (), NOTHING) -DEF(getopt, int, (argc, argv, optstring), - int argc AND char **argv AND CONST char *optstring) -DEF(getpagesize, int , (), NOTHING) -DEF(getcwd, char*, (buf, len), char *buf AND int len) -DEF(index, char*, (s, c), char *s AND int c) -DEF(insque, void, (), NOTHING) -DEF(memchr, PTR, (s, c, length), CONST PTR s AND int c AND size_t length) -DEF(memcmp, int, (s1, s2, length), - CONST PTR s1 AND CONST PTR s2 AND size_t length) -DEF(memcpy, PTR, (s1, s2, length), PTR s1 AND CONST PTR s2 AND size_t length) -DEF(memmove, PTR, (s1, s2, length), PTR s1 AND CONST PTR s2 AND size_t length) -DEF(memset, PTR, (s, val, length), PTR s AND int val AND size_t length ) -DEF(random, long int, (), NOTHING) -DEF(rename, int, (f, t), char *f AND char *t) -DEF(rindex, char*, (s, c), char *s AND int c) -DEF(strcasecmp, int, (s1, s2), char *s1 AND char *s2) -DEF(strncasecmp, int, (s1, s2, n), char *s1 AND char *s2 AND int n) -DEF(strchr, char*, (s, c), CONST char *s AND int c) -DEF(strdup, char*, (s1), char * s1) -DEF(strrchr, char*, (s, c), CONST char *s AND int c) -DEF(strstr, char*, (), NOTHING) -DEF(strtod, double, (), NOTHING) -DEF(strtol, long, (), NOTHING) -DEF(strtoul, unsigned long, (), NOTHING) -DEF(tmpnam, char *, (s), char * s) -DEF(vfork, int, (), NOTHING) -DEF(vfprintf, int, (), NOTHING) -DEF(vprintf, int, (), NOTHING) -DEF(vsprintf, int, (), NOTHING) -DEF(sigsetmask, int, (), NOTHING) -DEF(alloca, PTR, (size), size_t size) -DEF(waitpid, int, (pid, statp, opts), int pid AND int* statp AND int opts ) -DEF(vasprintf, int, (), NOTHING) - -/* List of global variables that we want to look for in the host - environment, and to generate an entry NEED_ in config.h - if they are not found. The first arg is the variable name, the - second arg is how to declare the variable, and the third is how to - use it. */ - -DEFVAR(sys_nerr, int sys_nerr, sys_nerr = 0) -DEFVAR(sys_errlist, char *sys_errlist[], sys_errlist[0] = 0) -DEFVAR(sys_siglist, char *sys_siglist[], sys_siglist[0] = 0) - -/* List of global functions that we want to look for in the host - environment, and to generate an entry NEED_ in config.h - if they are not found. */ - -DEFFUNC(strerror, char*, (errnoval), int errnoval) -DEFFUNC(psignal, void, (signo, message), unsigned signo AND char *message) -DEFFUNC(basename, char *, (name), CONST char *name) -DEFFUNC(on_exit, void, (f, arg), void (*f)() AND char *arg) -DEFFUNC(strsignal, const char *, (signo), int signo) diff --git a/contrib/binutils/opcodes/acconfig.h b/contrib/binutils/opcodes/acconfig.h deleted file mode 100644 index ef2f4966c1bd..000000000000 --- a/contrib/binutils/opcodes/acconfig.h +++ /dev/null @@ -1,6 +0,0 @@ - -/* Name of package. */ -#undef PACKAGE - -/* Version of package. */ -#undef VERSION -- cgit v1.2.3