--- /dev/null Tue Jun 1 11:25:19 1999 +++ gdb.new/bfd/cpu-s390.c Fri Oct 13 13:49:45 2000 @@ -0,0 +1,40 @@ +/* BFD support for the s390 processor. + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Carl B. Pedersen and Martin Schwidefsky. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" + +const bfd_arch_info_type bfd_s390_arch = +{ + 32, /* bits in a word */ + 32, /* bits in an address */ + 8, /* bits in a byte */ + bfd_arch_s390, + bfd_mach_s390_esa, + "s390", + "s390:390", + 3, /* section alignment power */ + true, /* the default */ + bfd_default_compatible, + bfd_default_scan, + NULL +}; --- /dev/null Tue Jun 1 11:25:19 1999 +++ gdb.new/bfd/elf32-s390.c Fri Oct 13 13:49:45 2000 @@ -0,0 +1,2078 @@ +/* IBM S/390-specific support for 32-bit ELF + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Carl B. Pedersen and Martin Schwidefsky. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "libbfd.h" +#include "elf-bfd.h" +#include "elf/s390.h" + +#define USE_RELA 1 /* We want RELA relocations, not REL. */ + +static reloc_howto_type *elf32_s390_reloc_type_lookup + PARAMS ((bfd *, bfd_reloc_code_real_type)); +static void elf32_s390_info_to_howto + PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); +static boolean elf_s390_is_local_label_name PARAMS ((bfd *, const char *)); +static struct bfd_hash_entry *elf_s390_link_hash_newfunc + PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); +static struct bfd_link_hash_table *elf_s390_link_hash_table_create + PARAMS ((bfd *)); +static boolean elf32_s390_check_relocs + PARAMS ((bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *)); +static boolean elf32_s390_adjust_dynamic_symbol + PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); +static boolean elf32_s390_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +static boolean elf32_s390_relocate_section + PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, + Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); +static boolean elf32_s390_finish_dynamic_symbol + PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, + Elf_Internal_Sym *)); +static boolean elf32_s390_finish_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +static boolean elf32_s390_merge_private_bfd_data PARAMS ((bfd *, bfd *)); + +/* The relocation "howto" table. */ + +static bfd_reloc_status_type s390_elf_notsupported_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); + +reloc_howto_type _bfd_s390_elf_howto_table[] = +{ + HOWTO (R_390_NONE, /* type */ + 0, /* rightshift */ + 0, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_390_NONE", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + false), /* pcrel_offset */ + + HOWTO(R_390_8, 0, 0, 8, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_8", false, 0,0x000000ff, false), + HOWTO(R_390_12, 0, 1, 12, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_12", false, 0,0x00000fff, false), + HOWTO(R_390_16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_16", false, 0,0x0000ffff, false), + HOWTO(R_390_32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_32", false, 0,0xffffffff, false), + HOWTO(R_390_PC32, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC32", false, 0,0xffffffff, true), + HOWTO(R_390_GOT12, 0, 1, 12, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT12", false, 0,0x00000fff, false), + HOWTO(R_390_GOT32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT32", false, 0,0xffffffff, false), + HOWTO(R_390_PLT32, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT32", false, 0,0xffffffff, true), + HOWTO(R_390_COPY, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_COPY", false, 0,0xffffffff, false), + HOWTO(R_390_GLOB_DAT, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GLOB_DAT",false, 0,0xffffffff, false), + HOWTO(R_390_JMP_SLOT, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_JMP_SLOT",false, 0,0xffffffff, false), + HOWTO(R_390_RELATIVE, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_RELATIVE",false, 0,0xffffffff, false), + HOWTO(R_390_GOTOFF, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTOFF", false, 0,0xffffffff, false), + HOWTO(R_390_GOTPC, 0, 2, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOTPC", false, 0,0xffffffff, true), + HOWTO(R_390_GOT16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_GOT16", false, 0,0x0000ffff, false), + HOWTO(R_390_PC16, 0, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC16", false, 0,0x0000ffff, true), + HOWTO(R_390_PC16DBL, 1, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PC16DBL", false, 0,0x0000ffff, true), + HOWTO(R_390_PLT16DBL, 1, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_390_PLT16DBL", false, 0,0x0000ffff, true), +}; + +/* GNU extension to record C++ vtable hierarchy. */ +static reloc_howto_type elf32_s390_vtinherit_howto = + HOWTO (R_390_GNU_VTINHERIT, 0,2,0,false,0,complain_overflow_dont, NULL, "R_390_GNU_VTINHERIT", false,0, 0, false); +static reloc_howto_type elf32_s390_vtentry_howto = + HOWTO (R_390_GNU_VTENTRY, 0,2,0,false,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_390_GNU_VTENTRY", false,0,0, false); + +static reloc_howto_type * +elf32_s390_reloc_type_lookup (abfd, code) + bfd *abfd ATTRIBUTE_UNUSED; + bfd_reloc_code_real_type code; +{ + switch (code) { + case BFD_RELOC_NONE: + return &_bfd_s390_elf_howto_table[(int) R_390_NONE]; + case BFD_RELOC_8: + return &_bfd_s390_elf_howto_table[(int) R_390_8]; + case BFD_RELOC_390_12: + return &_bfd_s390_elf_howto_table[(int) R_390_12]; + case BFD_RELOC_16: + return &_bfd_s390_elf_howto_table[(int) R_390_16]; + case BFD_RELOC_32: + return &_bfd_s390_elf_howto_table[(int) R_390_32]; + case BFD_RELOC_CTOR: + return &_bfd_s390_elf_howto_table[(int) R_390_32]; + case BFD_RELOC_32_PCREL: + return &_bfd_s390_elf_howto_table[(int) R_390_PC32]; + case BFD_RELOC_390_GOT12: + return &_bfd_s390_elf_howto_table[(int) R_390_GOT12]; + case BFD_RELOC_32_GOT_PCREL: + return &_bfd_s390_elf_howto_table[(int) R_390_GOT32]; + case BFD_RELOC_390_PLT32: + return &_bfd_s390_elf_howto_table[(int) R_390_PLT32]; + case BFD_RELOC_390_COPY: + return &_bfd_s390_elf_howto_table[(int) R_390_COPY]; + case BFD_RELOC_390_GLOB_DAT: + return &_bfd_s390_elf_howto_table[(int) R_390_GLOB_DAT]; + case BFD_RELOC_390_JMP_SLOT: + return &_bfd_s390_elf_howto_table[(int) R_390_JMP_SLOT]; + case BFD_RELOC_390_RELATIVE: + return &_bfd_s390_elf_howto_table[(int) R_390_RELATIVE]; + case BFD_RELOC_32_GOTOFF: + return &_bfd_s390_elf_howto_table[(int) R_390_GOTOFF]; + case BFD_RELOC_390_GOTPC: + return &_bfd_s390_elf_howto_table[(int) R_390_GOTPC]; + case BFD_RELOC_390_GOT16: + return &_bfd_s390_elf_howto_table[(int) R_390_GOT16]; + case BFD_RELOC_16_PCREL: + return &_bfd_s390_elf_howto_table[(int) R_390_PC16]; + case BFD_RELOC_390_PC16DBL: + return &_bfd_s390_elf_howto_table[(int) R_390_PC16DBL]; + case BFD_RELOC_390_PLT16DBL: + return &_bfd_s390_elf_howto_table[(int) R_390_PLT16DBL]; + case BFD_RELOC_VTABLE_INHERIT: + return &elf32_s390_vtinherit_howto; + case BFD_RELOC_VTABLE_ENTRY: + return &elf32_s390_vtentry_howto; + default: + break; + } + return 0; +} + +/* We need to use ELF32_R_TYPE so we have our own copy of this function, + and elf32-s390.c has its own copy. */ + +static void +elf32_s390_info_to_howto (abfd, cache_ptr, dst) + bfd *abfd ATTRIBUTE_UNUSED; + arelent *cache_ptr; + Elf_Internal_Rela *dst; +{ + switch (ELF32_R_TYPE(dst->r_info)) + { + case R_390_GNU_VTINHERIT: + cache_ptr->howto = &elf32_s390_vtinherit_howto; + break; + + case R_390_GNU_VTENTRY: + cache_ptr->howto = &elf32_s390_vtentry_howto; + break; + + default: + BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_390_max); + cache_ptr->howto = &_bfd_s390_elf_howto_table[ELF32_R_TYPE(dst->r_info)]; + } +} + +/* For unsupported relocs. */ + +static bfd_reloc_status_type +s390_elf_notsupported_reloc (abfd, + reloc_entry, + symbol, + data, + input_section, + output_bfd, + error_message) + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; +{ + return bfd_reloc_notsupported; +} + + + +static boolean +elf_s390_is_local_label_name (abfd, name) + bfd *abfd; + const char *name; +{ + if (name[0] == '.' && name[1] == 'X') + return true; + + return _bfd_elf_is_local_label_name (abfd, name); +} + +/* Functions for the 390 ELF linker. */ + +/* The name of the dynamic interpreter. This is put in the .interp + section. */ + +#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" + +/* The nop opcode we use. */ + +#define s390_NOP 0x07070707 + + +/* The size in bytes of the first entry in the procedure linkage table. */ +#define PLT_FIRST_ENTRY_SIZE 32 +/* The size in bytes of an entry in the procedure linkage table. */ +#define PLT_ENTRY_SIZE 32 + +#define GOT_ENTRY_SIZE 4 + +/* The first three entries in a procedure linkage table are reserved, + and the initial contents are unimportant (we zero them out). + Subsequent entries look like this. See the SVR4 ABI 386 + supplement to see how this works. */ + +/* For the s390, simple addr offset can only be 0 - 4096. + To use the full 2 GB address space, several instructions + are needed to load an address in a register and execute + a branch( or just saving the address) + + Furthermore, only r 0 and 1 are free to use!!! */ + +/* The first 3 words in the GOT are then reserved. + Word 0 is the address of the dynamic table. + Word 1 is a pointer to a structure describing the object + Word 2 is used to point to the loader entry address. + + The code for position independand PLT entries looks like this: + + r12 holds addr of the current GOT at entry to the PLT + + The GOT holds the address in the PLT to be executed. + The loader then gets: + 24(15) = Pointer to the structure describing the object. + 28(15) = Offset in symbol table + + The loader must then find the module where the function is + and insert the address in the GOT. + + Note: 390 can only address +- 64 K relative. + We check if offset > 65536, then make a relative branch -64xxx + back to a previous defined branch + + +PLT1: BASR 1,0 # 2 bytes + L 1,22(1) # 4 bytes Load offset in GOT in r 1 + L 1,(1,12) # 4 bytes Load address from GOT in r1 + BCR 15,1 # 2 bytes Jump to address +RET1: BASR 1,0 # 2 bytes Return from GOT 1st time + L 1,14(1) # 4 bytes Load offset in symol table in r1 + BRC 15,-x # 4 bytes Jump to start of PLT + .word 0 # 2 bytes filler + .long ? # 4 bytes offset in GOT + .long ? # 4 bytes offset into symbol table + +Total = 32 bytes per PLT entry + + The code for static build PLT entries looks like this: + +PLT1: BASR 1,0 # 2 bytes + L 1,22(1) # 4 bytes Load address of GOT entry + L 1,0(0,1) # 4 bytes Load address from GOT in r1 + BCR 15,1 # 2 bytes Jump to address +RET1: BASR 1,0 # 2 bytes Return from GOT 1st time + L 1,14(1) # 4 bytes Load offset in symbol table in r1 + BRC 15,-x # 4 bytes Jump to start of PLT + .word 0 # 2 bytes filler + .long ? # 4 bytes address of GOT entry + .long ? # 4 bytes offset into symbol table */ + +#define PLT_PIC_ENTRY_WORD0 0x0d105810 +#define PLT_PIC_ENTRY_WORD1 0x10165811 +#define PLT_PIC_ENTRY_WORD2 0xc00007f1 +#define PLT_PIC_ENTRY_WORD3 0x0d105810 +#define PLT_PIC_ENTRY_WORD4 0x100ea7f4 + +#define PLT_ENTRY_WORD0 0x0d105810 +#define PLT_ENTRY_WORD1 0x10165810 +#define PLT_ENTRY_WORD2 0x100007f1 +#define PLT_ENTRY_WORD3 0x0d105810 +#define PLT_ENTRY_WORD4 0x100ea7f4 + +/* The first PLT entry pushes the offset into the symbol table + from R1 onto the stack at 8(15) and the loader object info + at 12(15), loads the loader address in R1 and jumps to it. */ + +/* The first entry in the PLT for PIC code: + +PLT0: + ST 1,28(15) # R1 has offset into symbol table + L 1,4(12) # Get loader ino(object struct address) + ST 1,24(15) # Store address + L 1,8(12) # Entry address of loader in R1 + BR 1 # Jump to loader + + The first entry in the PLT for static code: + +PLT0: + ST 1,28(15) # R1 has offset into symbol table + BASR 1,0 + L 1,18(0,1) # Get address of GOT + MVC 24(4,15),4(1) # Move loader ino to stack + L 1,8(1) # Get address of loader + BR 1 # Jump to loader + .word 0 # filler + .long got # address of GOT */ + +#define PLT_PIC_FIRST_ENTRY_WORD0 0x5010f01c +#define PLT_PIC_FIRST_ENTRY_WORD1 0x5810c004 +#define PLT_PIC_FIRST_ENTRY_WORD2 0x5010f018 +#define PLT_PIC_FIRST_ENTRY_WORD3 0x5810c008 +#define PLT_PIC_FIRST_ENTRY_WORD4 0x07f10000 + +#define PLT_FIRST_ENTRY_WORD0 0x5010f01c +#define PLT_FIRST_ENTRY_WORD1 0x0d105810 +#define PLT_FIRST_ENTRY_WORD2 0x1012D203 +#define PLT_FIRST_ENTRY_WORD3 0xf0181004 +#define PLT_FIRST_ENTRY_WORD4 0x58101008 +#define PLT_FIRST_ENTRY_WORD5 0x07f10000 + +/* The s390 linker needs to keep track of the number of relocs that it + decides to copy in check_relocs for each symbol. This is so that + it can discard PC relative relocs if it doesn't need them when + linking with -Bsymbolic. We store the information in a field + extending the regular ELF linker hash table. */ + +/* This structure keeps track of the number of PC relative relocs we + have copied for a given symbol. */ + +struct elf_s390_pcrel_relocs_copied +{ + /* Next section. */ + struct elf_s390_pcrel_relocs_copied *next; + /* A section in dynobj. */ + asection *section; + /* Number of relocs copied in this section. */ + bfd_size_type count; +}; + +/* s390 ELF linker hash entry. */ + +struct elf_s390_link_hash_entry +{ + struct elf_link_hash_entry root; + + /* Number of PC relative relocs copied for this symbol. */ + struct elf_s390_pcrel_relocs_copied *pcrel_relocs_copied; +}; + +/* s390 ELF linker hash table. */ + +struct elf_s390_link_hash_table +{ + struct elf_link_hash_table root; +}; + +/* Declare this now that the above structures are defined. */ + +static boolean elf_s390_discard_copies + PARAMS ((struct elf_s390_link_hash_entry *, PTR)); + +/* Traverse an s390 ELF linker hash table. */ + +#define elf_s390_link_hash_traverse(table, func, info) \ + (elf_link_hash_traverse \ + (&(table)->root, \ + (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \ + (info))) + +/* Get the s390 ELF linker hash table from a link_info structure. */ + +#define elf_s390_hash_table(p) \ + ((struct elf_s390_link_hash_table *) ((p)->hash)) + +/* Create an entry in an s390 ELF linker hash table. */ + +static struct bfd_hash_entry * +elf_s390_link_hash_newfunc (entry, table, string) + struct bfd_hash_entry *entry; + struct bfd_hash_table *table; + const char *string; +{ + struct elf_s390_link_hash_entry *ret = + (struct elf_s390_link_hash_entry *) entry; + + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (ret == (struct elf_s390_link_hash_entry *) NULL) + ret = ((struct elf_s390_link_hash_entry *) + bfd_hash_allocate (table, + sizeof (struct elf_s390_link_hash_entry))); + if (ret == (struct elf_s390_link_hash_entry *) NULL) + return (struct bfd_hash_entry *) ret; + + /* Call the allocation method of the superclass. */ + ret = ((struct elf_s390_link_hash_entry *) + _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, + table, string)); + if (ret != (struct elf_s390_link_hash_entry *) NULL) + { + ret->pcrel_relocs_copied = NULL; + } + + return (struct bfd_hash_entry *) ret; +} + +/* Create an s390 ELF linker hash table. */ + +static struct bfd_link_hash_table * +elf_s390_link_hash_table_create (abfd) + bfd *abfd; +{ + struct elf_s390_link_hash_table *ret; + + ret = ((struct elf_s390_link_hash_table *) + bfd_alloc (abfd, sizeof (struct elf_s390_link_hash_table))); + if (ret == (struct elf_s390_link_hash_table *) NULL) + return NULL; + + if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, + elf_s390_link_hash_newfunc)) + { + bfd_release (abfd, ret); + return NULL; + } + + return &ret->root.root; +} + + +/* Look through the relocs for a section during the first phase, and + allocate space in the global offset table or procedure linkage + table. */ + +static boolean +elf32_s390_check_relocs (abfd, info, sec, relocs) + bfd *abfd; + struct bfd_link_info *info; + asection *sec; + const Elf_Internal_Rela *relocs; +{ + bfd *dynobj; + Elf_Internal_Shdr *symtab_hdr; + struct elf_link_hash_entry **sym_hashes; + bfd_vma *local_got_offsets; + const Elf_Internal_Rela *rel; + const Elf_Internal_Rela *rel_end; + asection *sgot; + asection *srelgot; + asection *sreloc; + + if (info->relocateable) + return true; + + dynobj = elf_hash_table (info)->dynobj; + symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (abfd); + local_got_offsets = elf_local_got_offsets (abfd); + + sgot = NULL; + srelgot = NULL; + sreloc = NULL; + + rel_end = relocs + sec->reloc_count; + for (rel = relocs; rel < rel_end; rel++) + { + unsigned long r_symndx; + struct elf_link_hash_entry *h; + + r_symndx = ELF32_R_SYM (rel->r_info); + if (r_symndx < symtab_hdr->sh_info) + h = NULL; + else + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + + /* Some relocs require a global offset table. */ + if (dynobj == NULL) + { + switch (ELF32_R_TYPE (rel->r_info)) + { + case R_390_GOT12: + case R_390_GOT16: + case R_390_GOT32: + case R_390_GOTOFF: + case R_390_GOTPC: + elf_hash_table (info)->dynobj = dynobj = abfd; + if (! _bfd_elf_create_got_section (dynobj, info)) + return false; + break; + + default: + break; + } + } + + + switch (ELF32_R_TYPE (rel->r_info)) + { + case R_390_GOT12: + case R_390_GOT16: + case R_390_GOT32: + /* This symbol requires a global offset table entry. */ + + if (sgot == NULL) + { + sgot = bfd_get_section_by_name (dynobj, ".got"); + BFD_ASSERT (sgot != NULL); + } + + + if (srelgot == NULL + && (h != NULL || info->shared)) + { + srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + if (srelgot == NULL) + { + srelgot = bfd_make_section (dynobj, ".rela.got"); + if (srelgot == NULL + || ! bfd_set_section_flags (dynobj, srelgot, + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)) + || ! bfd_set_section_alignment (dynobj, srelgot, 2)) + return false; + } + } + + if (h != NULL) + { + if (h->got.offset != (bfd_vma) -1) + { + /* We have already allocated space in the .got. */ + break; + } + h->got.offset = sgot->_raw_size; + + /* Make sure this symbol is output as a dynamic symbol. */ + if (h->dynindx == -1) + { + if (! bfd_elf32_link_record_dynamic_symbol (info, h)) + return false; + } + + srelgot->_raw_size += sizeof (Elf32_External_Rela); + } + else + { + /* This is a global offset table entry for a local + symbol. */ + if (local_got_offsets == NULL) + { + size_t size; + register unsigned int i; + + size = symtab_hdr->sh_info * sizeof (bfd_vma); + local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size); + if (local_got_offsets == NULL) + return false; + elf_local_got_offsets (abfd) = local_got_offsets; + for (i = 0; i < symtab_hdr->sh_info; i++) + local_got_offsets[i] = (bfd_vma) -1; + } + if (local_got_offsets[r_symndx] != (bfd_vma) -1) + { + /* We have already allocated space in the .got. */ + break; + } + local_got_offsets[r_symndx] = sgot->_raw_size; + + if (info->shared) + { + /* If we are generating a shared object, we need to + output a R_390_RELATIVE reloc so that the dynamic + linker can adjust this GOT entry. */ + srelgot->_raw_size += sizeof (Elf32_External_Rela); + } + } + + sgot->_raw_size += GOT_ENTRY_SIZE; + + break; + + case R_390_PLT16DBL: + case R_390_PLT32: + /* This symbol requires a procedure linkage table entry. We + actually build the entry in adjust_dynamic_symbol, + because this might be a case of linking PIC code which is + never referenced by a dynamic object, in which case we + don't need to generate a procedure linkage table entry + after all. */ + + /* If this is a local symbol, we resolve it directly without + creating a procedure linkage table entry. */ + if (h == NULL) + continue; + + h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; + + break; + + case R_390_8: + case R_390_16: + case R_390_32: + case R_390_PC16: + case R_390_PC16DBL: + case R_390_PC32: + if (h != NULL) + h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; + + /* If we are creating a shared library, and this is a reloc + against a global symbol, or a non PC relative reloc + against a local symbol, then we need to copy the reloc + into the shared library. However, if we are linking with + -Bsymbolic, we do not need to copy a reloc against a + global symbol which is defined in an object we are + including in the link (i.e., DEF_REGULAR is set). At + this point we have not seen all the input files, so it is + possible that DEF_REGULAR is not set now but will be set + later (it is never cleared). We account for that + possibility below by storing information in the + pcrel_relocs_copied field of the hash table entry. */ + if (info->shared + && ((ELF32_R_TYPE (rel->r_info) != R_390_PC16 && + ELF32_R_TYPE (rel->r_info) != R_390_PC16DBL && + ELF32_R_TYPE (rel->r_info) != R_390_PC32) + || (h != NULL + && (! info->symbolic + || (h->elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0)))) + { + /* When creating a shared object, we must copy these + reloc types into the output file. We create a reloc + section in dynobj and make room for this reloc. */ + if (sreloc == NULL) + { + const char *name; + + name = (bfd_elf_string_from_elf_section + (abfd, + elf_elfheader (abfd)->e_shstrndx, + elf_section_data (sec)->rel_hdr.sh_name)); + if (name == NULL) + return false; + + BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + && strcmp (bfd_get_section_name (abfd, sec), + name + 5) == 0); + + sreloc = bfd_get_section_by_name (dynobj, name); + if (sreloc == NULL) + { + flagword flags; + + sreloc = bfd_make_section (dynobj, name); + flags = (SEC_HAS_CONTENTS | SEC_READONLY + | SEC_IN_MEMORY | SEC_LINKER_CREATED); + if ((sec->flags & SEC_ALLOC) != 0) + flags |= SEC_ALLOC | SEC_LOAD; + if (sreloc == NULL + || ! bfd_set_section_flags (dynobj, sreloc, flags) + || ! bfd_set_section_alignment (dynobj, sreloc, 2)) + return false; + } + } + + sreloc->_raw_size += sizeof (Elf32_External_Rela); + + /* If we are linking with -Bsymbolic, and this is a + global symbol, we count the number of PC relative + relocations we have entered for this symbol, so that + we can discard them again if the symbol is later + defined by a regular object. Note that this function + is only called if we are using an elf_s390 linker + hash table, which means that h is really a pointer to + an elf_s390_link_hash_entry. */ + if (h != NULL && info->symbolic + && (ELF32_R_TYPE (rel->r_info) == R_390_PC16 || + ELF32_R_TYPE (rel->r_info) == R_390_PC16DBL || + ELF32_R_TYPE (rel->r_info) == R_390_PC32)) + { + struct elf_s390_link_hash_entry *eh; + struct elf_s390_pcrel_relocs_copied *p; + + eh = (struct elf_s390_link_hash_entry *) h; + + for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next) + if (p->section == sreloc) + break; + + if (p == NULL) + { + p = ((struct elf_s390_pcrel_relocs_copied *) + bfd_alloc (dynobj, sizeof *p)); + if (p == NULL) + return false; + p->next = eh->pcrel_relocs_copied; + eh->pcrel_relocs_copied = p; + p->section = sreloc; + p->count = 0; + } + + ++p->count; + } + } + + break; + + /* This relocation describes the C++ object vtable hierarchy. + Reconstruct it for later use during GC. */ + case R_390_GNU_VTINHERIT: + if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) + return false; + break; + + /* This relocation describes which C++ vtable entries are actually + used. Record for later use during GC. */ + case R_390_GNU_VTENTRY: + if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) + return false; + break; + + default: + break; + } + } + + return true; +} + +/* Return the section that should be marked against GC for a given + relocation. */ + +static asection * +elf_s390_gc_mark_hook (abfd, info, rel, h, sym) + bfd *abfd; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + Elf_Internal_Rela *rel; + struct elf_link_hash_entry *h; + Elf_Internal_Sym *sym; +{ + if (h != NULL) + { + switch (ELF32_R_TYPE (rel->r_info)) + { + case R_390_GNU_VTINHERIT: + case R_390_GNU_VTENTRY: + break; + + default: + switch (h->root.type) + { + case bfd_link_hash_defined: + case bfd_link_hash_defweak: + return h->root.u.def.section; + + case bfd_link_hash_common: + return h->root.u.c.p->section; + + default: + break; + } + } + } + else + { + if (!(elf_bad_symtab (abfd) + && ELF_ST_BIND (sym->st_info) != STB_LOCAL) + && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE) + && sym->st_shndx != SHN_COMMON)) + { + return bfd_section_from_elf_index (abfd, sym->st_shndx); + } + } + + return NULL; +} + +/* Update the got entry reference counts for the section being removed. */ + +static boolean +elf_s390_gc_sweep_hook (abfd, info, sec, relocs) + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; +{ + /* ??? It would seem that the existing s390 code does no sort + of reference counting or whatnot on its GOT and PLT entries, + so it is not possible to garbage collect them at this time. */ + + return true; +} + +/* Adjust a symbol defined by a dynamic object and referenced by a + regular object. The current definition is in some section of the + dynamic object, but we're not including those sections. We have to + change the definition to something the rest of the link can + understand. */ + +static boolean +elf32_s390_adjust_dynamic_symbol (info, h) + struct bfd_link_info *info; + struct elf_link_hash_entry *h; +{ + bfd *dynobj; + asection *s; + unsigned int power_of_two; + + dynobj = elf_hash_table (info)->dynobj; + + /* Make sure we know what is going on here. */ + BFD_ASSERT (dynobj != NULL + && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) + || h->weakdef != NULL + || ((h->elf_link_hash_flags + & ELF_LINK_HASH_DEF_DYNAMIC) != 0 + && (h->elf_link_hash_flags + & ELF_LINK_HASH_REF_REGULAR) != 0 + && (h->elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0))); + + /* If this is a function, put it in the procedure linkage table. We + will fill in the contents of the procedure linkage table later + (although we could actually do it here). */ + if (h->type == STT_FUNC + || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) + { + if (! info->shared + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0 + && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0) + { + /* This case can occur if we saw a PLT32 reloc in an input + file, but the symbol was never referred to by a dynamic + object. In such a case, we don't actually need to build + a procedure linkage table, and we can just do a PC32 + reloc instead. */ + BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0); + return true; + } + + /* Make sure this symbol is output as a dynamic symbol. */ + if (h->dynindx == -1) + { + if (! bfd_elf32_link_record_dynamic_symbol (info, h)) + return false; + } + + s = bfd_get_section_by_name (dynobj, ".plt"); + BFD_ASSERT (s != NULL); + + + /* The first entry in .plt is reserved. */ + if (s->_raw_size == 0) + s->_raw_size = PLT_FIRST_ENTRY_SIZE; + + /* If this symbol is not defined in a regular file, and we are + not generating a shared library, then set the symbol to this + location in the .plt. This is required to make function + pointers compare as equal between the normal executable and + the shared library. */ + if (! info->shared + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) + { + h->root.u.def.section = s; + h->root.u.def.value = s->_raw_size; + } + + h->plt.offset = s->_raw_size; + + /* Make room for this entry. */ + s->_raw_size += PLT_ENTRY_SIZE; + + /* We also need to make an entry in the .got.plt section, which + will be placed in the .got section by the linker script. */ + + s = bfd_get_section_by_name (dynobj, ".got.plt"); + BFD_ASSERT (s != NULL); + s->_raw_size += GOT_ENTRY_SIZE; + + /* We also need to make an entry in the .rela.plt section. */ + + s = bfd_get_section_by_name (dynobj, ".rela.plt"); + BFD_ASSERT (s != NULL); + s->_raw_size += sizeof (Elf32_External_Rela); + + return true; + } + + /* If this is a weak symbol, and there is a real definition, the + processor independent code will have arranged for us to see the + real definition first, and we can just use the same value. */ + if (h->weakdef != NULL) + { + BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined + || h->weakdef->root.type == bfd_link_hash_defweak); + h->root.u.def.section = h->weakdef->root.u.def.section; + h->root.u.def.value = h->weakdef->root.u.def.value; + return true; + } + + /* This is a reference to a symbol defined by a dynamic object which + is not a function. */ + + /* If we are creating a shared library, we must presume that the + only references to the symbol are via the global offset table. + For such cases we need not do anything here; the relocations will + be handled correctly by relocate_section. */ + if (info->shared) + return true; + + /* If there are no references to this symbol that do not use the + GOT, we don't need to generate a copy reloc. */ + if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0) + return true; + + /* We must allocate the symbol in our .dynbss section, which will + become part of the .bss section of the executable. There will be + an entry for this symbol in the .dynsym section. The dynamic + object will contain position independent code, so all references + from the dynamic object to this symbol will go through the global + offset table. The dynamic linker will use the .dynsym entry to + determine the address it must put in the global offset table, so + both the dynamic object and the regular object will refer to the + same memory location for the variable. */ + + s = bfd_get_section_by_name (dynobj, ".dynbss"); + BFD_ASSERT (s != NULL); + + /* We must generate a R_390_COPY reloc to tell the dynamic linker + to copy the initial value out of the dynamic object and into the + runtime process image. We need to remember the offset into the + .rel.bss section we are going to use. */ + if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) + { + asection *srel; + + srel = bfd_get_section_by_name (dynobj, ".rela.bss"); + BFD_ASSERT (srel != NULL); + srel->_raw_size += sizeof (Elf32_External_Rela); + h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; + } + + /* We need to figure out the alignment required for this symbol. I + have no idea how ELF linkers handle this. */ + power_of_two = bfd_log2 (h->size); + if (power_of_two > 3) + power_of_two = 3; + + /* Apply the required alignment. */ + s->_raw_size = BFD_ALIGN (s->_raw_size, + (bfd_size_type) (1 << power_of_two)); + if (power_of_two > bfd_get_section_alignment (dynobj, s)) + { + if (! bfd_set_section_alignment (dynobj, s, power_of_two)) + return false; + } + + /* Define the symbol as being at this point in the section. */ + h->root.u.def.section = s; + h->root.u.def.value = s->_raw_size; + + /* Increment the section size to make room for the symbol. */ + s->_raw_size += h->size; + + return true; +} + +/* Set the sizes of the dynamic sections. */ + +static boolean +elf32_s390_size_dynamic_sections (output_bfd, info) + bfd *output_bfd; + struct bfd_link_info *info; +{ + bfd *dynobj; + asection *s; + boolean reltext; + boolean relocs; + boolean plt; + + dynobj = elf_hash_table (info)->dynobj; + BFD_ASSERT (dynobj != NULL); + + if (elf_hash_table (info)->dynamic_sections_created) + { + /* Set the contents of the .interp section to the interpreter. */ + if (! info->shared) + { + s = bfd_get_section_by_name (dynobj, ".interp"); + BFD_ASSERT (s != NULL); + s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; + } + } + else + { + /* We may have created entries in the .rela.got section. + However, if we are not creating the dynamic sections, we will + not actually use these entries. Reset the size of .rela.got, + which will cause it to get stripped from the output file + below. */ + s = bfd_get_section_by_name (dynobj, ".rela.got"); + if (s != NULL) + s->_raw_size = 0; + } + + /* If this is a -Bsymbolic shared link, then we need to discard all + PC relative relocs against symbols defined in a regular object. + We allocated space for them in the check_relocs routine, but we + will not fill them in in the relocate_section routine. */ + if (info->shared && info->symbolic) + elf_s390_link_hash_traverse (elf_s390_hash_table (info), + elf_s390_discard_copies, + (PTR) NULL); + + + /* The check_relocs and adjust_dynamic_symbol entry points have + determined the sizes of the various dynamic sections. Allocate + memory for them. */ + plt = false; + reltext = false; + relocs = false; + for (s = dynobj->sections; s != NULL; s = s->next) + { + const char *name; + boolean strip; + + if ((s->flags & SEC_LINKER_CREATED) == 0) + continue; + + /* It's OK to base decisions on the section name, because none + of the dynobj section names depend upon the input files. */ + name = bfd_get_section_name (dynobj, s); + + strip = false; + + if (strcmp (name, ".plt") == 0) + { + if (s->_raw_size == 0) + { + /* Strip this section if we don't need it; see the + comment below. */ + strip = true; + } + else + { + /* Remember whether there is a PLT. */ + plt = true; + } + } + else if (strncmp (name, ".rela", 5) == 0) + { + if (s->_raw_size == 0) + { + /* If we don't need this section, strip it from the + output file. This is to handle .rela.bss and + .rel.plt. We must create it in + create_dynamic_sections, because it must be created + before the linker maps input sections to output + sections. The linker does that before + adjust_dynamic_symbol is called, and it is that + function which decides whether anything needs to go + into these sections. */ + strip = true; + } + else + { + asection *target; + + /* Remember whether there are any reloc sections other + than .rela.plt. */ + if (strcmp (name, ".rela.plt") != 0) + { + const char *outname; + + relocs = true; + + /* If this relocation section applies to a read only + section, then we probably need a DT_TEXTREL + entry. The entries in the .rela.plt section + really apply to the .got section, which we + created ourselves and so know is not readonly. */ + outname = bfd_get_section_name (output_bfd, + s->output_section); + target = bfd_get_section_by_name (output_bfd, outname + 5); + if (target != NULL + && (target->flags & SEC_READONLY) != 0 + && (target->flags & SEC_ALLOC) != 0) + reltext = true; + } + + /* We use the reloc_count field as a counter if we need + to copy relocs into the output file. */ + s->reloc_count = 0; + } + } + else if (strncmp (name, ".got", 4) != 0) + { + /* It's not one of our sections, so don't allocate space. */ + continue; + } + + if (strip) + { + _bfd_strip_section_from_output (info, s); + continue; + } + + /* Allocate memory for the section contents. */ + s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size); + if (s->contents == NULL && s->_raw_size != 0) + return false; + } + + if (elf_hash_table (info)->dynamic_sections_created) + { + /* Add some entries to the .dynamic section. We fill in the + values later, in elf32_s390_finish_dynamic_sections, but we + must add the entries now so that we get the correct size for + the .dynamic section. The DT_DEBUG entry is filled in by the + dynamic linker and used by the debugger. */ + if (! info->shared) + { + if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0)) + return false; + } + + if (plt) + { + if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0) + || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0) + || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA) + || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0)) + return false; + } + + if (relocs) + { + if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0) + || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0) + || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT, + sizeof (Elf32_External_Rela))) + return false; + } + + if (reltext) + { + if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0)) + return false; + } + } + + return true; +} + +/* This function is called via elf_s390_link_hash_traverse if we are + creating a shared object with -Bsymbolic. It discards the space + allocated to copy PC relative relocs against symbols which are + defined in regular objects. We allocated space for them in the + check_relocs routine, but we won't fill them in in the + relocate_section routine. */ + +/*ARGSUSED*/ +static boolean +elf_s390_discard_copies (h, ignore) + struct elf_s390_link_hash_entry *h; + PTR ignore ATTRIBUTE_UNUSED; +{ + struct elf_s390_pcrel_relocs_copied *s; + + /* We only discard relocs for symbols defined in a regular object. */ + if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) + return true; + + for (s = h->pcrel_relocs_copied; s != NULL; s = s->next) + s->section->_raw_size -= s->count * sizeof (Elf32_External_Rela); + + return true; +} +/* Relocate a 390 ELF section. */ + +static boolean +elf32_s390_relocate_section (output_bfd, info, input_bfd, input_section, + contents, relocs, local_syms, local_sections) + bfd *output_bfd; + struct bfd_link_info *info; + bfd *input_bfd; + asection *input_section; + bfd_byte *contents; + Elf_Internal_Rela *relocs; + Elf_Internal_Sym *local_syms; + asection **local_sections; +{ + bfd *dynobj; + Elf_Internal_Shdr *symtab_hdr; + struct elf_link_hash_entry **sym_hashes; + bfd_vma *local_got_offsets; + asection *sgot; + asection *splt; + asection *sreloc; + Elf_Internal_Rela *rel; + Elf_Internal_Rela *relend; + + dynobj = elf_hash_table (info)->dynobj; + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (input_bfd); + local_got_offsets = elf_local_got_offsets (input_bfd); + + sgot = NULL; + splt = NULL; + sreloc = NULL; + + rel = relocs; + relend = relocs + input_section->reloc_count; + for (; rel < relend; rel++) + { + int r_type; + reloc_howto_type *howto; + unsigned long r_symndx; + struct elf_link_hash_entry *h; + Elf_Internal_Sym *sym; + asection *sec; + bfd_vma relocation; + bfd_reloc_status_type r; + + r_type = ELF32_R_TYPE (rel->r_info); + if (r_type == R_390_GNU_VTINHERIT + || r_type == R_390_GNU_VTENTRY) + continue; + if (r_type < 0 || r_type >= (int) R_390_max) + { + bfd_set_error (bfd_error_bad_value); + return false; + } + howto = _bfd_s390_elf_howto_table + r_type; + + r_symndx = ELF32_R_SYM (rel->r_info); + + if (info->relocateable) + { + /* This is a relocateable link. We don't have to change + anything, unless the reloc is against a section symbol, + in which case we have to adjust according to where the + section symbol winds up in the output section. */ + if (r_symndx < symtab_hdr->sh_info) + { + sym = local_syms + r_symndx; + if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) + { + sec = local_sections[r_symndx]; + rel->r_addend += sec->output_offset + sym->st_value; + } + } + + continue; + } + + /* This is a final link. */ + h = NULL; + sym = NULL; + sec = NULL; + if (r_symndx < symtab_hdr->sh_info) + { + sym = local_syms + r_symndx; + sec = local_sections[r_symndx]; + relocation = (sec->output_section->vma + + sec->output_offset + + sym->st_value); + } + else + { + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + if (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + { + sec = h->root.u.def.section; + if (r_type == R_390_GOTPC + || ((r_type == R_390_PLT16DBL || + r_type == R_390_PLT32) + && h->plt.offset != (bfd_vma) -1) + || ((r_type == R_390_GOT12 || + r_type == R_390_GOT16 || + r_type == R_390_GOT32) + && elf_hash_table (info)->dynamic_sections_created + && (! info->shared + || (! info->symbolic && h->dynindx != -1) + || (h->elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0)) + || (info->shared + && ((! info->symbolic && h->dynindx != -1) + || (h->elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0) + && ( r_type == R_390_8 || + r_type == R_390_16 || + r_type == R_390_32 || + ((r_type == R_390_PC16 || + r_type == R_390_PC16DBL || + r_type == R_390_PC32) && + strcmp (h->root.root.string, + "_GLOBAL_OFFSET_TABLE_") != 0)))) + { + /* In these cases, we don't need the relocation + value. We check specially because in some + obscure cases sec->output_section will be NULL. */ + relocation = 0; + } + else if (sec->output_section == NULL) + { + (*_bfd_error_handler) + (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"), + bfd_get_filename (input_bfd), h->root.root.string, + bfd_get_section_name (input_bfd, input_section)); + relocation = 0; + } + else + relocation = (h->root.u.def.value + + sec->output_section->vma + + sec->output_offset); + } + else if (h->root.type == bfd_link_hash_undefweak) + relocation = 0; + else if (info->shared && !info->symbolic && !info->no_undefined) + relocation = 0; + else + { + if (! ((*info->callbacks->undefined_symbol) + (info, h->root.root.string, input_bfd, + input_section, rel->r_offset, + (!info->shared || info->no_undefined)))) + + return false; + relocation = 0; + } + } + + switch (r_type) + { + case R_390_GOT12: + case R_390_GOT16: + case R_390_GOT32: + /* Relocation is to the entry for this symbol in the global + offset table. */ + if (sgot == NULL) + { + sgot = bfd_get_section_by_name (dynobj, ".got"); + BFD_ASSERT (sgot != NULL); + } + + if (h != NULL) + { + bfd_vma off; + + off = h->got.offset; + BFD_ASSERT (off != (bfd_vma) -1); + + if (! elf_hash_table (info)->dynamic_sections_created + || (info->shared + && (info->symbolic || h->dynindx == -1) + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))) + { + /* This is actually a static link, or it is a + -Bsymbolic link and the symbol is defined + locally, or the symbol was forced to be local + because of a version file. We must initialize + this entry in the global offset table. Since the + offset must always be a multiple of 2, we use the + least significant bit to record whether we have + initialized it already. + + When doing a dynamic link, we create a .rel.got + relocation entry to initialize the value. This + is done in the finish_dynamic_symbol routine. */ + if ((off & 1) != 0) + off &= ~1; + else + { + bfd_put_32 (output_bfd, relocation, + sgot->contents + off); + h->got.offset |= 1; + } + } + relocation = sgot->output_offset + off; + } + else + { + bfd_vma off; + + BFD_ASSERT (local_got_offsets != NULL + && local_got_offsets[r_symndx] != (bfd_vma) -1); + + off = local_got_offsets[r_symndx]; + + /* The offset must always be a multiple of 4. We use + the least significant bit to record whether we have + already generated the necessary reloc. */ + if ((off & 1) != 0) + off &= ~1; + else + { + bfd_put_32 (output_bfd, relocation, sgot->contents + off); + + if (info->shared) + { + asection *srelgot; + Elf_Internal_Rela outrel; + + srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + BFD_ASSERT (srelgot != NULL); + + outrel.r_offset = (sgot->output_section->vma + + sgot->output_offset + + off); + outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE); + outrel.r_addend = relocation; + bfd_elf32_swap_reloca_out (output_bfd, &outrel, + (((Elf32_External_Rela *) + srelgot->contents) + + srelgot->reloc_count)); + ++srelgot->reloc_count; + } + + local_got_offsets[r_symndx] |= 1; + } + + relocation = sgot->output_offset + off; + } + + + break; + + case R_390_GOTOFF: + /* Relocation is relative to the start of the global offset + table. */ + + if (sgot == NULL) + { + sgot = bfd_get_section_by_name (dynobj, ".got"); + BFD_ASSERT (sgot != NULL); + } + + /* Note that sgot->output_offset is not involved in this + calculation. We always want the start of .got. If we + defined _GLOBAL_OFFSET_TABLE in a different way, as is + permitted by the ABI, we might have to change this + calculation. */ + relocation -= sgot->output_section->vma; + + break; + + case R_390_GOTPC: + /* Use global offset table as symbol value. */ + + if (sgot == NULL) + { + sgot = bfd_get_section_by_name (dynobj, ".got"); + BFD_ASSERT (sgot != NULL); + } + + relocation = sgot->output_section->vma; + + break; + + case R_390_PLT16DBL: + case R_390_PLT32: + /* Relocation is to the entry for this symbol in the + procedure linkage table. */ + + /* Resolve a PLT32 reloc against a local symbol directly, + without using the procedure linkage table. */ + if (h == NULL) + break; + + if (h->plt.offset == (bfd_vma) -1) + { + /* We didn't make a PLT entry for this symbol. This + happens when statically linking PIC code, or when + using -Bsymbolic. */ + break; + } + + if (splt == NULL) + { + splt = bfd_get_section_by_name (dynobj, ".plt"); + BFD_ASSERT (splt != NULL); + } + + relocation = (splt->output_section->vma + + splt->output_offset + + h->plt.offset); + + break; + + case R_390_8: + case R_390_16: + case R_390_32: + case R_390_PC16: + case R_390_PC16DBL: + case R_390_PC32: + if (info->shared + && ((r_type != R_390_PC16 && + r_type != R_390_PC16DBL && + r_type != R_390_PC32) + || (h != NULL + && h->dynindx != -1 + && (! info->symbolic + || (h->elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0)))) + { + Elf_Internal_Rela outrel; + boolean skip, relocate; + + /* When generating a shared object, these relocations + are copied into the output file to be resolved at run + time. */ + + if (sreloc == NULL) + { + const char *name; + + name = (bfd_elf_string_from_elf_section + (input_bfd, + elf_elfheader (input_bfd)->e_shstrndx, + elf_section_data (input_section)->rel_hdr.sh_name)); + if (name == NULL) + return false; + + BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + && strcmp (bfd_get_section_name (input_bfd, + input_section), + name + 5) == 0); + + sreloc = bfd_get_section_by_name (dynobj, name); + BFD_ASSERT (sreloc != NULL); + } + + skip = false; + + if (elf_section_data (input_section)->stab_info == NULL) + outrel.r_offset = rel->r_offset; + else + { + bfd_vma off; + + off = (_bfd_stab_section_offset + (output_bfd, &elf_hash_table (info)->stab_info, + input_section, + &elf_section_data (input_section)->stab_info, + rel->r_offset)); + if (off == (bfd_vma) -1) + skip = true; + outrel.r_offset = off; + } + + outrel.r_offset += (input_section->output_section->vma + + input_section->output_offset); + + if (skip) + { + memset (&outrel, 0, sizeof outrel); + relocate = false; + } + else if (r_type == R_390_PC16 || + r_type == R_390_PC16DBL || + r_type == R_390_PC32) + { + BFD_ASSERT (h != NULL && h->dynindx != -1); + relocate = false; + outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); + outrel.r_addend = relocation + rel->r_addend; + } + else + { + /* h->dynindx may be -1 if this symbol was marked to + become local. */ + if (h == NULL + || ((info->symbolic || h->dynindx == -1) + && (h->elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) != 0)) + { + relocate = true; + outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE); + outrel.r_addend = relocation + rel->r_addend; + } + else + { + BFD_ASSERT (h->dynindx != -1); + relocate = false; + outrel.r_info = ELF32_R_INFO (h->dynindx, R_390_32); + outrel.r_addend = relocation + rel->r_addend; + } + } + + bfd_elf32_swap_reloca_out (output_bfd, &outrel, + (((Elf32_External_Rela *) + sreloc->contents) + + sreloc->reloc_count)); + ++sreloc->reloc_count; + + /* If this reloc is against an external symbol, we do + not want to fiddle with the addend. Otherwise, we + need to include the symbol value so that it becomes + an addend for the dynamic reloc. */ + if (! relocate) + continue; + } + + break; + + default: + break; + } + + r = _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, rel->r_offset, + relocation, rel->r_addend); + + if (r != bfd_reloc_ok) + { + switch (r) + { + default: + case bfd_reloc_outofrange: + abort (); + case bfd_reloc_overflow: + { + const char *name; + + if (h != NULL) + name = h->root.root.string; + else + { + name = bfd_elf_string_from_elf_section (input_bfd, + symtab_hdr->sh_link, + sym->st_name); + if (name == NULL) + return false; + if (*name == '\0') + name = bfd_section_name (input_bfd, sec); + } + if (! ((*info->callbacks->reloc_overflow) + (info, name, howto->name, (bfd_vma) 0, + input_bfd, input_section, rel->r_offset))) + return false; + } + break; + } + } + } + + return true; +} + +/* Finish up dynamic symbol handling. We set the contents of various + dynamic sections here. */ + +static boolean +elf32_s390_finish_dynamic_symbol (output_bfd, info, h, sym) + bfd *output_bfd; + struct bfd_link_info *info; + struct elf_link_hash_entry *h; + Elf_Internal_Sym *sym; +{ + bfd *dynobj; + + dynobj = elf_hash_table (info)->dynobj; + + if (h->plt.offset != (bfd_vma) -1) + { + asection *splt; + asection *srela; + Elf_Internal_Rela rela; + bfd_vma relative_offset; + bfd_vma got_offset; + bfd_vma plt_index; + asection *sgot; + + /* This symbol has an entry in the procedure linkage table. Set + it up. */ + + BFD_ASSERT (h->dynindx != -1); + + splt = bfd_get_section_by_name (dynobj, ".plt"); + sgot = bfd_get_section_by_name (dynobj, ".got.plt"); + srela = bfd_get_section_by_name (dynobj, ".rela.plt"); + BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL); + + /* Calc. index no. + Current offset - size first entry / entry size. */ + plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) / PLT_ENTRY_SIZE; + + /* Offset in GOT is PLT index plus GOT headers(3) times 4, + addr & GOT addr. */ + got_offset = (plt_index + 3) * GOT_ENTRY_SIZE; + + /* S390 uses halfwords for relative branch calc! */ + relative_offset = - ((PLT_FIRST_ENTRY_SIZE + + (PLT_ENTRY_SIZE * plt_index) + 18)/2); + /* If offset is > 32768, branch to a previous branch + 390 can only handle +-64 K jumps. */ + if ( -32768 > (int)relative_offset ) + relative_offset = -(((65536/PLT_ENTRY_SIZE-1)*PLT_ENTRY_SIZE)/2); + + /* Fill in the entry in the procedure linkage table. */ + if (!info->shared) + { + bfd_put_32 (output_bfd, PLT_ENTRY_WORD0, + splt->contents + h->plt.offset); + bfd_put_32 (output_bfd, PLT_ENTRY_WORD1, + splt->contents + h->plt.offset + 4); + bfd_put_32 (output_bfd, PLT_ENTRY_WORD2, + splt->contents + h->plt.offset + 8); + bfd_put_32 (output_bfd, PLT_ENTRY_WORD3, + splt->contents + h->plt.offset + 12); + bfd_put_32 (output_bfd, PLT_ENTRY_WORD4, + splt->contents + h->plt.offset + 16); + bfd_put_32 (output_bfd, 0+(relative_offset << 16), + splt->contents + h->plt.offset + 20); + bfd_put_32 (output_bfd, + (sgot->output_section->vma + + sgot->output_offset + + got_offset), + splt->contents + h->plt.offset + 24); + /* Insert offset into reloc. table here. */ + bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela), + splt->contents + h->plt.offset + 28); + } + else + { + bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD0, + splt->contents + h->plt.offset); + bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD1, + splt->contents + h->plt.offset + 4); + bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD2, + splt->contents + h->plt.offset + 8); + bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD3, + splt->contents + h->plt.offset + 12); + bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD4, + splt->contents + h->plt.offset + 16); + bfd_put_32 (output_bfd, 0+(relative_offset << 16), + splt->contents + h->plt.offset + 20); + bfd_put_32 (output_bfd, got_offset, + splt->contents + h->plt.offset + 24); + /* Insert offset into reloc. table here. */ + bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela), + splt->contents + h->plt.offset + 28); + } + + /* Fill in the entry in the .rela.plt section. */ + rela.r_offset = (sgot->output_section->vma + + sgot->output_offset + + got_offset); + rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT); + rela.r_addend = 0; + bfd_elf32_swap_reloca_out (output_bfd, &rela, + ((Elf32_External_Rela *) srela->contents + + plt_index )); + + /* Fill in the entry in the global offset table. + Points to instruction after GOT offset. */ + bfd_put_32 (output_bfd, + (splt->output_section->vma + + splt->output_offset + + h->plt.offset + + 12), + sgot->contents + got_offset); + + + if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) + { + /* Mark the symbol as undefined, rather than as defined in + the .plt section. Leave the value alone. */ + sym->st_shndx = SHN_UNDEF; + } + } + + if (h->got.offset != (bfd_vma) -1) + { + asection *sgot; + asection *srela; + Elf_Internal_Rela rela; + + /* This symbol has an entry in the global offset table. Set it + up. */ + + sgot = bfd_get_section_by_name (dynobj, ".got"); + srela = bfd_get_section_by_name (dynobj, ".rela.got"); + BFD_ASSERT (sgot != NULL && srela != NULL); + + rela.r_offset = (sgot->output_section->vma + + sgot->output_offset + + (h->got.offset &~ 1)); + + /* If this is a -Bsymbolic link, and the symbol is defined + locally, we just want to emit a RELATIVE reloc. Likewise if + the symbol was forced to be local because of a version file. + The entry in the global offset table will already have been + initialized in the relocate_section function. */ + if (info->shared + && (info->symbolic || h->dynindx == -1) + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) + { + rela.r_info = ELF32_R_INFO (0, R_390_RELATIVE); + rela.r_addend = (h->root.u.def.value + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset); + } + else + { + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset); + rela.r_info = ELF32_R_INFO (h->dynindx, R_390_GLOB_DAT); + rela.r_addend = 0; + } + + bfd_elf32_swap_reloca_out (output_bfd, &rela, + ((Elf32_External_Rela *) srela->contents + + srela->reloc_count)); + ++srela->reloc_count; + } + + if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0) + { + asection *s; + Elf_Internal_Rela rela; + + /* This symbols needs a copy reloc. Set it up. */ + + BFD_ASSERT (h->dynindx != -1 + && (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak)); + + + s = bfd_get_section_by_name (h->root.u.def.section->owner, + ".rela.bss"); + BFD_ASSERT (s != NULL); + + rela.r_offset = (h->root.u.def.value + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset); + rela.r_info = ELF32_R_INFO (h->dynindx, R_390_COPY); + rela.r_addend = 0; + bfd_elf32_swap_reloca_out (output_bfd, &rela, + ((Elf32_External_Rela *) s->contents + + s->reloc_count)); + ++s->reloc_count; + } + + /* Mark some specially defined symbols as absolute. */ + if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0 + || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0){ + sym->st_shndx = SHN_ABS; + + } + + return true; +} + +/* Finish up the dynamic sections. */ + +static boolean +elf32_s390_finish_dynamic_sections (output_bfd, info) + bfd *output_bfd; + struct bfd_link_info *info; +{ + bfd *dynobj; + asection *sdyn; + asection *sgot; + + dynobj = elf_hash_table (info)->dynobj; + + sgot = bfd_get_section_by_name (dynobj, ".got.plt"); + BFD_ASSERT (sgot != NULL); + sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); + + if (elf_hash_table (info)->dynamic_sections_created) + { + asection *splt; + Elf32_External_Dyn *dyncon, *dynconend; + + splt = bfd_get_section_by_name (dynobj, ".plt"); + BFD_ASSERT (splt != NULL && sdyn != NULL); + + dyncon = (Elf32_External_Dyn *) sdyn->contents; + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + for (; dyncon < dynconend; dyncon++) + { + Elf_Internal_Dyn dyn; + const char *name; + asection *s; + + bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); + + switch (dyn.d_tag) + { + default: + break; + + case DT_PLTGOT: + name = ".got"; + goto get_vma; + case DT_JMPREL: + name = ".rela.plt"; + get_vma: + s = bfd_get_section_by_name(output_bfd, name); + BFD_ASSERT (s != NULL); + dyn.d_un.d_ptr = s->vma; + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); + break; + + case DT_PLTRELSZ: + s = bfd_get_section_by_name (output_bfd, ".rela.plt"); + BFD_ASSERT (s != NULL); + if (s->_cooked_size != 0) + dyn.d_un.d_val = s->_cooked_size; + else + dyn.d_un.d_val = s->_raw_size; + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); + break; + } + } + + /* Fill in the special first entry in the procedure linkage table. */ + if (splt->_raw_size > 0) + { + memset (splt->contents, 0, PLT_FIRST_ENTRY_SIZE); + if (info->shared) + { + bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD0, + splt->contents ); + bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD1, + splt->contents +4 ); + bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD2, + splt->contents +8 ); + bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD3, + splt->contents +12 ); + bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD4, + splt->contents +16 ); + } + else + { + bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD0, + splt->contents ); + bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD1, + splt->contents +4 ); + bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD2, + splt->contents +8 ); + bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD3, + splt->contents +12 ); + bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD4, + splt->contents +16 ); + bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD5, + splt->contents +20 ); + bfd_put_32 (output_bfd, + sgot->output_section->vma + sgot->output_offset, + splt->contents + 24); + } + } + + elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; + } + + /* Set the first entry in the global offset table to the address of + the dynamic section. */ + if (sgot->_raw_size > 0) + { + if (sdyn == NULL) + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); + else + bfd_put_32 (output_bfd, + sdyn->output_section->vma + sdyn->output_offset, + sgot->contents); + + /* One entry for shared object struct ptr. */ + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4); + /* One entry for _dl_runtime_resolve. */ + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8); + } + + elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; + + return true; +} + +/* Merge backend specific data from an object file to the output + object file when linking. */ + +static boolean +elf32_s390_merge_private_bfd_data (ibfd, obfd) + bfd *ibfd; + bfd *obfd; +{ + boolean error; + + if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour + || bfd_get_flavour (obfd) != bfd_target_elf_flavour) + return true; + + error = false; + + if (error) + { + bfd_set_error (bfd_error_bad_value); + return false; + } + + return true; +} + +#define TARGET_BIG_SYM bfd_elf32_s390_vec +#define TARGET_BIG_NAME "elf32-s390" +#define ELF_ARCH bfd_arch_s390 +#define ELF_MACHINE_CODE EM_S390 +#define ELF_MAXPAGESIZE 0x1000 + +#define elf_info_to_howto elf32_s390_info_to_howto +#define bfd_elf32_bfd_reloc_type_lookup elf32_s390_reloc_type_lookup +#define elf_backend_create_dynamic_sections \ + _bfd_elf_create_dynamic_sections +#define elf_backend_check_relocs elf32_s390_check_relocs +#define elf_backend_adjust_dynamic_symbol \ + elf32_s390_adjust_dynamic_symbol +#define elf_backend_size_dynamic_sections \ + elf32_s390_size_dynamic_sections +#define elf_backend_relocate_section elf32_s390_relocate_section +#define elf_backend_finish_dynamic_symbol \ + elf32_s390_finish_dynamic_symbol +#define elf_backend_finish_dynamic_sections \ + elf32_s390_finish_dynamic_sections +#define bfd_elf32_bfd_merge_private_bfd_data \ + elf32_s390_merge_private_bfd_data +#define bfd_elf32_bfd_link_hash_table_create \ + elf_s390_link_hash_table_create +#define bfd_elf32_bfd_is_local_label_name \ + elf_s390_is_local_label_name + +#define elf_backend_gc_mark_hook elf_s390_gc_mark_hook +#define elf_backend_gc_sweep_hook elf_s390_gc_sweep_hook + +#define elf_backend_want_got_plt 1 +#define elf_backend_plt_readonly 1 +#define elf_backend_want_plt_sym 0 +#define elf_backend_got_header_size 12 +#define elf_backend_plt_header_size PLT_ENTRY_SIZE + +#include "elf32-target.h" --- /dev/null Tue Jun 1 11:25:19 1999 +++ gdb.new/include/elf/s390.h Fri Oct 13 13:49:45 2000 @@ -0,0 +1,62 @@ +/* 390 ELF support for BFD. + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Carl B. Pedersen and Martin Schwidefsky. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#ifndef _ELF_390_H +#define _ELF_390_H + +/* Processor specific flags for the ELF header e_flags field. */ + +/* Symbol types. */ + +#define STACK_REG 15 /* Global Stack reg */ +#define BACKL_REG 14 /* Global Backlink reg */ +#define BASE_REG 13 /* Global Base reg */ +#define GOT_REG 12 /* Holds addr of GOT */ + +/* Relocation types. */ + +enum elf_390_reloc_type { + R_390_NONE = 0, + R_390_8, + R_390_12, + R_390_16, + R_390_32, + R_390_PC32, + R_390_GOT12, + R_390_GOT32, + R_390_PLT32, + R_390_COPY, + R_390_GLOB_DAT, + R_390_JMP_SLOT, + R_390_RELATIVE, + R_390_GOTOFF, + R_390_GOTPC, + R_390_GOT16, + R_390_PC16, + R_390_PC16DBL, + R_390_PLT16DBL, + R_390_max, + /* These are GNU extensions to enable C++ vtable garbage collection. */ + R_390_GNU_VTINHERIT = 250, + R_390_GNU_VTENTRY = 251 +}; + +#endif /* _ELF_390_H */ --- /dev/null Tue Jun 1 11:25:19 1999 +++ gdb.new/include/opcode/s390.h Fri Oct 13 13:49:45 2000 @@ -0,0 +1,119 @@ +/* s390.h -- Header file for S390 opcode table + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#ifndef S390_H +#define S390_H + +/* The opcode table is an array of struct s390_opcode. */ + +struct s390_opcode +{ + /* The opcode name. */ + const char *name; + + /* The opcode itself. Those bits which will be filled in with + operands are zeroes. */ + unsigned char opcode[6]; + + /* The opcode mask. This is used by the disassembler. This is a + mask containing ones indicating those bits which must match the + opcode field, and zeroes indicating those bits which need not + match (and are presumably filled in by operands). */ + unsigned char mask[6]; + + /* The opcode length in bytes. */ + int oplen; + + /* An array of operand codes. Each code is an index into the + operand table. They appear in the order which the operands must + appear in assembly code, and are terminated by a zero. */ + unsigned char operands[6]; +}; + +/* The table itself is sorted by major opcode number, and is otherwise + in the order in which the disassembler should consider + instructions. */ +extern const struct s390_opcode s390_opcodes[]; +extern const int s390_num_opcodes; + +/* A opcode format table for the .insn pseudo mnemonic */ +extern const struct s390_opcode s390_opformats[]; +extern const int s390_num_opformats; + +/* Values defined for the flags field of a struct powerpc_opcode. */ + +/* The operands table is an array of struct s390_operand. */ + +struct s390_operand +{ + /* The number of bits in the operand. */ + int bits; + + /* How far the operand is left shifted in the instruction. */ + int shift; + + /* One bit syntax flags. */ + unsigned long flags; +}; + +/* Elements in the table are retrieved by indexing with values from + the operands field of the powerpc_opcodes table. */ + +extern const struct s390_operand s390_operands[]; + +/* Values defined for the flags field of a struct s390_operand. */ + +/* This operand names a register. The disassembler uses this to print + register names with a leading 'r'. */ +#define S390_OPERAND_GPR 0x1 + +/* This operand names a floating point register. The disassembler + prints these with a leading 'f'. */ +#define S390_OPERAND_FPR 0x2 + +/* This operand names an access register. The disassembler + prints these with a leading 'a'. */ +#define S390_OPERAND_AR 0x4 + +/* This operand names a control register. The disassembler + prints these with a leading 'c'. */ +#define S390_OPERAND_CR 0x8 + +/* This operand is a displacement */ +#define S390_OPERAND_DISP 0x10 + +/* This operand names a base register. */ +#define S390_OPERAND_BASE 0x20 + +/* This operand names an index register, it can be skipped. */ +#define S390_OPERAND_INDEX 0x40 + +/* This operand is a relative branch displacement. The disassembler + prints these symbolically if possible. */ +#define S390_OPERAND_PCREL 0x80 + +/* This operand takes signed values. */ +#define S390_OPERAND_SIGNED 0x100 + +/* This operand is a length. */ +#define S390_OPERAND_LENGTH 0x200 + +#endif /* S390_H */ --- /dev/null Tue Jun 1 11:25:19 1999 +++ gdb.new/opcodes/s390-dis.c Fri Oct 13 13:49:45 2000 @@ -0,0 +1,220 @@ +/* s390-dis.c -- Disassemble S390 instructions + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + This file is part of GDB, GAS and the 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 +#include "ansidecl.h" +#include "sysdep.h" +#include "dis-asm.h" +#include "opcode/s390.h" + +static int init_flag = 0; +static int opc_index[256]; + +/* Set up index table for first opcode byte */ +static void +init_disasm(info) + struct disassemble_info *info ATTRIBUTE_UNUSED; +{ + const struct s390_opcode *opcode; + const struct s390_opcode *opcode_end; + + memset(opc_index, 0, sizeof(opc_index)); + opcode_end = s390_opcodes + s390_num_opcodes; + for (opcode = s390_opcodes; opcode < opcode_end; opcode++) { + opc_index[(int) opcode->opcode[0]] = opcode - s390_opcodes; + while ((opcode < opcode_end) && + (opcode[1].opcode[0] == opcode->opcode[0])) + opcode++; + } + init_flag = 1; +} + +/* Extracts an operand value from an instruction. */ + +static inline unsigned int +s390_extract_operand (insn, operand) + unsigned char *insn; + const struct s390_operand *operand; +{ + unsigned int val; + int bits; + + /* extract fragments of the operand byte for byte */ + insn += operand->shift/8; + bits = (operand->shift & 7) + operand->bits; + val = 0; + do { + val <<= 8; + val |= (unsigned int) *insn++; + bits -= 8; + } while (bits > 0); + val >>= -bits; + val &= ((1U << (operand->bits-1))<<1) - 1; + + /* sign extend value if the operand is signed or pc relative */ + if ((operand->flags & (S390_OPERAND_SIGNED|S390_OPERAND_PCREL)) && + (val & (1U << (operand->bits-1)))) + val |= (-1U << (operand->bits-1))<<1; + + /* double value if the operand is pc relative */ + if (operand->flags & S390_OPERAND_PCREL) + val <<= 1; + + /* length x in an instructions has real length x+1 */ + if (operand->flags & S390_OPERAND_LENGTH) + val++; + return val; +} + +/* Print a S390 instruction. */ + +int +print_insn_s390 (memaddr, info) + bfd_vma memaddr; + struct disassemble_info *info; +{ + bfd_byte buffer[6]; + const struct s390_opcode *opcode; + const struct s390_opcode *opcode_end; + unsigned int value; + int status, opsize, bufsize; + char separator; + + if (init_flag == 0) + init_disasm(info); + + /* The output looks better if we put 6 bytes on a line */ + info->bytes_per_line = 6; + + /* every S390 instruction is max 6 bytes long */ + memset(buffer, 0, 6); + status = (*info->read_memory_func) (memaddr, buffer, 6, info); + if (status != 0) { + for (bufsize = 0; bufsize < 6; bufsize++) + if ((*info->read_memory_func) (memaddr, buffer, bufsize+1, info) != 0) + break; + if (bufsize <= 0) { + (*info->memory_error_func) (status, memaddr, info); + return -1; + } + /* + * opsize calculation looks strange but it works + * 00xxxxxx -> 2 bytes, 01xxxxxx/10xxxxxx -> 4 bytes, 11xxxxxx -> 6 bytes + */ + opsize = ((((buffer[0]>>6)+1)>>1)+1)<<1; + status = opsize > bufsize; + } else { + bufsize = 6; + opsize = ((((buffer[0]>>6)+1)>>1)+1)<<1; + } + + if (status == 0) { + /* find the first match in the opcode table */ + opcode_end = s390_opcodes + s390_num_opcodes; + for (opcode = s390_opcodes + opc_index[(int) buffer[0]]; + (opcode < opcode_end) && (buffer[0] == opcode->opcode[0]); + opcode++) { + const struct s390_operand *operand; + const unsigned char *opindex; + int i; + + /* check signature of the opcode */ + if ((buffer[1] & opcode->mask[1]) != opcode->opcode[1] || + (buffer[2] & opcode->mask[2]) != opcode->opcode[2] || + (buffer[3] & opcode->mask[3]) != opcode->opcode[3] || + (buffer[4] & opcode->mask[4]) != opcode->opcode[4] || + (buffer[5] & opcode->mask[5]) != opcode->opcode[5]) + continue; + + /* the instruction is valid */ + if (opcode->operands[0] != 0) + (*info->fprintf_func) (info->stream, "%s\t", opcode->name); + else + (*info->fprintf_func) (info->stream, "%s", opcode->name); + + /* extract the operands */ + separator = 0; + for (opindex = opcode->operands; *opindex != 0; opindex++) { + char *insn; + unsigned int value; + + operand = s390_operands + *opindex; + value = s390_extract_operand(buffer, operand); + + if ((operand->flags & S390_OPERAND_INDEX) && value == 0) + continue; + if ((operand->flags & S390_OPERAND_BASE) && + value == 0 && separator == '(') { + separator = ','; + continue; + } + + if (separator) + (*info->fprintf_func) (info->stream, "%c", separator); + + if (operand->flags & S390_OPERAND_GPR) + (*info->fprintf_func) (info->stream, "%%r%i", value); + else if (operand->flags & S390_OPERAND_FPR) + (*info->fprintf_func) (info->stream, "%%f%i", value); + else if (operand->flags & S390_OPERAND_AR) + (*info->fprintf_func) (info->stream, "%%a%i", value); + else if (operand->flags & S390_OPERAND_CR) + (*info->fprintf_func) (info->stream, "%%c%i", value); + else if (operand->flags & S390_OPERAND_PCREL) + (*info->print_address_func) (memaddr + (int) value, info); + else if (operand->flags & S390_OPERAND_SIGNED) + (*info->fprintf_func) (info->stream, "%i", (int) value); + else + (*info->fprintf_func) (info->stream, "%i", value); + + if (operand->flags & S390_OPERAND_DISP) { + separator = '('; + } else if (operand->flags & S390_OPERAND_BASE) { + (*info->fprintf_func) (info->stream, ")"); + separator = ','; + } else + separator = ','; + } + + /* found instruction, printed it, return its size */ + return opsize; + } + /* no matching instruction found, fall through to hex print */ + } + + if (bufsize >= 4) { + value = (unsigned int) buffer[0]; + value = (value << 8) + (unsigned int) buffer[1]; + value = (value << 8) + (unsigned int) buffer[2]; + value = (value << 8) + (unsigned int) buffer[3]; + (*info->fprintf_func) (info->stream,".long\t0x%08x", value); + return 4; + } else if (bufsize >= 2) { + value = (unsigned int) buffer[0]; + value = (value << 8) + (unsigned int) buffer[1]; + (*info->fprintf_func) (info->stream,".short\t0x%04x", value); + return 2; + } else { + value = (unsigned int) buffer[0]; + (*info->fprintf_func) (info->stream,".byte\t0x%02x", value); + return 1; + } +} --- /dev/null Tue Jun 1 11:25:19 1999 +++ gdb.new/opcodes/s390-mkopc.c Fri Oct 13 13:49:45 2000 @@ -0,0 +1,148 @@ +/* s390-mkopc.c -- Generates opcode table out of s390-opc.txt + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + This file is part of GDB, GAS, and the 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 +#include +#include + +struct op_struct { + char opcode[16]; + char mnemonic[16]; + char format[16]; + unsigned long long sort_value; + int no_nibbles; +}; + +struct op_struct *op_array; +int max_ops; +int no_ops; + +static void +createTable(void) +{ + max_ops = 256; + op_array = malloc(max_ops*sizeof(struct op_struct)); + no_ops = 0; +} + +/* + * `insertOpcode': insert an op_struct into sorted opcode array + */ +static void +insertOpcode(char *opcode, char *mnemonic, char *format) +{ + char *str; + unsigned long long sort_value; + int no_nibbles; + int ix, k; + + while (no_ops >= max_ops) { + max_ops = max_ops*2; + op_array = realloc(op_array, max_ops*sizeof(struct op_struct)); + } + sort_value = 0; + str = opcode; + for (ix = 0; ix < 16; ix++) { + if (*str >= '0' && *str <= '9') + sort_value = (sort_value << 4) + (*str - '0'); + else if (*str >= 'a' && *str <= 'f') + sort_value = (sort_value << 4) + (*str - 'a' + 10); + else if (*str >= 'A' && *str <= 'F') + sort_value = (sort_value << 4) + (*str - 'A' + 10); + else if (*str == '?') + sort_value <<= 4; + else + break; + str++; + } + sort_value <<= 4*(16 - ix); + no_nibbles = ix; + for (ix = 0; ix < no_ops; ix++) + if (sort_value > op_array[ix].sort_value) + break; + for (k = no_ops; k > ix; k--) + op_array[k] = op_array[k-1]; + strcpy(op_array[ix].opcode, opcode); + strcpy(op_array[ix].mnemonic, mnemonic); + strcpy(op_array[ix].format, format); + op_array[ix].sort_value = sort_value; + op_array[ix].no_nibbles = no_nibbles; + no_ops++; +} + + +/* + * `dumpTable': write opcode table + */ +static void +dumpTable(void) +{ + char *str; + int ix; + + /* Write hash table entries (slots). */ + printf("const struct s390_opcode s390_opcodes[] = {\n"); + for (ix = 0; ix < no_ops; ix++) { + printf(" { \"%s\",\t ", op_array[ix].mnemonic); + for (str = op_array[ix].opcode; *str != 0; str++) + if (*str == '?') + *str = '0'; + printf("OP%i(0x%sLL),\t ", + op_array[ix].no_nibbles*4, op_array[ix].opcode); + printf("MASK_%s,\t INSTR_%s\t}", + op_array[ix].format, op_array[ix].format); + if (ix < no_ops-1) + printf(",\n"); + else + printf("\n"); + } + printf("};\n\n"); + printf("const int s390_num_opcodes =\n"); + printf(" sizeof (s390_opcodes) / sizeof (s390_opcodes[0]);\n\n"); +} + + +int +main(void) +{ + char currentLine[256]; + + createTable(); + /* Read opcode descriptions from `stdin'. For each mnemonic, + * make an entry into the opcode table. + */ + while (fgets(currentLine, sizeof(currentLine), stdin) != NULL) { + char opcode[16]; + char mnemonic[16]; + char format[16]; + + if (currentLine[0] == '#') + continue; + memset(opcode, 0, 8); + if (sscanf(currentLine, + "%15s %15s %15s", opcode, mnemonic, format) == 3) { + insertOpcode(opcode, mnemonic, format); + } + } + + dumpTable(); + return 0; +} --- /dev/null Tue Jun 1 11:25:19 1999 +++ gdb.new/opcodes/s390-opc.c Fri Oct 13 13:49:45 2000 @@ -0,0 +1,741 @@ +/* s390-opc.c -- S390 opcode list + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + This file is part of GDB, GAS, and the 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 +#include "ansidecl.h" +#include "opcode/s390.h" + +/* TODO: 1) correct forms for vector instructions. + * 2) change OPXX_MASK to reflect the 'reserved' bits of + * instructions with 'holes' in them + */ + +/* This file holds the S390 opcode table. The opcode table + includes almost all of the extended instruction mnemonics. This + permits the disassembler to use them, and simplifies the assembler + logic, at the cost of increasing the table size. The table is + strictly constant data, so the compiler should be able to put it in + the .text section. + + This file also holds the operand table. All knowledge about + inserting operands into instructions and vice-versa is kept in this + file. */ + +/* The operands table. + The fields are bits, shift, insert, extract, flags. */ + +const struct s390_operand s390_operands[] = +{ +#define UNUSED 0 + { 0, 0, 0 }, /* Indicates the end of the operand list */ + +#define R_8 1 /* GPR starting at position 8 */ + { 4, 8, S390_OPERAND_GPR }, +#define R_12 2 /* GPR starting at position 12 */ + { 4, 12, S390_OPERAND_GPR }, +#define R_16 3 /* GPR starting at position 16 */ + { 4, 16, S390_OPERAND_GPR }, +#define R_20 4 /* GPR starting at position 20 */ + { 4, 20, S390_OPERAND_GPR }, +#define R_24 5 /* GPR starting at position 24 */ + { 4, 24, S390_OPERAND_GPR }, +#define R_28 6 /* GPR starting at position 28 */ + { 4, 28, S390_OPERAND_GPR }, +#define R_32 7 /* GPR starting at position 32 */ + { 4, 32, S390_OPERAND_GPR }, + +#define F_8 8 /* FPR starting at position 8 */ + { 4, 8, S390_OPERAND_FPR }, +#define F_12 9 /* FPR starting at position 12 */ + { 4, 12, S390_OPERAND_FPR }, +#define F_24 10 /* FPR starting at position 24 */ + { 4, 24, S390_OPERAND_FPR }, +#define F_28 11 /* FPR starting at position 28 */ + { 4, 28, S390_OPERAND_FPR }, +#define F_32 12 /* FPR starting at position 32 */ + { 4, 32, S390_OPERAND_FPR }, + +#define A_8 13 /* Access reg. starting at position 8 */ + { 4, 8, S390_OPERAND_AR }, +#define A_12 14 /* Access reg. starting at position 12 */ + { 4, 12, S390_OPERAND_AR }, +#define A_24 15 /* Access reg. starting at position 24 */ + { 4, 24, S390_OPERAND_AR }, +#define A_28 16 /* Access reg. starting at position 28 */ + { 4, 28, S390_OPERAND_AR }, + +#define C_8 17 /* Control reg. starting at position 8 */ + { 4, 8, S390_OPERAND_CR }, +#define C_12 18 /* Control reg. starting at position 12 */ + { 4, 12, S390_OPERAND_CR }, + +#define B_16 19 /* Base register starting at position 16 */ + { 4, 16, S390_OPERAND_BASE|S390_OPERAND_GPR }, +#define B_32 20 /* Base register starting at position 32 */ + { 4, 32, S390_OPERAND_BASE|S390_OPERAND_GPR }, + +#define X_12 21 /* Index register starting at position 12 */ + { 4, 12, S390_OPERAND_INDEX|S390_OPERAND_GPR }, + +#define D_20 22 /* Displacement starting at position 20 */ + { 12, 20, S390_OPERAND_DISP }, +#define D_36 23 /* Displacement starting at position 36 */ + { 12, 36, S390_OPERAND_DISP }, + +#define L4_8 24 /* 4 bit length starting at position 8 */ + { 4, 8, S390_OPERAND_LENGTH }, +#define L4_12 25 /* 4 bit length starting at position 12 */ + { 4, 12, S390_OPERAND_LENGTH }, +#define L8_8 26 /* 8 bit length starting at position 8 */ + { 8, 8, S390_OPERAND_LENGTH }, + +#define U4_8 27 /* 4 bit unsigned value starting at 8 */ + { 4, 8, 0 }, +#define U4_12 28 /* 4 bit unsigned value starting at 12 */ + { 4, 12, 0 }, +#define U4_16 29 /* 4 bit unsigned value starting at 16 */ + { 4, 16, 0 }, +#define U4_20 30 /* 4 bit unsigned value starting at 20 */ + { 4, 20, 0 }, +#define U8_8 31 /* 8 bit unsigned value starting at 8 */ + { 8, 8, 0 }, +#define U8_16 32 /* 8 bit unsigned value starting at 16 */ + { 8, 16, 0 }, +#define I16_16 33 /* 16 bit signed value starting at 16 */ + { 16, 16, S390_OPERAND_SIGNED }, +#define U16_16 34 /* 16 bit unsigned value starting at 16 */ + { 16, 16, 0 }, +#define J16_16 35 /* PC relative jump offset @ 16 */ + { 16, 16, S390_OPERAND_PCREL }, +}; + + +/* Macros used to form opcodes. */ + +/* 8/16/48 bit opcodes */ +#define OP8(x) { x, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define OP16(x) { x>>8, x&255, 0x00, 0x00, 0x00, 0x00 } +#define OP48(x) { x>>40, (x>>32)&255, (x>>24)&255, \ + (x>>16)&255, (x>>8)&255, x&255} + +#define INSTR_E 2, { 0,0,0,0,0,0 } /* e.g. pr */ +#define INSTR_RR 2, { R_8,R_12,0,0,0,0 } /* e.g. lr */ +#define INSTR_RR_M 2, { U4_8,R_12,0,0,0,0 } /* e.g. bcr */ +#define INSTR_RR_B 2, { R_12, 0,0,0,0,0 } /* e.g. br */ +#define INSTR_RR_I 2, { U8_8, 0,0,0,0,0 } /* e.g. svc */ +#define INSTR_RR_R 2, { R_8, 0,0,0,0,0 } /* e.g. spm */ +#define INSTR_RR_E 2, { R_8,R_12,0,0,0,0 } /* e.g. aer */ +#define INSTR_RR_D 2, { F_8,F_12,0,0,0,0 } /* e.g. adr */ +#define INSTR_RR_X 2, { R_8,R_12,0,0,0,0 } /* e.g. mxr */ +#define INSTR_RR_ED 2, { F_8,F_12,0,0,0,0 } /* e.g. mer */ +#define INSTR_RR_DE 2, { F_8,F_12,0,0,0,0 } /* e.g. lrer */ +#define INSTR_RR_DX 2, { F_8,F_12,0,0,0,0 } /* e.g. mxdr */ +#define INSTR_RR_XD 2, { F_8,F_12,0,0,0,0 } /* e.g. lrdr */ +#define INSTR_RRE 4, { R_24,R_28,0,0,0,0 } /* e.g. lura */ +#define INSTR_RRE_A 4, { A_24,A_28,0,0,0,0 } /* e.g. cpya */ +#define INSTR_RRE_F 4, { F_24,F_28,0,0,0,0 } /* e.g. debr */ +#define INSTR_RRE_O 4, { 0,0,0,0,0,0 } /* e.g. palb */ +#define INSTR_RRE_R 4, { R_24,0,0,0,0,0 } /* e.g. ipm */ +#define INSTR_RRE_E 4, { F_24,0,0,0,0,0 } /* e.g. sqer */ +#define INSTR_RRE_D 4, { F_24,0,0,0,0,0 } /* e.g. sqdr */ +#define INSTR_RRE_X 4, { F_24,0,0,0,0,0 } /* e.g. dxr */ +#define INSTR_RRE_AR 4, { A_24,R_28,0,0,0,0 } /* e.g. sar */ +#define INSTR_RRE_RA 4, { R_24,A_28,0,0,0,0 } /* e.g. ear */ +#define INSTR_RRF_M 4, { R_24,U4_16,R_28,0,0,0 } /* e.g. cfxbr*/ +#define INSTR_RRF_RM 4, { R_24,R_16,R_28,U4_20,0,0 } /* e.g. didbr*/ +#define INSTR_RRF_R 4, { R_16,R_24,R_28,0,0,0 } /* e.g. madbr*/ +#define INSTR_RS 4, { R_8,R_12,D_20,B_16,0,0 } /* e.g. cs */ +#define INSTR_RS_A 4, { A_8,A_12,D_20,B_16,0,0 } /* e.g. lam */ +#define INSTR_RS_C 4, { C_8,C_12,D_20,B_16,0,0 } /* e.g. lctl */ +#define INSTR_RS_M 4, { R_8,U4_12,D_20,B_16,0,0 } /* e.g. icm */ +#define INSTR_RS_S 4, { R_8,D_20,B_16,0,0,0 } /* e.g. sll */ +#define INSTR_RS_D 4, { R_8,D_20,B_16,0,0,0 } /* e.g. sldl */ +#define INSTR_RX 4, { R_8,D_20,X_12,B_16,0,0 } /* e.g. l */ +#define INSTR_RX_M 4, { U4_8,D_20,X_12,B_16,0,0 } /* e.g. bc */ +#define INSTR_RX_B 4, { D_20,X_12,B_16,0,0,0 } /* e.g. b */ +#define INSTR_RX_E 4, { F_8,D_20,X_12,B_16,0,0 } /* e.g. ae */ +#define INSTR_RX_D 4, { F_8,D_20,X_12,B_16,0,0 } /* e.g. ad */ +#define INSTR_RX_ED 4, { F_8,D_20,X_12,B_16,0,0 } /* e.g. me */ +#define INSTR_RX_DX 4, { F_8,D_20,X_12,B_16,0,0 } /* e.g. mxd */ +#define INSTR_RXE 6, { F_8,D_20,X_12,B_16,0,0 } /* e.g. axbr */ +#define INSTR_RXF 6, { F_32,D_20,X_12,B_16,F_8,0 } /* e.g. madb */ +#define INSTR_S 4, { D_20,B_16,0,0,0,0 } /* e.g. lpsw */ +#define INSTR_INSN_S 4, { U32_0, D_20, B_16,0,0,0 } +#define INSTR_S_O 4, { 0,0,0,0,0,0 } /* e.g. hsch */ +#define INSTR_SI 4, { D_20,B_16,U8_8,0,0,0 } /* e.g. cli */ +#define INSTR_SS_RR 6, { D_20,R_8,B_16,D_36,B_32,R_12 } /* e.g. mvck */ +#define INSTR_SS_LL 6, { D_20,L4_8,B_16,D_36,L4_12,B_32 } /* e.g. pack */ +#define INSTR_SS_LI 6, { D_20,L4_8,B_16,D_36,B_32,U4_12 } /* e.g. srp */ +#define INSTR_SS_L 6, { D_20,L8_8,B_16,D_36,B_32,0 } /* e.g. mvc */ +#define INSTR_SSE 6, { D_20,B_16,D_36,B_32,0,0 } /* e.g. mvsdk */ +#define INSTR_RI 4, { R_8,I16_16,0,0,0,0 } /* e.g. ahi */ +#define INSTR_RI_U 4, { R_8,U16_16,0,0,0,0 } /* e.g. tml */ +#define INSTR_RI_A 4, { R_8,J16_16,0,0,0,0 } /* e.g. brct */ +#define INSTR_RI_MA 4, { U4_8,J16_16,0,0,0 } /* e.g. brc */ +#define INSTR_RI_B 4, { J16_16,0,0,0,0 } /* e.g. j */ +#define INSTR_RSI_A 4, { R_8,R_12,J16_16,0,0,0 } /* e.g. brxh */ +#define INSTR_VR 4, { 0,0,0,0,0,0 } /* no support */ +#define INSTR_VS 4, { 0,0,0,0,0,0 } /* no support */ +#define INSTR_VST 4, { 0,0,0,0,0,0 } /* no support */ +#define INSTR_VV 4, { 0,0,0,0,0,0 } /* no support */ +#define INSTR_RSE 6, { 0,0,0,0,0,0 } /* no support */ +#define INSTR_QST 4, { 0,0,0,0,0,0 } /* no support */ +#define INSTR_QV 4, { 0,0,0,0,0,0 } /* no support */ + +#define MASK_E { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_M { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_B { 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_I { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_R { 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_E { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_D { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_X { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_ED { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_DE { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_DX { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RR_XD { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RRE { 0xff, 0xff, 0xff, 0x00, 0x00, 0x00 } +#define MASK_RRE_A { 0xff, 0xff, 0xff, 0x00, 0x00, 0x00 } +#define MASK_RRE_F { 0xff, 0xff, 0xff, 0x00, 0x00, 0x00 } +#define MASK_RRE_O { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } +#define MASK_RRE_R { 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00 } +#define MASK_RRE_E { 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00 } +#define MASK_RRE_D { 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00 } +#define MASK_RRE_X { 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00 } +#define MASK_RRE_AR { 0xff, 0xff, 0xff, 0x00, 0x00, 0x00 } +#define MASK_RRE_RA { 0xff, 0xff, 0xff, 0x00, 0x00, 0x00 } +#define MASK_RRF_M { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RRF_RM { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RRF_R { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RS { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RS_A { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RS_C { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RS_M { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RS_S { 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RS_D { 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RX { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RX_M { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RX_B { 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RX_E { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RX_D { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RX_ED { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RX_DX { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RXE { 0xff, 0x00, 0x00, 0x00, 0x00, 0xff } +#define MASK_RXF { 0xff, 0x00, 0x00, 0x00, 0x00, 0xff } +#define MASK_S { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } +#define MASK_INSN_S { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } +#define MASK_S_O { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } +#define MASK_SI { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_SS_RR { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_SS_LL { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_SS_LI { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_SS_L { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_SSE { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RI { 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RI_U { 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RI_A { 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RI_MA { 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RI_B { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RSI_A { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_VR { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_VS { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_VST { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_VV { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_RSE { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_QST { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +#define MASK_QV { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } + +/* The opcode formats table (blueprints for .insn pseudo mnemonic). */ + +const struct s390_opcode s390_opformats[] = { + { "e", OP8(0x00LL), MASK_E, INSTR_E }, + { "ri", OP8(0x00LL), MASK_RI, INSTR_RI }, + { "ri_a", OP8(0x00LL), MASK_RI_A, INSTR_RI_A }, + { "ri_b", OP8(0x00LL), MASK_RI_B, INSTR_RI_B }, + { "ri_ma", OP8(0x00LL), MASK_RI_MA, INSTR_RI_MA }, + { "ri_u", OP8(0x00LL), MASK_RI_U, INSTR_RI_U }, + { "rr", OP8(0x00LL), MASK_RR, INSTR_RR }, + { "rre", OP8(0x00LL), MASK_RRE, INSTR_RRE }, + { "rre_a", OP8(0x00LL), MASK_RRE_A, INSTR_RRE_A }, + { "rre_ar", OP8(0x00LL), MASK_RRE_AR, INSTR_RRE_AR }, + { "rre_d", OP8(0x00LL), MASK_RRE_D, INSTR_RRE_D }, + { "rre_e", OP8(0x00LL), MASK_RRE_E, INSTR_RRE_E }, + { "rre_f", OP8(0x00LL), MASK_RRE_F, INSTR_RRE_F }, + { "rre_o", OP8(0x00LL), MASK_RRE_O, INSTR_RRE_O }, + { "rre_r", OP8(0x00LL), MASK_RRE_R, INSTR_RRE_R }, + { "rre_ra", OP8(0x00LL), MASK_RRE_RA, INSTR_RRE_RA }, + { "rre_x", OP8(0x00LL), MASK_RRE_X, INSTR_RRE_X }, + { "rrf_m", OP8(0x00LL), MASK_RRF_M, INSTR_RRF_M }, + { "rrf_r", OP8(0x00LL), MASK_RRF_R, INSTR_RRF_R }, + { "rrf_rm", OP8(0x00LL), MASK_RRF_RM, INSTR_RRF_RM }, + { "rr_b", OP8(0x00LL), MASK_RR_B, INSTR_RR_B }, + { "rr_d", OP8(0x00LL), MASK_RR_D, INSTR_RR_D }, + { "rr_de", OP8(0x00LL), MASK_RR_DE, INSTR_RR_DE }, + { "rr_dx", OP8(0x00LL), MASK_RR_DX, INSTR_RR_DX }, + { "rr_e", OP8(0x00LL), MASK_RR_E, INSTR_RR_E }, + { "rr_ed", OP8(0x00LL), MASK_RR_ED, INSTR_RR_ED }, + { "rr_i", OP8(0x00LL), MASK_RR_I, INSTR_RR_I }, + { "rr_m", OP8(0x00LL), MASK_RR_M, INSTR_RR_M }, + { "rr_r", OP8(0x00LL), MASK_RR_R, INSTR_RR_R }, + { "rr_x", OP8(0x00LL), MASK_RR_X, INSTR_RR_X }, + { "rr_xd", OP8(0x00LL), MASK_RR_XD, INSTR_RR_XD }, + { "rs", OP8(0x00LL), MASK_RS, INSTR_RS }, + { "rsi_a", OP8(0x00LL), MASK_RSI_A, INSTR_RSI_A }, + { "rs_a", OP8(0x00LL), MASK_RS_A, INSTR_RS_A }, + { "rs_c", OP8(0x00LL), MASK_RS_C, INSTR_RS_C }, + { "rs_d", OP8(0x00LL), MASK_RS_D, INSTR_RS_D }, + { "rs_m", OP8(0x00LL), MASK_RS_M, INSTR_RS_M }, + { "rs_s", OP8(0x00LL), MASK_RS_S, INSTR_RS_S }, + { "rx", OP8(0x00LL), MASK_RX, INSTR_RX }, + { "rxe", OP8(0x00LL), MASK_RXE, INSTR_RXE }, + { "rxf", OP8(0x00LL), MASK_RXF, INSTR_RXF }, + { "rx_b", OP8(0x00LL), MASK_RX_B, INSTR_RX_B }, + { "rx_d", OP8(0x00LL), MASK_RX_D, INSTR_RX_D }, + { "rx_dx", OP8(0x00LL), MASK_RX_DX, INSTR_RX_DX }, + { "rx_e", OP8(0x00LL), MASK_RX_E, INSTR_RX_E }, + { "rx_ed", OP8(0x00LL), MASK_RX_ED, INSTR_RX_ED }, + { "rx_m", OP8(0x00LL), MASK_RX_M, INSTR_RX_M }, + { "s", OP8(0x00LL), MASK_S, INSTR_S }, + { "si", OP8(0x00LL), MASK_SI, INSTR_SI }, + { "sse", OP8(0x00LL), MASK_SSE, INSTR_SSE }, + { "ss_l", OP8(0x00LL), MASK_SS_L, INSTR_SS_L }, + { "ss_li", OP8(0x00LL), MASK_SS_LI, INSTR_SS_LI }, + { "ss_ll", OP8(0x00LL), MASK_SS_LL, INSTR_SS_LL }, + { "ss_rr", OP8(0x00LL), MASK_SS_RR, INSTR_SS_RR }, + { "s_o", OP8(0x00LL), MASK_S_O, INSTR_S_O } +}; + +const int s390_num_opformats = + sizeof (s390_opformats) / sizeof (s390_opformats[0]); + +/* The opcode table. + + The format of the opcode table is: + + NAME OPCODE MASK OPERANDS + + NAME is the name of the instruction. + OPCODE is the instruction opcode. + MASK is the opcode mask; this is used to tell the disassembler + which bits in the actual opcode must match OPCODE. + OPERANDS is the list of operands. + + The disassembler reads the table in order and prints the first + instruction which matches. */ + +const struct s390_opcode s390_opcodes[] = { + { "dp", OP8(0xfdLL), MASK_SS_LL, INSTR_SS_LL }, + { "mp", OP8(0xfcLL), MASK_SS_LL, INSTR_SS_LL }, + { "sp", OP8(0xfbLL), MASK_SS_LL, INSTR_SS_LL }, + { "ap", OP8(0xfaLL), MASK_SS_LL, INSTR_SS_LL }, + { "cp", OP8(0xf9LL), MASK_SS_LL, INSTR_SS_LL }, + { "zap", OP8(0xf8LL), MASK_SS_LL, INSTR_SS_LL }, + { "unpk", OP8(0xf3LL), MASK_SS_LL, INSTR_SS_LL }, + { "pack", OP8(0xf2LL), MASK_SS_LL, INSTR_SS_LL }, + { "mvo", OP8(0xf1LL), MASK_SS_LL, INSTR_SS_LL }, + { "srp", OP8(0xf0LL), MASK_SS_LI, INSTR_SS_LI }, + { "msdb", OP48(0xed000000001fLL), MASK_RXF, INSTR_RXF }, + { "madb", OP48(0xed000000001eLL), MASK_RXF, INSTR_RXF }, + { "ddb", OP48(0xed000000001dLL), MASK_RXE, INSTR_RXE }, + { "mdb", OP48(0xed000000001cLL), MASK_RXE, INSTR_RXE }, + { "sdb", OP48(0xed000000001bLL), MASK_RXE, INSTR_RXE }, + { "adb", OP48(0xed000000001aLL), MASK_RXE, INSTR_RXE }, + { "cdb", OP48(0xed0000000019LL), MASK_RXE, INSTR_RXE }, + { "kdb", OP48(0xed0000000018LL), MASK_RXE, INSTR_RXE }, + { "meeb", OP48(0xed0000000017LL), MASK_RXE, INSTR_RXE }, + { "sqdb", OP48(0xed0000000015LL), MASK_RXE, INSTR_RXE }, + { "sqeb", OP48(0xed0000000014LL), MASK_RXE, INSTR_RXE }, + { "tcxb", OP48(0xed0000000012LL), MASK_RXE, INSTR_RXE }, + { "tcdb", OP48(0xed0000000011LL), MASK_RXE, INSTR_RXE }, + { "tceb", OP48(0xed0000000010LL), MASK_RXE, INSTR_RXE }, + { "mseb", OP48(0xed000000000fLL), MASK_RXF, INSTR_RXF }, + { "maeb", OP48(0xed000000000eLL), MASK_RXF, INSTR_RXF }, + { "deb", OP48(0xed000000000dLL), MASK_RXE, INSTR_RXE }, + { "mdeb", OP48(0xed000000000cLL), MASK_RXE, INSTR_RXE }, + { "seb", OP48(0xed000000000bLL), MASK_RXE, INSTR_RXE }, + { "aeb", OP48(0xed000000000aLL), MASK_RXE, INSTR_RXE }, + { "ceb", OP48(0xed0000000009LL), MASK_RXE, INSTR_RXE }, + { "keb", OP48(0xed0000000008LL), MASK_RXE, INSTR_RXE }, + { "mxdb", OP48(0xed0000000007LL), MASK_RXE, INSTR_RXE }, + { "lxeb", OP48(0xed0000000006LL), MASK_RXE, INSTR_RXE }, + { "lxdb", OP48(0xed0000000005LL), MASK_RXE, INSTR_RXE }, + { "ldeb", OP48(0xed0000000004LL), MASK_RXE, INSTR_RXE }, + { "mvcin", OP8(0xe8LL), MASK_SS_L, INSTR_SS_L }, + { "mvcdk", OP16(0xe50fLL), MASK_SSE, INSTR_SSE }, + { "mvcsk", OP16(0xe50eLL), MASK_SSE, INSTR_SSE }, + { "tprot", OP16(0xe501LL), MASK_SSE, INSTR_SSE }, + { "lasp", OP16(0xe500LL), MASK_SSE, INSTR_SSE }, + { "edmk", OP8(0xdfLL), MASK_SS_L, INSTR_SS_L }, + { "ed", OP8(0xdeLL), MASK_SS_L, INSTR_SS_L }, + { "trt", OP8(0xddLL), MASK_SS_L, INSTR_SS_L }, + { "tr", OP8(0xdcLL), MASK_SS_L, INSTR_SS_L }, + { "mvcs", OP8(0xdbLL), MASK_SS_RR, INSTR_SS_RR }, + { "mvcp", OP8(0xdaLL), MASK_SS_RR, INSTR_SS_RR }, + { "mvck", OP8(0xd9LL), MASK_SS_RR, INSTR_SS_RR }, + { "xc", OP8(0xd7LL), MASK_SS_L, INSTR_SS_L }, + { "oc", OP8(0xd6LL), MASK_SS_L, INSTR_SS_L }, + { "clc", OP8(0xd5LL), MASK_SS_L, INSTR_SS_L }, + { "nc", OP8(0xd4LL), MASK_SS_L, INSTR_SS_L }, + { "mvz", OP8(0xd3LL), MASK_SS_L, INSTR_SS_L }, + { "mvc", OP8(0xd2LL), MASK_SS_L, INSTR_SS_L }, + { "mvn", OP8(0xd1LL), MASK_SS_L, INSTR_SS_L }, + { "icm", OP8(0xbfLL), MASK_RS_M, INSTR_RS_M }, + { "stcm", OP8(0xbeLL), MASK_RS_M, INSTR_RS_M }, + { "clm", OP8(0xbdLL), MASK_RS_M, INSTR_RS_M }, + { "cds", OP8(0xbbLL), MASK_RS, INSTR_RS }, + { "cs", OP8(0xbaLL), MASK_RS, INSTR_RS }, + { "lctl", OP8(0xb7LL), MASK_RS_C, INSTR_RS_C }, + { "stctl", OP8(0xb6LL), MASK_RS_C, INSTR_RS_C }, + { "cfxbr", OP16(0xb39aLL), MASK_RRF_M, INSTR_RRF_M }, + { "cfdbr", OP16(0xb399LL), MASK_RRF_M, INSTR_RRF_M }, + { "cfebr", OP16(0xb398LL), MASK_RRF_M, INSTR_RRF_M }, + { "cxfbr", OP16(0xb396LL), MASK_RRE_F, INSTR_RRE_F }, + { "cdfbr", OP16(0xb395LL), MASK_RRE_F, INSTR_RRE_F }, + { "cefbr", OP16(0xb394LL), MASK_RRE_F, INSTR_RRE_F }, + { "efpc", OP16(0xb38cLL), MASK_RRE, INSTR_RRE }, + { "sfpc", OP16(0xb384LL), MASK_RRE, INSTR_RRE }, + { "fidbr", OP16(0xb35fLL), MASK_RRF_M, INSTR_RRF_M }, + { "didbr", OP16(0xb35bLL), MASK_RRF_RM, INSTR_RRF_RM }, + { "fiebr", OP16(0xb357LL), MASK_RRF_M, INSTR_RRF_M }, + { "diebr", OP16(0xb353LL), MASK_RRF_RM, INSTR_RRF_RM }, + { "dxbr", OP16(0xb34dLL), MASK_RRE_F, INSTR_RRE_F }, + { "mxbr", OP16(0xb34cLL), MASK_RRE_F, INSTR_RRE_F }, + { "sxbr", OP16(0xb34bLL), MASK_RRE_F, INSTR_RRE_F }, + { "axbr", OP16(0xb34aLL), MASK_RRE_F, INSTR_RRE_F }, + { "cxbr", OP16(0xb349LL), MASK_RRE_F, INSTR_RRE_F }, + { "kxbr", OP16(0xb348LL), MASK_RRE_F, INSTR_RRE_F }, + { "fixbr", OP16(0xb347LL), MASK_RRF_M, INSTR_RRF_M }, + { "lexbr", OP16(0xb346LL), MASK_RRE_F, INSTR_RRE_F }, + { "ldxbr", OP16(0xb345LL), MASK_RRE_F, INSTR_RRE_F }, + { "ledbr", OP16(0xb344LL), MASK_RRE_F, INSTR_RRE_F }, + { "lcxbr", OP16(0xb343LL), MASK_RRE_F, INSTR_RRE_F }, + { "ltxbr", OP16(0xb342LL), MASK_RRE_F, INSTR_RRE_F }, + { "lnxbr", OP16(0xb341LL), MASK_RRE_F, INSTR_RRE_F }, + { "lpxbr", OP16(0xb340LL), MASK_RRE_F, INSTR_RRE_F }, + { "msdbr", OP16(0xb31fLL), MASK_RRF_R, INSTR_RRF_R }, + { "madbr", OP16(0xb31eLL), MASK_RRF_R, INSTR_RRF_R }, + { "ddbr", OP16(0xb31dLL), MASK_RRE_F, INSTR_RRE_F }, + { "mdbr", OP16(0xb31cLL), MASK_RRE_F, INSTR_RRE_F }, + { "sdbr", OP16(0xb31bLL), MASK_RRE_F, INSTR_RRE_F }, + { "adbr", OP16(0xb31aLL), MASK_RRE_F, INSTR_RRE_F }, + { "cdbr", OP16(0xb319LL), MASK_RRE_F, INSTR_RRE_F }, + { "kdbr", OP16(0xb318LL), MASK_RRE_F, INSTR_RRE_F }, + { "meebr", OP16(0xb317LL), MASK_RRE_F, INSTR_RRE_F }, + { "sqxbr", OP16(0xb316LL), MASK_RRE_F, INSTR_RRE_F }, + { "sqdbr", OP16(0xb315LL), MASK_RRE_F, INSTR_RRE_F }, + { "sqebr", OP16(0xb314LL), MASK_RRE_F, INSTR_RRE_F }, + { "lcdbr", OP16(0xb313LL), MASK_RRE_F, INSTR_RRE_F }, + { "ltdbr", OP16(0xb312LL), MASK_RRE_F, INSTR_RRE_F }, + { "lndbr", OP16(0xb311LL), MASK_RRE_F, INSTR_RRE_F }, + { "lpdbr", OP16(0xb310LL), MASK_RRE_F, INSTR_RRE_F }, + { "msebr", OP16(0xb30fLL), MASK_RRF_R, INSTR_RRF_R }, + { "maebr", OP16(0xb30eLL), MASK_RRF_R, INSTR_RRF_R }, + { "debr", OP16(0xb30dLL), MASK_RRE_F, INSTR_RRE_F }, + { "mdebr", OP16(0xb30cLL), MASK_RRE_F, INSTR_RRE_F }, + { "sebr", OP16(0xb30bLL), MASK_RRE_F, INSTR_RRE_F }, + { "aebr", OP16(0xb30aLL), MASK_RRE_F, INSTR_RRE_F }, + { "cebr", OP16(0xb309LL), MASK_RRE_F, INSTR_RRE_F }, + { "kebr", OP16(0xb308LL), MASK_RRE_F, INSTR_RRE_F }, + { "mxdbr", OP16(0xb307LL), MASK_RRE_F, INSTR_RRE_F }, + { "lxebr", OP16(0xb306LL), MASK_RRE_F, INSTR_RRE_F }, + { "lxdbr", OP16(0xb305LL), MASK_RRE_F, INSTR_RRE_F }, + { "ldebr", OP16(0xb304LL), MASK_RRE_F, INSTR_RRE_F }, + { "lcebr", OP16(0xb303LL), MASK_RRE_F, INSTR_RRE_F }, + { "ltebr", OP16(0xb302LL), MASK_RRE_F, INSTR_RRE_F }, + { "lnebr", OP16(0xb301LL), MASK_RRE_F, INSTR_RRE_F }, + { "lpebr", OP16(0xb300LL), MASK_RRE_F, INSTR_RRE_F }, + { "lfpc", OP16(0xb29dLL), MASK_S, INSTR_S }, + { "stfpc", OP16(0xb29cLL), MASK_S, INSTR_S }, + { "srnm", OP16(0xb299LL), MASK_S, INSTR_S }, + { "sacf", OP16(0xb279LL), MASK_S, INSTR_S }, + { "siga", OP16(0xb274LL), MASK_S, INSTR_S }, + { "cmpsc", OP16(0xb263LL), MASK_RRE, INSTR_RRE }, + { "srst", OP16(0xb25eLL), MASK_RRE, INSTR_RRE }, + { "clst", OP16(0xb25dLL), MASK_RRE, INSTR_RRE }, + { "bsg", OP16(0xb258LL), MASK_RRE, INSTR_RRE }, + { "cuse", OP16(0xb257LL), MASK_RRE, INSTR_RRE }, + { "mvst", OP16(0xb255LL), MASK_RRE, INSTR_RRE }, + { "mvpg", OP16(0xb254LL), MASK_RRE, INSTR_RRE }, + { "msr", OP16(0xb252LL), MASK_RRE, INSTR_RRE }, + { "csp", OP16(0xb250LL), MASK_RRE, INSTR_RRE }, + { "ear", OP16(0xb24fLL), MASK_RRE_RA, INSTR_RRE_RA }, + { "sar", OP16(0xb24eLL), MASK_RRE_AR, INSTR_RRE_AR }, + { "cpya", OP16(0xb24dLL), MASK_RRE_A, INSTR_RRE_A }, + { "tar", OP16(0xb24cLL), MASK_RRE_AR, INSTR_RRE_AR }, + { "lura", OP16(0xb24bLL), MASK_RRE, INSTR_RRE }, + { "esta", OP16(0xb24aLL), MASK_RRE, INSTR_RRE }, + { "ereg", OP16(0xb249LL), MASK_RRE, INSTR_RRE }, + { "palb", OP16(0xb248LL), MASK_RRE_O, INSTR_RRE_O }, + { "msta", OP16(0xb247LL), MASK_RRE_R, INSTR_RRE_R }, + { "stura", OP16(0xb246LL), MASK_RRE, INSTR_RRE }, + { "sqer", OP16(0xb245LL), MASK_RRE_E, INSTR_RRE_E }, + { "sqdr", OP16(0xb244LL), MASK_RRE_D, INSTR_RRE_D }, + { "cksm", OP16(0xb241LL), MASK_RRE, INSTR_RRE }, + { "bakr", OP16(0xb240LL), MASK_RRE, INSTR_RRE }, + { "schm", OP16(0xb23cLL), MASK_S_O, INSTR_S_O }, + { "rchp", OP16(0xb23bLL), MASK_S_O, INSTR_S_O }, + { "stcps", OP16(0xb23aLL), MASK_S, INSTR_S }, + { "stcrw", OP16(0xb239LL), MASK_S, INSTR_S }, + { "rsch", OP16(0xb238LL), MASK_S_O, INSTR_S_O }, + { "sal", OP16(0xb237LL), MASK_S_O, INSTR_S_O }, + { "tpi", OP16(0xb236LL), MASK_S, INSTR_S }, + { "tsch", OP16(0xb235LL), MASK_S, INSTR_S }, + { "stsch", OP16(0xb234LL), MASK_S, INSTR_S }, + { "ssch", OP16(0xb233LL), MASK_S, INSTR_S }, + { "msch", OP16(0xb232LL), MASK_S, INSTR_S }, + { "hsch", OP16(0xb231LL), MASK_S_O, INSTR_S_O }, + { "csch", OP16(0xb230LL), MASK_S_O, INSTR_S_O }, + { "dxr", OP16(0xb22dLL), MASK_RRE_X, INSTR_RRE_X }, + { "tb", OP16(0xb22cLL), MASK_RRE, INSTR_RRE }, + { "sske", OP16(0xb22bLL), MASK_RRE, INSTR_RRE }, + { "rrbe", OP16(0xb22aLL), MASK_RRE, INSTR_RRE }, + { "iske", OP16(0xb229LL), MASK_RRE, INSTR_RRE }, + { "pt", OP16(0xb228LL), MASK_RRE, INSTR_RRE }, + { "esar", OP16(0xb227LL), MASK_RRE_R, INSTR_RRE_R }, + { "epar", OP16(0xb226LL), MASK_RRE_R, INSTR_RRE_R }, + { "ssar", OP16(0xb225LL), MASK_RRE_R, INSTR_RRE_R }, + { "iac", OP16(0xb224LL), MASK_RRE_R, INSTR_RRE_R }, + { "ivsk", OP16(0xb223LL), MASK_RRE, INSTR_RRE }, + { "ipm", OP16(0xb222LL), MASK_RRE_R, INSTR_RRE_R }, + { "ipte", OP16(0xb221LL), MASK_RRE, INSTR_RRE }, + { "cfc", OP16(0xb21aLL), MASK_S, INSTR_S }, + { "sac", OP16(0xb219LL), MASK_S, INSTR_S }, + { "pc", OP16(0xb218LL), MASK_S, INSTR_S }, + { "sie", OP16(0xb214LL), MASK_S, INSTR_S }, + { "stap", OP16(0xb212LL), MASK_S, INSTR_S }, + { "stpx", OP16(0xb211LL), MASK_S, INSTR_S }, + { "spx", OP16(0xb210LL), MASK_S, INSTR_S }, + { "ptlb", OP16(0xb20dLL), MASK_S_O, INSTR_S_O }, + { "ipk", OP16(0xb20bLL), MASK_S_O, INSTR_S_O }, + { "spka", OP16(0xb20aLL), MASK_S, INSTR_S }, + { "stpt", OP16(0xb209LL), MASK_S, INSTR_S }, + { "spt", OP16(0xb208LL), MASK_S, INSTR_S }, + { "stckc", OP16(0xb207LL), MASK_S, INSTR_S }, + { "sckc", OP16(0xb206LL), MASK_S, INSTR_S }, + { "stck", OP16(0xb205LL), MASK_S, INSTR_S }, + { "sck", OP16(0xb204LL), MASK_S, INSTR_S }, + { "stidp", OP16(0xb202LL), MASK_S, INSTR_S }, + { "lra", OP8(0xb1LL), MASK_RX, INSTR_RX }, + { "mc", OP8(0xafLL), MASK_SI, INSTR_SI }, + { "sigp", OP8(0xaeLL), MASK_RS, INSTR_RS }, + { "stosm", OP8(0xadLL), MASK_SI, INSTR_SI }, + { "stnsm", OP8(0xacLL), MASK_SI, INSTR_SI }, + { "clcle", OP8(0xa9LL), MASK_RS, INSTR_RS }, + { "mvcle", OP8(0xa8LL), MASK_RS, INSTR_RS }, + { "j", OP16(0xa7f4LL), MASK_RI_B, INSTR_RI_B }, + { "jno", OP16(0xa7e4LL), MASK_RI_B, INSTR_RI_B }, + { "jnp", OP16(0xa7d4LL), MASK_RI_B, INSTR_RI_B }, + { "jnh", OP16(0xa7d4LL), MASK_RI_B, INSTR_RI_B }, + { "jnm", OP16(0xa7b4LL), MASK_RI_B, INSTR_RI_B }, + { "jnl", OP16(0xa7b4LL), MASK_RI_B, INSTR_RI_B }, + { "jz", OP16(0xa784LL), MASK_RI_B, INSTR_RI_B }, + { "je", OP16(0xa784LL), MASK_RI_B, INSTR_RI_B }, + { "jnz", OP16(0xa774LL), MASK_RI_B, INSTR_RI_B }, + { "jne", OP16(0xa774LL), MASK_RI_B, INSTR_RI_B }, + { "jm", OP16(0xa744LL), MASK_RI_B, INSTR_RI_B }, + { "jl", OP16(0xa744LL), MASK_RI_B, INSTR_RI_B }, + { "jp", OP16(0xa724LL), MASK_RI_B, INSTR_RI_B }, + { "jh", OP16(0xa724LL), MASK_RI_B, INSTR_RI_B }, + { "jo", OP16(0xa714LL), MASK_RI_B, INSTR_RI_B }, + { "chi", OP16(0xa70eLL), MASK_RI, INSTR_RI }, + { "mhi", OP16(0xa70cLL), MASK_RI, INSTR_RI }, + { "ahi", OP16(0xa70aLL), MASK_RI, INSTR_RI }, + { "lhi", OP16(0xa708LL), MASK_RI, INSTR_RI }, + { "brct", OP16(0xa706LL), MASK_RI_A, INSTR_RI_A }, + { "bras", OP16(0xa705LL), MASK_RI_A, INSTR_RI_A }, + { "brc", OP16(0xa704LL), MASK_RI_MA, INSTR_RI_MA }, + { "tml", OP16(0xa701LL), MASK_RI_U, INSTR_RI_U }, + { "tmh", OP16(0xa700LL), MASK_RI_U, INSTR_RI_U }, + { "stam", OP8(0x9bLL), MASK_RS_A, INSTR_RS_A }, + { "lam", OP8(0x9aLL), MASK_RS_A, INSTR_RS_A }, + { "trace", OP8(0x99LL), MASK_RS, INSTR_RS }, + { "lm", OP8(0x98LL), MASK_RS, INSTR_RS }, + { "xi", OP8(0x97LL), MASK_SI, INSTR_SI }, + { "oi", OP8(0x96LL), MASK_SI, INSTR_SI }, + { "cli", OP8(0x95LL), MASK_SI, INSTR_SI }, + { "ni", OP8(0x94LL), MASK_SI, INSTR_SI }, + { "ts", OP8(0x93LL), MASK_S, INSTR_S }, + { "mvi", OP8(0x92LL), MASK_SI, INSTR_SI }, + { "tm", OP8(0x91LL), MASK_SI, INSTR_SI }, + { "stm", OP8(0x90LL), MASK_RS, INSTR_RS }, + { "slda", OP8(0x8fLL), MASK_RS_D, INSTR_RS_D }, + { "srda", OP8(0x8eLL), MASK_RS_D, INSTR_RS_D }, + { "sldl", OP8(0x8dLL), MASK_RS_D, INSTR_RS_D }, + { "srdl", OP8(0x8cLL), MASK_RS_D, INSTR_RS_D }, + { "sla", OP8(0x8bLL), MASK_RS_S, INSTR_RS_S }, + { "sra", OP8(0x8aLL), MASK_RS_S, INSTR_RS_S }, + { "sll", OP8(0x89LL), MASK_RS_S, INSTR_RS_S }, + { "srl", OP8(0x88LL), MASK_RS_S, INSTR_RS_S }, + { "bxle", OP8(0x87LL), MASK_RS, INSTR_RS }, + { "bxh", OP8(0x86LL), MASK_RS, INSTR_RS }, + { "brxle", OP8(0x85LL), MASK_RSI_A, INSTR_RSI_A }, + { "brxh", OP8(0x84LL), MASK_RSI_A, INSTR_RSI_A }, + { "diag", OP8(0x83LL), MASK_RS, INSTR_RS }, + { "lpsw", OP8(0x82LL), MASK_S, INSTR_S }, + { "ssm", OP8(0x80LL), MASK_S, INSTR_S }, + { "su", OP8(0x7fLL), MASK_RX_E, INSTR_RX_E }, + { "au", OP8(0x7eLL), MASK_RX_E, INSTR_RX_E }, + { "de", OP8(0x7dLL), MASK_RX_E, INSTR_RX_E }, + { "me", OP8(0x7cLL), MASK_RX_ED, INSTR_RX_ED }, + { "se", OP8(0x7bLL), MASK_RX_E, INSTR_RX_E }, + { "ae", OP8(0x7aLL), MASK_RX_E, INSTR_RX_E }, + { "ce", OP8(0x79LL), MASK_RX_E, INSTR_RX_E }, + { "le", OP8(0x78LL), MASK_RX_E, INSTR_RX_E }, + { "ms", OP8(0x71LL), MASK_RX, INSTR_RX }, + { "ste", OP8(0x70LL), MASK_RX_E, INSTR_RX_E }, + { "sw", OP8(0x6fLL), MASK_RX_D, INSTR_RX_D }, + { "aw", OP8(0x6eLL), MASK_RX_D, INSTR_RX_D }, + { "dd", OP8(0x6dLL), MASK_RX_D, INSTR_RX_D }, + { "md", OP8(0x6cLL), MASK_RX_D, INSTR_RX_D }, + { "sd", OP8(0x6bLL), MASK_RX_D, INSTR_RX_D }, + { "ad", OP8(0x6aLL), MASK_RX_D, INSTR_RX_D }, + { "cd", OP8(0x69LL), MASK_RX_D, INSTR_RX_D }, + { "ld", OP8(0x68LL), MASK_RX_D, INSTR_RX_D }, + { "mxd", OP8(0x67LL), MASK_RX_DX, INSTR_RX_DX }, + { "std", OP8(0x60LL), MASK_RX_D, INSTR_RX_D }, + { "sl", OP8(0x5fLL), MASK_RX, INSTR_RX }, + { "al", OP8(0x5eLL), MASK_RX, INSTR_RX }, + { "d", OP8(0x5dLL), MASK_RX, INSTR_RX }, + { "m", OP8(0x5cLL), MASK_RX, INSTR_RX }, + { "s", OP8(0x5bLL), MASK_RX, INSTR_RX }, + { "a", OP8(0x5aLL), MASK_RX, INSTR_RX }, + { "c", OP8(0x59LL), MASK_RX, INSTR_RX }, + { "l", OP8(0x58LL), MASK_RX, INSTR_RX }, + { "x", OP8(0x57LL), MASK_RX, INSTR_RX }, + { "o", OP8(0x56LL), MASK_RX, INSTR_RX }, + { "cl", OP8(0x55LL), MASK_RX, INSTR_RX }, + { "n", OP8(0x54LL), MASK_RX, INSTR_RX }, + { "lae", OP8(0x51LL), MASK_RX, INSTR_RX }, + { "st", OP8(0x50LL), MASK_RX, INSTR_RX }, + { "cvb", OP8(0x4fLL), MASK_RX, INSTR_RX }, + { "cvd", OP8(0x4eLL), MASK_RX, INSTR_RX }, + { "bas", OP8(0x4dLL), MASK_RX, INSTR_RX }, + { "mh", OP8(0x4cLL), MASK_RX, INSTR_RX }, + { "sh", OP8(0x4bLL), MASK_RX, INSTR_RX }, + { "ah", OP8(0x4aLL), MASK_RX, INSTR_RX }, + { "ch", OP8(0x49LL), MASK_RX, INSTR_RX }, + { "lh", OP8(0x48LL), MASK_RX, INSTR_RX }, + { "b", OP16(0x47f0LL), MASK_RX_B, INSTR_RX_B }, + { "bno", OP16(0x47e0LL), MASK_RX_B, INSTR_RX_B }, + { "bnp", OP16(0x47d0LL), MASK_RX_B, INSTR_RX_B }, + { "bnh", OP16(0x47d0LL), MASK_RX_B, INSTR_RX_B }, + { "bnm", OP16(0x47b0LL), MASK_RX_B, INSTR_RX_B }, + { "bnl", OP16(0x47b0LL), MASK_RX_B, INSTR_RX_B }, + { "bz", OP16(0x4780LL), MASK_RX_B, INSTR_RX_B }, + { "be", OP16(0x4780LL), MASK_RX_B, INSTR_RX_B }, + { "bnz", OP16(0x4770LL), MASK_RX_B, INSTR_RX_B }, + { "bne", OP16(0x4770LL), MASK_RX_B, INSTR_RX_B }, + { "bm", OP16(0x4740LL), MASK_RX_B, INSTR_RX_B }, + { "bl", OP16(0x4740LL), MASK_RX_B, INSTR_RX_B }, + { "bp", OP16(0x4720LL), MASK_RX_B, INSTR_RX_B }, + { "bh", OP16(0x4720LL), MASK_RX_B, INSTR_RX_B }, + { "bo", OP16(0x4710LL), MASK_RX_B, INSTR_RX_B }, + { "bc", OP8(0x47LL), MASK_RX_M, INSTR_RX_M }, + { "nop", OP16(0x4700LL), MASK_RX_B, INSTR_RX_B }, + { "bct", OP8(0x46LL), MASK_RX, INSTR_RX }, + { "bal", OP8(0x45LL), MASK_RX, INSTR_RX }, + { "ex", OP8(0x44LL), MASK_RX, INSTR_RX }, + { "ic", OP8(0x43LL), MASK_RX, INSTR_RX }, + { "stc", OP8(0x42LL), MASK_RX, INSTR_RX }, + { "la", OP8(0x41LL), MASK_RX, INSTR_RX }, + { "sth", OP8(0x40LL), MASK_RX, INSTR_RX }, + { "sur", OP8(0x3fLL), MASK_RR_E, INSTR_RR_E }, + { "aur", OP8(0x3eLL), MASK_RR_E, INSTR_RR_E }, + { "der", OP8(0x3dLL), MASK_RR_E, INSTR_RR_E }, + { "mer", OP8(0x3cLL), MASK_RR_ED, INSTR_RR_ED }, + { "ser", OP8(0x3bLL), MASK_RR_E, INSTR_RR_E }, + { "aer", OP8(0x3aLL), MASK_RR_E, INSTR_RR_E }, + { "cer", OP8(0x39LL), MASK_RR_E, INSTR_RR_E }, + { "ler", OP8(0x38LL), MASK_RR_E, INSTR_RR_E }, + { "sxr", OP8(0x37LL), MASK_RR_X, INSTR_RR_X }, + { "axr", OP8(0x36LL), MASK_RR, INSTR_RR }, + { "lrer", OP8(0x35LL), MASK_RR_DE, INSTR_RR_DE }, + { "her", OP8(0x34LL), MASK_RR_E, INSTR_RR_E }, + { "lcer", OP8(0x33LL), MASK_RR_E, INSTR_RR_E }, + { "lter", OP8(0x32LL), MASK_RR_E, INSTR_RR_E }, + { "lner", OP8(0x31LL), MASK_RR_E, INSTR_RR_E }, + { "lper", OP8(0x30LL), MASK_RR_E, INSTR_RR_E }, + { "swr", OP8(0x2fLL), MASK_RR_D, INSTR_RR_D }, + { "awr", OP8(0x2eLL), MASK_RR_D, INSTR_RR_D }, + { "ddr", OP8(0x2dLL), MASK_RR_D, INSTR_RR_D }, + { "mdr", OP8(0x2cLL), MASK_RR_D, INSTR_RR_D }, + { "sdr", OP8(0x2bLL), MASK_RR_D, INSTR_RR_D }, + { "adr", OP8(0x2aLL), MASK_RR_D, INSTR_RR_D }, + { "cdr", OP8(0x29LL), MASK_RR_D, INSTR_RR_D }, + { "ldr", OP8(0x28LL), MASK_RR_D, INSTR_RR_D }, + { "mxdr", OP8(0x27LL), MASK_RR_DX, INSTR_RR_DX }, + { "mxr", OP8(0x26LL), MASK_RR_X, INSTR_RR_X }, + { "lrdr", OP8(0x25LL), MASK_RR_XD, INSTR_RR_XD }, + { "hdr", OP8(0x24LL), MASK_RR_D, INSTR_RR_D }, + { "lcdr", OP8(0x23LL), MASK_RR_D, INSTR_RR_D }, + { "ltdr", OP8(0x22LL), MASK_RR_D, INSTR_RR_D }, + { "lndr", OP8(0x21LL), MASK_RR_D, INSTR_RR_D }, + { "lpdr", OP8(0x20LL), MASK_RR_D, INSTR_RR_D }, + { "slr", OP8(0x1fLL), MASK_RR, INSTR_RR }, + { "alr", OP8(0x1eLL), MASK_RR, INSTR_RR }, + { "dr", OP8(0x1dLL), MASK_RR, INSTR_RR }, + { "mr", OP8(0x1cLL), MASK_RR, INSTR_RR }, + { "sr", OP8(0x1bLL), MASK_RR, INSTR_RR }, + { "ar", OP8(0x1aLL), MASK_RR, INSTR_RR }, + { "cr", OP8(0x19LL), MASK_RR, INSTR_RR }, + { "lr", OP8(0x18LL), MASK_RR, INSTR_RR }, + { "xr", OP8(0x17LL), MASK_RR, INSTR_RR }, + { "or", OP8(0x16LL), MASK_RR, INSTR_RR }, + { "clr", OP8(0x15LL), MASK_RR, INSTR_RR }, + { "nr", OP8(0x14LL), MASK_RR, INSTR_RR }, + { "lcr", OP8(0x13LL), MASK_RR, INSTR_RR }, + { "ltr", OP8(0x12LL), MASK_RR, INSTR_RR }, + { "lnr", OP8(0x11LL), MASK_RR, INSTR_RR }, + { "lpr", OP8(0x10LL), MASK_RR, INSTR_RR }, + { "clcl", OP8(0x0fLL), MASK_RR, INSTR_RR }, + { "mvcl", OP8(0x0eLL), MASK_RR, INSTR_RR }, + { "basr", OP8(0x0dLL), MASK_RR, INSTR_RR }, + { "bassm", OP8(0x0cLL), MASK_RR, INSTR_RR }, + { "bsm", OP8(0x0bLL), MASK_RR, INSTR_RR }, + { "svc", OP8(0x0aLL), MASK_RR_I, INSTR_RR_I }, + { "br", OP16(0x07f0LL), MASK_RR_B, INSTR_RR_B }, + { "bnor", OP16(0x07e0LL), MASK_RR_B, INSTR_RR_B }, + { "bnpr", OP16(0x07d0LL), MASK_RR_B, INSTR_RR_B }, + { "bnhr", OP16(0x07d0LL), MASK_RR_B, INSTR_RR_B }, + { "bnmr", OP16(0x07b0LL), MASK_RR_B, INSTR_RR_B }, + { "bnlr", OP16(0x07b0LL), MASK_RR_B, INSTR_RR_B }, + { "bzr", OP16(0x0780LL), MASK_RR_B, INSTR_RR_B }, + { "ber", OP16(0x0780LL), MASK_RR_B, INSTR_RR_B }, + { "bnzr", OP16(0x0770LL), MASK_RR_B, INSTR_RR_B }, + { "bner", OP16(0x0770LL), MASK_RR_B, INSTR_RR_B }, + { "bmr", OP16(0x0740LL), MASK_RR_B, INSTR_RR_B }, + { "blr", OP16(0x0740LL), MASK_RR_B, INSTR_RR_B }, + { "bpr", OP16(0x0720LL), MASK_RR_B, INSTR_RR_B }, + { "bhr", OP16(0x0720LL), MASK_RR_B, INSTR_RR_B }, + { "bor", OP16(0x0710LL), MASK_RR_B, INSTR_RR_B }, + { "bcr", OP8(0x07LL), MASK_RR_M, INSTR_RR_M }, + { "nopr", OP16(0x0700LL), MASK_RR_B, INSTR_RR_B }, + { "bctr", OP8(0x06LL), MASK_RR, INSTR_RR }, + { "balr", OP8(0x05LL), MASK_RR, INSTR_RR }, + { "spm", OP8(0x04LL), MASK_RR_R, INSTR_RR_R }, + { "upt", OP16(0x0102LL), MASK_E, INSTR_E }, + { "pr", OP16(0x0101LL), MASK_E, INSTR_E } +}; + +const int s390_num_opcodes = + sizeof (s390_opcodes) / sizeof (s390_opcodes[0]); + --- /dev/null Tue Jun 1 11:25:19 1999 +++ gdb.new/opcodes/s390-opc.txt Fri Oct 13 13:49:45 2000 @@ -0,0 +1,393 @@ +# S/390 opcodes list. Use s390-mkopc to convert it into the opcode table. +# Copyright (C) 2000 Free Software Foundation, Inc. +# Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). +5a a RX "add" mchi +6a ad RX_D "add normalized (long)" mchi +2a adr RR_D "add normalized (long)" mchi +7a ae RX_E "add normalized (short)" mchi +3a aer RR_E "add normalized (short)" mchi +4a ah RX "add halfword" mchi +5e al RX "add logical" mchi +1e alr RR "add logical" mchi +fa ap SS_LL "add decimal" mchi +1a ar RR "add" mchi +7e au RX_E "add unnormalized (short)" mchi +3e aur RR_E "add unnormalized (short)" mchi +6e aw RX_D "add unnormalized (long)" mchi +2e awr RR_D "add unnormalized (long)" mchi +36 axr RR "add normalized" mchi +b240 bakr RRE "branch and stack" mchi +45 bal RX "branch and link" mchi +05 balr RR "branch and link" mchi +4d bas RX "branch and save" mchi +0d basr RR "branch and save" mchi +0c bassm RR "branch and save and set mode" mchi +47 bc RX_M "branch on condition" mchi +07 bcr RR_M "branch on condition" mchi +46 bct RX "branch on count" mchi +06 bctr RR "branch on count" mchi +b258 bsg RRE "branch in subspace group" mchi +0b bsm RR "branch and set mode" mchi +86 bxh RS "branch on index high" mchi +87 bxle RS "branch on index low or equal" mchi +59 c RX "compare" mchi +69 cd RX_D "compare (long)" mchi +29 cdr RR_D "compare (long)" mchi +bb cds RS "compare double and swap" mchi +79 ce RX_E "compare (short)" mchi +39 cer RR_E "compare (short)" mchi +b21a cfc S "compare and form codeword" mchi +49 ch RX "compare halfword" mchi +55 cl RX "compare logical" mchi +d5 clc SS_L "compare logical" mchi +0f clcl RR "compare logical long" mchi +95 cli SI "compare logical" mchi +bd clm RS_M "compare logical characters under mask" mchi +15 clr RR "compare logical" mchi +b25d clst RRE "compare logical string" mchi +b263 cmpsc RRE "compression call" mchi +f9 cp SS_LL "compare decimal" mchi +b24d cpya RRE_A "copy access" mchi +19 cr RR "compare" mchi +ba cs RS "compare and swap" mchi +b230 csch S_O "clear subchannel" mchi +b250 csp RRE "compare and swap and purge" mchi +b257 cuse RRE "compare until substring equal" mchi +4f cvb RX "convert to binary" mchi +4e cvd RX "convert to decimal" mchi +5d d RX "divide" mchi +6d dd RX_D "divide (long)" mchi +2d ddr RR_D "divide (long)" mchi +7d de RX_E "divide (short)" mchi +3d der RR_E "divide (short)" mchi +83 diag RS "diagnose" mchi +fd dp SS_LL "divide decimal" mchi +1d dr RR "divide" mchi +b22d dxr RRE_X "divide (ext.)" mchi +b24f ear RRE_RA "extract access" mchi +de ed SS_L "edit" mchi +df edmk SS_L "edit and mark" mchi +b226 epar RRE_R "extract primary ASN" mchi +b249 ereg RRE "extract stacked registers" mchi +b227 esar RRE_R "extract secondary ASN" mchi +b24a esta RRE "extract stacked state" mchi +44 ex RX "execute" mchi +24 hdr RR_D "halve (long)" mchi +34 her RR_E "halve (short)" mchi +b231 hsch S_O "halt subchannel" mchi +b224 iac RRE_R "insert address space control" mchi +43 ic RX "insert character" mchi +bf icm RS_M "insert characters under mask" mchi +b20b ipk S_O "insert PSW key" mchi +b222 ipm RRE_R "insert program mask" mchi +b221 ipte RRE "invalidate page table entry" mchi +b229 iske RRE "insert storage key extended" mchi +b223 ivsk RRE "insert virtual storage key" mchi +58 l RX "load" mchi +41 la RX "load address" mchi +51 lae RX "load address extended" mchi +9a lam RS_A "load access multiple" mchi +e500 lasp SSE "load address space parameters" mchi +23 lcdr RR_D "load complement (long)" mchi +33 lcer RR_E "load complement (short)" mchi +13 lcr RR "load complement" mchi +b7 lctl RS_C "load control" mchi +68 ld RX_D "load (long)" mchi +28 ldr RR_D "load (long)" mchi +78 le RX_E "load (short)" mchi +38 ler RR_E "load (short)" mchi +48 lh RX "load halfword" mchi +98 lm RS "load multiple" mchi +21 lndr RR_D "load negative (long)" mchi +31 lner RR_E "load negative (short)" mchi +11 lnr RR "load negative" mchi +20 lpdr RR_D "load positive (long)" mchi +30 lper RR_E "load positive (short)" mchi +10 lpr RR "load positive" mchi +82 lpsw S "load PSW" mchi +18 lr RR "load" mchi +b1 lra RX "load real address" mchi +25 lrdr RR_XD "load rounded (ext. to long)" mchi +35 lrer RR_DE "load rounded (long to short)" mchi +22 ltdr RR_D "load and test (long)" mchi +32 lter RR_E "load and test (short)" mchi +12 ltr RR "load and test" mchi +b24b lura RRE "load using real address" mchi +5c m RX "multiply" mchi +af mc SI "monitor call" mchi +6c md RX_D "multiply (long)" mchi +2c mdr RR_D "multiply (long)" mchi +7c me RX_ED "multiply (short to long)" mchi +3c mer RR_ED "multiply (short to long)" mchi +4c mh RX "multiply halfword" mchi +fc mp SS_LL "multiply decimal" mchi +1c mr RR "multiply" mchi +b232 msch S "modify subchannel" mchi +b247 msta RRE_R "modify stacked state" mchi +d2 mvc SS_L "move" mchi +e50f mvcdk SSE "move with destination key" mchi +e8 mvcin SS_L "move inverse" mchi +d9 mvck SS_RR "move with key" mchi +0e mvcl RR "move long" mchi +da mvcp SS_RR "move to primary" mchi +db mvcs SS_RR "move to secondary" mchi +e50e mvcsk SSE "move with source key" mchi +92 mvi SI "move" mchi +d1 mvn SS_L "move numerics" mchi +f1 mvo SS_LL "move with offset" mchi +b254 mvpg RRE "move page" mchi +b255 mvst RRE "move string" mchi +d3 mvz SS_L "move zones" mchi +67 mxd RX_DX "multiply (long to ext.)" mchi +27 mxdr RR_DX "multiply (long to ext.)" mchi +26 mxr RR_X "multiply (ext.)" mchi +54 n RX "AND" mchi +d4 nc SS_L "AND" mchi +94 ni SI "AND" mchi +14 nr RR "AND" mchi +56 o RX "OR" mchi +d6 oc SS_L "OR" mchi +96 oi SI "OR" mchi +16 or RR "OR" mchi +f2 pack SS_LL "pack" mchi +b248 palb RRE_O "purge ALB" mchi +b218 pc S "program call" mchi +0101 pr E "program return" mchi +b228 pt RRE "program transfer" mchi +b20d ptlb S_O "purge TLB" mchi +b23b rchp S_O "reset channel path" mchi +b22a rrbe RRE "reset reference bit extended" mchi +b238 rsch S_O "resume subchannel" mchi +5b s RX "subtract" mchi +b219 sac S "set address space control" mchi +b279 sacf S "set address space control fast" mchi +b237 sal S_O "set address limit" mchi +b24e sar RRE_AR "set access" mchi +b23c schm S_O "set channel monitor" mchi +b204 sck S "set clock" mchi +b206 sckc S "set clock comparator" mchi +6b sd RX_D "subtract normalized (long)" mchi +2b sdr RR_D "subtract normalized (long)" mchi +7b se RX_E "subtract normalized (short)" mchi +3b ser RR_E "subtract normalized (short)" mchi +4b sh RX "subtract halfword" mchi +b214 sie S "start interpretive execution" mchi +ae sigp RS "signal processor" mchi +5f sl RX "subtract logical" mchi +8b sla RS_S "shift left single" mchi +8f slda RS_D "shift left double (long)" mchi +8d sldl RS_D "shift left double logical (long)" mchi +89 sll RS_S "shift left single logical" mchi +1f slr RR "subtract logical" mchi +fb sp SS_LL "subtract decimal" mchi +b20a spka S "set PSW key from address" mchi +04 spm RR_R "set program mask" mchi +b208 spt S "set CPU timer" mchi +b210 spx S "set prefix" mchi +b244 sqdr RRE_D "square root (long)" mchi +b245 sqer RRE_E "square root (short)" mchi +1b sr RR "subtract" mchi +8a sra RS_S "shift right single" mchi +8e srda RS_D "shift right double (long)" mchi +8c srdl RS_D "shift right double logical (long)" mchi +88 srl RS_S "shift right single logical" mchi +f0 srp SS_LI "shift and round decimal" mchi +b25e srst RRE "search string" mchi +b225 ssar RRE_R "set secondary ASN" mchi +b233 ssch S "start subchannel" mchi +b22b sske RRE "set storage key extended" mchi +80 ssm S "set system mask" mchi +50 st RX "store" mchi +9b stam RS_A "store access multiple" mchi +b212 stap S "store CPU address" mchi +42 stc RX "store character" mchi +b205 stck S "store clock" mchi +b207 stckc S "store clock comparator" mchi +be stcm RS_M "store characters under mask" mchi +b23a stcps S "store channel path status" mchi +b239 stcrw S "store channel report word" mchi +b6 stctl RS_C "store control" mchi +60 std RX_D "store (long)" mchi +70 ste RX_E "store (short)" mchi +40 sth RX "store halfword" mchi +b202 stidp S "store CPU id" mchi +90 stm RS "store multiple" mchi +ac stnsm SI "store then AND system mask" mchi +ad stosm SI "store then OR system mask" mchi +b209 stpt S "store CPU timer" mchi +b211 stpx S "store prefix" mchi +b234 stsch S "store subchannel" mchi +b246 stura RRE "store using real address" mchi +7f su RX_E "subtract unnormalized (short)" mchi +3f sur RR_E "subtract unnormalized (short)" mchi +0a svc RR_I "supervisor call" mchi +6f sw RX_D "subtract unnormalized (long)" mchi +2f swr RR_D "subtract unnormalized (long)" mchi +37 sxr RR_X "subtract normalized (ext.)" mchi +b24c tar RRE_AR "test access" mchi +b22c tb RRE "test block" mchi +91 tm SI "test under mask" mchi +b236 tpi S "test pending interruption" mchi +e501 tprot SSE "test protection" mchi +dc tr SS_L "translate" mchi +99 trace RS "trace" mchi +dd trt SS_L "translate and test" mchi +93 ts S "test and set" mchi +b235 tsch S "test subchannel" mchi +f3 unpk SS_LL "unpack" mchi +0102 upt E "update tree" mchi +57 x RX "exclusive OR" mchi +d7 xc SS_L "exclusive OR" mchi +97 xi SI "exclusive OR" mchi +17 xr RR "exclusive OR" mchi +f8 zap SS_LL "zero and add" mchi +a7?a ahi RI "add halfword immediate" mchi +84 brxh RSI_A "branch relative on index high" mchi +85 brxle RSI_A "branch relative on index low or equal" mchi +a7?5 bras RI_A "branch relative and save" mchi +a7?4 brc RI_MA "branch relative on condition" mchi +a7?6 brct RI_A "branch relative on count" mchi +b241 cksm RRE "checksum" mchi +a7?e chi RI "compare halfword immediate" mchi +a9 clcle RS "compare logical long extended" mchi +a7?8 lhi RI "load halfword immediate" mchi +a8 mvcle RS "move long extended" mchi +a7?c mhi RI "multiply halfword immediate" mchi +b252 msr RRE "multiply single" mchi +71 ms RX "multiply single" mchi +a7?0 tmh RI_U "test under mask high" mchi +a7?1 tml RI_U "test under mask low" mchi +070? nopr RR_B "no operation" xmni +071? bor RR_B "branch on overflow / if ones" xmni +072? bpr RR_B "branch on plus" xmni +074? bmr RR_B "branch on minus / if mixed" xmni +077? bnzr RR_B "branch on not zero / if not zeros" xmni +078? bzr RR_B "branch on zero / if zeros" xmni +07b? bnmr RR_B "branch on not minus / if not mixed" xmni +07d? bnpr RR_B "branch on not plus" xmni +07e? bnor RR_B "branch on not overflow / if not ones" xmni +07f? br RR_B "unconditional branch" xmni +470? nop RX_B "no operation" xmni +471? bo RX_B "branch on overflow / if ones" xmni +472? bp RX_B "branch on plus" xmni +474? bm RX_B "branch on minus / if mixed" xmni +477? bnz RX_B "branch on not zero / if not zeros" xmni +478? bz RX_B "branch on zero / if zeros" xmni +47b? bnm RX_B "branch on not minus / if not mixed" xmni +47d? bnp RX_B "branch on not plus" xmni +47e? bno RX_B "branch on not overflow / if not ones" xmni +47f? b RX_B "unconditional branch" xmni +a714 jo RI_B "jump on overflow / if ones" xmni +a724 jp RI_B "jump on plus" xmni +a744 jm RI_B "jump on minus / if mixed" xmni +a774 jnz RI_B "jump on not zero / if not zeros" xmni +a784 jz RI_B "jump on zero / if zeros" xmni +a7b4 jnm RI_B "jump on not minus / if not mixed" xmni +a7d4 jnp RI_B "jump on not plus" xmni +a7e4 jno RI_B "jump on not overflow / if not ones" xmni +a7f4 j RI_B "jump" xmni +072? bhr RR_B "branch on A high" xmni +074? blr RR_B "branch on A low" xmni +077? bner RR_B "branch on A not equal B" xmni +078? ber RR_B "branch on A equal B" xmni +07b? bnlr RR_B "branch on A not low" xmni +07d? bnhr RR_B "branch on A not high" xmni +472? bh RX_B "branch on A high" xmni +474? bl RX_B "branch on A low" xmni +477? bne RX_B "branch on A not equal B" xmni +478? be RX_B "branch on A equal B" xmni +47b? bnl RX_B "branch on A not low" xmni +47d? bnh RX_B "branch on A not high" xmni +a724 jh RI_B "jump on A high" xmni +a744 jl RI_B "jump on A low" xmni +a774 jne RI_B "jump on A not equal B" xmni +a784 je RI_B "jump on A equal B" xmni +a7b4 jnl RI_B "jump on A not low" xmni +a7d4 jnh RI_B "jump on A not high" xmni +b34a axbr RRE_F "add extended bfp" mchi +b31a adbr RRE_F "add long bfp" mchi +ed000000001a adb RXE "add long bfp" mchi +b30a aebr RRE_F "add short bfp" mchi +ed000000000a aeb RXE "add short bfp" mchi +b349 cxbr RRE_F "compare extended bfp" mchi +b319 cdbr RRE_F "compare long bfp" mchi +ed0000000019 cdb RXE "compare long bfp" mchi +b309 cebr RRE_F "compare short bfp" mchi +ed0000000009 ceb RXE "compare short bfp" mchi +b348 kxbr RRE_F "compare and signal extended bfp" mchi +b318 kdbr RRE_F "compare and signal long bfp" mchi +ed0000000018 kdb RXE "compare and signal long bfp" mchi +b308 kebr RRE_F "compare and signal short bfp" mchi +ed0000000008 keb RXE "compare and signal short bfp" mchi +b396 cxfbr RRE_F "convert from fixed 32 to extended bfp" mchi +b395 cdfbr RRE_F "convert from fixed 32 to long bfp" mchi +b394 cefbr RRE_F "convert from fixed 32 to short bfp" mchi +b39a cfxbr RRF_M "convert to fixed extended bfp to 32" mchi +b399 cfdbr RRF_M "convert to fixed long bfp to 32" mchi +b398 cfebr RRF_M "convert to fixed short bfp to 32" mchi +b34d dxbr RRE_F "divide extended bfp" mchi +b31d ddbr RRE_F "divide long bfp" mchi +ed000000001d ddb RXE "divide long bfp" mchi +b30d debr RRE_F "divide short bfp" mchi +ed000000000d deb RXE "divide short bfp" mchi +b35b didbr RRF_RM "divide to integer long bfp" mchi +b353 diebr RRF_RM "divide to integer short bfp" mchi +b38c efpc RRE "extract fpc" mchi +b342 ltxbr RRE_F "load and test extended bfp" mchi +b312 ltdbr RRE_F "load and test long bfp" mchi +b302 ltebr RRE_F "load and test short bfp" mchi +b343 lcxbr RRE_F "load complement extended bfp" mchi +b313 lcdbr RRE_F "load complement long bfp" mchi +b303 lcebr RRE_F "load complement short bfp" mchi +b347 fixbr RRF_M "load fp integer extended bfp" mchi +b35f fidbr RRF_M "load fp integer long bfp" mchi +b357 fiebr RRF_M "load fp integer short bfp" mchi +b29d lfpc S "load fpc" mchi +b305 lxdbr RRE_F "load lengthened long to extended bfp" mchi +ed0000000005 lxdb RXE "load lengthened long to extended bfp" mchi +b306 lxebr RRE_F "load lengthened short to extended bfp" mchi +ed0000000006 lxeb RXE "load lengthened short to extended bfp" mchi +b304 ldebr RRE_F "load lengthened short to long bfp" mchi +ed0000000004 ldeb RXE "load lengthened short to long bfp" mchi +b341 lnxbr RRE_F "load negative extended bfp" mchi +b311 lndbr RRE_F "load negative long bfp" mchi +b301 lnebr RRE_F "load negative short bfp" mchi +b340 lpxbr RRE_F "load positive extended bfp" mchi +b310 lpdbr RRE_F "load positive long bfp" mchi +b300 lpebr RRE_F "load positive short bfp" mchi +b345 ldxbr RRE_F "load rounded extended to long bfp" mchi +b346 lexbr RRE_F "load rounded extended to short bfp" mchi +b344 ledbr RRE_F "load rounded long to short bfp" mchi +b34c mxbr RRE_F "multiply extended bfp" mchi +b31c mdbr RRE_F "multiply long bfp" mchi +ed000000001c mdb RXE "multiply long bfp" mchi +b307 mxdbr RRE_F "multiply long to extended bfp" mchi +ed0000000007 mxdb RXE "multiply long to extended bfp" mchi +b317 meebr RRE_F "multiply short bfp" mchi +ed0000000017 meeb RXE "multiply short bfp" mchi +b30c mdebr RRE_F "multiply short to long bfp" mchi +ed000000000c mdeb RXE "multiply short to long bfp" mchi +b31e madbr RRF_R "multiply and add long bfp" mchi +ed000000001e madb RXF "multiply and add long bfp" mchi +b30e maebr RRF_R "multiply and add short bfp" mchi +ed000000000e maeb RXF "multiply and add short bfp" mchi +b31f msdbr RRF_R "multiply and subtract long bfp" mchi +ed000000001f msdb RXF "multiply and subtract long bfp" mchi +b30f msebr RRF_R "multiply and subtract short bfp" mchi +ed000000000f mseb RXF "multiply and subtract short bfp" mchi +b384 sfpc RRE "set fpc" mchi +b299 srnm S "set rounding mode" mchi +b316 sqxbr RRE_F "square root extended bfp" mchi +b315 sqdbr RRE_F "square root long bfp" mchi +ed0000000015 sqdb RXE "square root long bfp" mchi +b314 sqebr RRE_F "square root short bfp" mchi +ed0000000014 sqeb RXE "square root short bfp" mchi +b29c stfpc S "store fpc" mchi +b34b sxbr RRE_F "subtract extended bfp" mchi +b31b sdbr RRE_F "subtract long bfp" mchi +ed000000001b sdb RXE "subtract long bfp" mchi +b30b sebr RRE_F "subtract short bfp" mchi +ed000000000b seb RXE "subtract short bfp" mchi +ed0000000012 tcxb RXE "test data class extended bfp" mchi +ed0000000011 tcdb RXE "test data class long bfp" mchi +ed0000000010 tceb RXE "test data class short bfp" mchi --- gdb.orig/bfd/archures.c Thu Sep 14 03:47:31 2000 +++ gdb.new/bfd/archures.c Fri Oct 13 13:49:45 2000 @@ -306,6 +306,7 @@ extern const bfd_arch_info_type bfd_ns32k_arch; extern const bfd_arch_info_type bfd_w65_arch; extern const bfd_arch_info_type bfd_v850_arch; +extern const bfd_arch_info_type bfd_s390_arch; extern const bfd_arch_info_type bfd_fr30_arch; extern const bfd_arch_info_type bfd_mcore_arch; extern const bfd_arch_info_type bfd_avr_arch; @@ -340,6 +341,7 @@ &bfd_mn10300_arch, &bfd_powerpc_arch, &bfd_rs6000_arch, + &bfd_s390_arch, &bfd_sh_arch, &bfd_sparc_arch, &bfd_tic30_arch, @@ -889,7 +891,9 @@ arch = bfd_arch_sh; number = bfd_mach_sh4; break; - + case 390: + arch = bfd_arch_s390; + break; default: return false; } --- gdb.orig/bfd/bfd-in2.h Thu Oct 12 05:44:50 2000 +++ gdb.new/bfd/bfd-in2.h Fri Oct 13 13:49:45 2000 @@ -1502,6 +1502,8 @@ #define bfd_mach_avr4 4 #define bfd_mach_avr5 5 bfd_arch_cris, /* Axis CRIS */ + bfd_arch_s390, /* IBM s390 */ +#define bfd_mach_s390_esa 0 bfd_arch_last }; @@ -2498,6 +2500,19 @@ into 22 bits. */ BFD_RELOC_AVR_CALL, +/* Additional s390/elf relocations. */ + BFD_RELOC_390_12, /* Direct 12 bit. */ + BFD_RELOC_390_GOT12, /* 12 bit GOT offset. */ + BFD_RELOC_390_PLT32, /* 32 bit PC relative PLT address. */ + BFD_RELOC_390_COPY, /* Copy symbol at runtime. */ + BFD_RELOC_390_GLOB_DAT, /* Create GOT entry. */ + BFD_RELOC_390_JMP_SLOT, /* Create PLT entry. */ + BFD_RELOC_390_RELATIVE, /* Adjust by program base. */ + BFD_RELOC_390_GOTPC, /* 32 bit PC relative offset to GOT. */ + BFD_RELOC_390_GOT16, /* 16 bit GOT offset. */ + BFD_RELOC_390_PC16DBL, /* PC relative 16 bit shifted by 1. */ + BFD_RELOC_390_PLT16DBL, /* 32 bit PC rel. PLT shifted by 1. */ + /* These two relocations are used by the linker to determine which of the entries in a C++ virtual function table are actually used. When the --gc-sections option is given, the linker will zero out the entries --- gdb.orig/bfd/targets.c Fri Sep 29 19:05:22 2000 +++ gdb.new/bfd/targets.c Fri Oct 13 13:49:45 2000 @@ -529,6 +529,7 @@ extern const bfd_target bfd_elf32_hppa_vec; extern const bfd_target bfd_elf32_i370_vec; extern const bfd_target bfd_elf32_i386_vec; +extern const bfd_target bfd_elf32_s390_vec; extern const bfd_target bfd_elf32_i860_vec; extern const bfd_target bfd_elf32_i860_little_vec; extern const bfd_target bfd_elf32_i960_vec; @@ -918,6 +919,7 @@ &vms_vax_vec, &we32kcoff_vec, &z8kcoff_vec, + &bfd_elf32_s390_vec, #endif /* not SELECT_VECS */ --- gdb.orig/include/dis-asm.h Fri Sep 29 20:07:47 2000 +++ gdb.new/include/dis-asm.h Fri Oct 13 13:49:45 2000 @@ -201,6 +201,7 @@ extern int print_insn_tic80 PARAMS ((bfd_vma, disassemble_info*)); extern int print_insn_pj PARAMS ((bfd_vma, disassemble_info*)); extern int print_insn_avr PARAMS ((bfd_vma, disassemble_info*)); +extern int print_insn_s390 PARAMS ((bfd_vma, disassemble_info*)); extern void print_arm_disassembler_options PARAMS ((FILE *)); extern void parse_arm_disassembler_option PARAMS ((char *)); --- gdb.orig/include/elf/common.h Thu Jul 20 17:44:56 2000 +++ gdb.new/include/elf/common.h Fri Oct 13 13:49:45 2000 @@ -196,6 +196,9 @@ #define EM_CYGNUS_MN10200 0xdead #define EM_CYGNUS_MN10300 0xbeef +/* IBM S390 */ +#define EM_S390 0xA390 + /* FR30 magic number - no EABI available. */ #define EM_CYGNUS_FR30 0x3330 --- gdb.orig/opcodes/disassemble.c Fri Sep 29 20:17:25 2000 +++ gdb.new/opcodes/disassemble.c Fri Oct 13 13:49:45 2000 @@ -52,6 +52,7 @@ #define ARCH_rs6000 #define ARCH_sh #define ARCH_sparc +#define ARCH_s390 #define ARCH_tic30 #define ARCH_tic54x #define ARCH_tic80 @@ -243,6 +244,11 @@ disassemble = print_insn_big_powerpc; else disassemble = print_insn_rs6000; + break; +#endif +#ifdef ARCH_s390 + case bfd_arch_s390: + disassemble = print_insn_s390; break; #endif #ifdef ARCH_sh