1 /* tc-s390.c -- Assemble for the S390
2 Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include "safe-ctype.h"
26 #include "struc-symbol.h"
28 #include "opcode/s390.h"
31 /* The default architecture. */
33 #define DEFAULT_ARCH "s390"
35 static char *default_arch = DEFAULT_ARCH;
36 /* Either 32 or 64, selects file format. */
37 static int s390_arch_size;
38 /* Current architecture. Start with the smallest instruction set. */
39 static enum s390_opcode_arch_val current_architecture = S390_OPCODE_ESA;
40 static int current_arch_mask = 1 << S390_OPCODE_ESA;
41 static int current_arch_requested = 0;
43 /* Whether to use user friendly register names. Default is true. */
44 #ifndef TARGET_REG_NAMES_P
45 #define TARGET_REG_NAMES_P true
48 static boolean reg_names_p = TARGET_REG_NAMES_P;
50 /* Set to TRUE if we want to warn about zero base/index registers. */
51 static boolean warn_areg_zero = FALSE;
53 /* Generic assembler global variables which must be defined by all
56 const char comment_chars[] = "#";
58 /* Characters which start a comment at the beginning of a line. */
59 const char line_comment_chars[] = "#";
61 /* Characters which may be used to separate multiple commands on a
63 const char line_separator_chars[] = ";";
65 /* Characters which are used to indicate an exponent in a floating
67 const char EXP_CHARS[] = "eE";
69 /* Characters which mean that a number is a floating point constant,
71 const char FLT_CHARS[] = "dD";
73 /* The target specific pseudo-ops which we support. */
75 /* Define the prototypes for the pseudo-ops */
76 static void s390_byte PARAMS ((int));
77 static void s390_elf_cons PARAMS ((int));
78 static void s390_bss PARAMS ((int));
79 static void s390_insn PARAMS ((int));
80 static void s390_literals PARAMS ((int));
82 const pseudo_typeS md_pseudo_table[] =
84 { "align", s_align_bytes, 0 },
85 /* Pseudo-ops which must be defined. */
86 { "bss", s390_bss, 0 },
87 { "insn", s390_insn, 0 },
88 /* Pseudo-ops which must be overridden. */
89 { "byte", s390_byte, 0 },
90 { "short", s390_elf_cons, 2 },
91 { "long", s390_elf_cons, 4 },
92 { "quad", s390_elf_cons, 8 },
93 { "ltorg", s390_literals, 0 },
94 { "string", stringer, 2 },
99 /* Structure to hold information about predefined registers. */
106 /* List of registers that are pre-defined:
108 Each access register has a predefined name of the form:
109 a<reg_num> which has the value <reg_num>.
111 Each control register has a predefined name of the form:
112 c<reg_num> which has the value <reg_num>.
114 Each general register has a predefined name of the form:
115 r<reg_num> which has the value <reg_num>.
117 Each floating point register a has predefined name of the form:
118 f<reg_num> which has the value <reg_num>.
120 There are individual registers as well:
124 The table is sorted. Suitable for searching by a binary search. */
126 static const struct pd_reg pre_defined_registers[] =
128 { "a0", 0 }, /* Access registers */
145 { "c0", 0 }, /* Control registers */
162 { "f0", 0 }, /* Floating point registers */
179 { "lit", 13 }, /* Pointer to literal pool */
181 { "r0", 0 }, /* General purpose registers */
198 { "sp", 15 }, /* Stack pointer */
202 #define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg))
204 static int reg_name_search
205 PARAMS ((const struct pd_reg *, int, const char *));
206 static boolean register_name PARAMS ((expressionS *));
207 static void init_default_arch PARAMS ((void));
208 static void s390_insert_operand
209 PARAMS ((unsigned char *, const struct s390_operand *, offsetT, char *,
211 static char *md_gather_operands
212 PARAMS ((char *, unsigned char *, const struct s390_opcode *));
214 /* Given NAME, find the register number associated with that name, return
215 the integer value associated with the given name or -1 on failure. */
218 reg_name_search (regs, regcount, name)
219 const struct pd_reg *regs;
223 int middle, low, high;
231 middle = (low + high) / 2;
232 cmp = strcasecmp (name, regs[middle].name);
238 return regs[middle].value;
247 * Summary of register_name().
249 * in: Input_line_pointer points to 1st char of operand.
251 * out: A expressionS.
252 * The operand may have been a register: in this case, X_op == O_register,
253 * X_add_number is set to the register number, and truth is returned.
254 * Input_line_pointer->(next non-blank) char after operand, or is in its
259 register_name (expressionP)
260 expressionS *expressionP;
267 /* Find the spelling of the operand. */
268 start = name = input_line_pointer;
269 if (name[0] == '%' && ISALPHA (name[1]))
270 name = ++input_line_pointer;
274 c = get_symbol_end ();
275 reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT, name);
277 /* Put back the delimiting char. */
278 *input_line_pointer = c;
280 /* Look to see if it's in the register table. */
283 expressionP->X_op = O_register;
284 expressionP->X_add_number = reg_number;
286 /* Make the rest nice. */
287 expressionP->X_add_symbol = NULL;
288 expressionP->X_op_symbol = NULL;
292 /* Reset the line as if we had not done anything. */
293 input_line_pointer = start;
297 /* Local variables. */
299 /* Opformat hash table. */
300 static struct hash_control *s390_opformat_hash;
302 /* Opcode hash table. */
303 static struct hash_control *s390_opcode_hash;
305 /* Flags to set in the elf header */
306 static flagword s390_flags = 0;
308 symbolS *GOT_symbol; /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
310 #ifndef WORKING_DOT_WORD
311 const int md_short_jump_size = 4;
312 const int md_long_jump_size = 4;
315 CONST char *md_shortopts = "A:m:kVQ:";
316 struct option md_longopts[] = {
317 {NULL, no_argument, NULL, 0}
319 size_t md_longopts_size = sizeof (md_longopts);
321 /* Initialize the default opcode arch and word size from the default
322 architecture name. */
326 if (current_arch_requested)
329 if (strcmp (default_arch, "s390") == 0)
332 current_architecture = S390_OPCODE_ESA;
334 else if (strcmp (default_arch, "s390x") == 0)
337 current_architecture = S390_OPCODE_ESAME;
340 as_fatal ("Invalid default architecture, broken assembler.");
341 current_arch_mask = 1 << current_architecture;
344 /* Called by TARGET_FORMAT. */
346 s390_target_format ()
348 /* We don't get a chance to initialize anything before we're called,
349 so handle that now. */
350 if (! s390_arch_size)
351 init_default_arch ();
353 return s390_arch_size == 64 ? "elf64-s390" : "elf32-s390";
357 md_parse_option (c, arg)
363 /* -k: Ignore for FreeBSD compatibility. */
367 if (arg != NULL && strcmp (arg, "regnames") == 0)
370 else if (arg != NULL && strcmp (arg, "no-regnames") == 0)
373 else if (arg != NULL && strcmp (arg, "warn-areg-zero") == 0)
374 warn_areg_zero = TRUE;
376 else if (arg != NULL && strcmp (arg, "31") == 0)
379 else if (arg != NULL && strcmp (arg, "64") == 0)
384 as_bad (_("invalid switch -m%s"), arg);
390 if (arg != NULL && strcmp (arg, "esa") == 0)
391 current_architecture = S390_OPCODE_ESA;
392 else if (arg != NULL && strcmp (arg, "esame") == 0)
393 current_architecture = S390_OPCODE_ESAME;
395 as_bad ("invalid architecture -A%s", arg);
396 current_arch_mask = 1 << current_architecture;
397 current_arch_requested = 1;
400 /* -V: SVR4 argument to print version ID. */
405 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
406 should be emitted or not. FIXME: Not implemented. */
418 md_show_usage (stream)
421 fprintf (stream, _("\
423 -mregnames Allow symbolic names for registers\n\
424 -mwarn-areg-zero Warn about zero base/index registers\n\
425 -mno-regnames Do not allow symbolic names for registers\n\
426 -m31 Set file format to 31 bit format\n\
427 -m64 Set file format to 64 bit format\n"));
428 fprintf (stream, _("\
429 -V print assembler version number\n\
430 -Qy, -Qn ignored\n"));
433 /* This function is called when the assembler starts up. It is called
434 after the options have been parsed and the output file has been
440 register const struct s390_opcode *op;
441 const struct s390_opcode *op_end;
442 boolean dup_insn = false;
445 /* Give a warning if the combination -m64-bit and -Aesa is used. */
446 if (s390_arch_size == 64 && current_arch_mask == (1 << S390_OPCODE_ESA))
447 as_warn ("The 64 bit file format is used without esame instructions.");
449 /* Set the ELF flags if desired. */
451 bfd_set_private_flags (stdoutput, s390_flags);
453 /* Insert the opcode formats into a hash table. */
454 s390_opformat_hash = hash_new ();
456 op_end = s390_opformats + s390_num_opformats;
457 for (op = s390_opformats; op < op_end; op++)
459 retval = hash_insert (s390_opformat_hash, op->name, (PTR) op);
460 if (retval != (const char *) NULL)
462 as_bad (_("Internal assembler error for instruction format %s"),
468 /* Insert the opcodes into a hash table. */
469 s390_opcode_hash = hash_new ();
471 op_end = s390_opcodes + s390_num_opcodes;
472 for (op = s390_opcodes; op < op_end; op++)
474 retval = hash_insert (s390_opcode_hash, op->name, (PTR) op);
475 if (retval != (const char *) NULL)
477 as_bad (_("Internal assembler error for instruction %s"), op->name);
485 record_alignment (text_section, 2);
486 record_alignment (data_section, 2);
487 record_alignment (bss_section, 2);
491 /* Called after all assembly has been done. */
495 if (s390_arch_size == 64)
496 bfd_set_arch_mach (stdoutput, bfd_arch_s390, bfd_mach_s390_64);
498 bfd_set_arch_mach (stdoutput, bfd_arch_s390, bfd_mach_s390_31);
502 s390_align_code (fragP, count)
506 /* We use nop pattern 0x0707. */
509 memset (fragP->fr_literal + fragP->fr_fix, 0x07, count);
510 fragP->fr_var = count;
514 /* Insert an operand value into an instruction. */
517 s390_insert_operand (insn, operand, val, file, line)
519 const struct s390_operand *operand;
527 if (operand->flags & (S390_OPERAND_SIGNED|S390_OPERAND_PCREL))
531 max = ((offsetT) 1 << (operand->bits - 1)) - 1;
532 min = - ((offsetT) 1 << (operand->bits - 1));
533 /* Halve PCREL operands. */
534 if (operand->flags & S390_OPERAND_PCREL)
536 /* Check for underflow / overflow. */
537 if (val < min || val > max)
540 "operand out of range (%s not between %ld and %ld)";
543 if (operand->flags & S390_OPERAND_PCREL)
549 sprint_value (buf, val);
550 if (file == (char *) NULL)
551 as_bad (err, buf, (int) min, (int) max);
553 as_bad_where (file, line, err, buf, (int) min, (int) max);
556 /* val is ok, now restrict it to operand->bits bits. */
557 uval = (addressT) val & ((((addressT) 1 << (operand->bits-1)) << 1) - 1);
563 max = (((addressT) 1 << (operand->bits - 1))<<1) - 1;
565 uval = (addressT) val;
566 /* Length x in an instructions has real length x+1. */
567 if (operand->flags & S390_OPERAND_LENGTH)
569 /* Check for underflow / overflow. */
570 if (uval < min || uval > max)
573 "operand out of range (%s not between %ld and %ld)";
576 if (operand->flags & S390_OPERAND_LENGTH)
582 sprint_value (buf, uval);
583 if (file == (char *) NULL)
584 as_bad (err, buf, (int) min, (int) max);
586 as_bad_where (file, line, err, buf, (int) min, (int) max);
591 /* Insert fragments of the operand byte for byte. */
592 offset = operand->shift + operand->bits;
593 uval <<= (-offset) & 7;
594 insn += (offset - 1)/8;
602 /* Structure used to hold suffixes. */
616 elf_suffix_type suffix;
619 static elf_suffix_type s390_elf_suffix PARAMS ((char **, expressionS *));
620 static int s390_exp_compare PARAMS ((expressionS *exp1, expressionS *exp2));
621 static elf_suffix_type s390_lit_suffix
622 PARAMS ((char **, expressionS *, elf_suffix_type));
625 /* Parse @got/@plt/@gotoff. and return the desired relocation. */
626 static elf_suffix_type
627 s390_elf_suffix (str_p, exp_p)
631 static struct map_bfd mapping[] =
633 { "got", 3, ELF_SUFFIX_GOT },
634 { "got12", 5, ELF_SUFFIX_GOT },
635 { "plt", 3, ELF_SUFFIX_PLT },
636 { "gotent", 6, ELF_SUFFIX_GOTENT },
637 { NULL, 0, ELF_SUFFIX_NONE }
646 return ELF_SUFFIX_NONE;
649 while (ISALNUM (*str))
653 for (ptr = &mapping[0]; ptr->length > 0; ptr++)
654 if (len == ptr->length
655 && strncasecmp (ident, ptr->string, ptr->length) == 0)
657 if (exp_p->X_add_number != 0)
658 as_warn (_("identifier+constant@%s means identifier@%s+constant"),
659 ptr->string, ptr->string);
660 /* Now check for identifier@suffix+constant. */
661 if (*str == '-' || *str == '+')
663 char *orig_line = input_line_pointer;
666 input_line_pointer = str;
667 expression (&new_exp);
669 switch (new_exp.X_op)
671 case O_constant: /* X_add_number (a constant expression). */
672 exp_p->X_add_number += new_exp.X_add_number;
673 str = input_line_pointer;
675 case O_symbol: /* X_add_symbol + X_add_number. */
676 /* this case is used for e.g. xyz@PLT+.Label. */
677 exp_p->X_add_number += new_exp.X_add_number;
678 exp_p->X_op_symbol = new_exp.X_add_symbol;
680 str = input_line_pointer;
682 case O_uminus: /* (- X_add_symbol) + X_add_number. */
683 /* this case is used for e.g. xyz@PLT-.Label. */
684 exp_p->X_add_number += new_exp.X_add_number;
685 exp_p->X_op_symbol = new_exp.X_add_symbol;
686 exp_p->X_op = O_subtract;
687 str = input_line_pointer;
693 /* If s390_elf_suffix has not been called with
694 &input_line_pointer as first parameter, we have
695 clobbered the input_line_pointer. We have to
697 if (&input_line_pointer != str_p)
698 input_line_pointer = orig_line;
704 return BFD_RELOC_UNUSED;
707 /* Structure used to hold a literal pool entry. */
710 struct s390_lpe *next;
712 FLONUM_TYPE floatnum; /* used if X_op == O_big && X_add_number <= 0 */
713 LITTLENUM_TYPE bignum[4]; /* used if X_op == O_big && X_add_number > 0 */
715 bfd_reloc_code_real_type reloc;
719 static struct s390_lpe *lpe_free_list = NULL;
720 static struct s390_lpe *lpe_list = NULL;
721 static struct s390_lpe *lpe_list_tail = NULL;
722 static symbolS *lp_sym = NULL;
723 static int lp_count = 0;
724 static int lpe_count = 0;
727 s390_exp_compare(exp1, exp2)
731 if (exp1->X_op != exp2->X_op)
736 case O_constant: /* X_add_number must be equal. */
738 return exp1->X_add_number == exp2->X_add_number;
741 as_bad (_("Can't handle O_big in s390_exp_compare"));
743 case O_symbol: /* X_add_symbol & X_add_number must be equal. */
748 return (exp1->X_add_symbol == exp2->X_add_symbol)
749 && (exp1->X_add_number == exp2->X_add_number);
751 case O_multiply: /* X_add_symbol,X_op_symbol&X_add_number must be equal. */
756 case O_bit_inclusive_or:
758 case O_bit_exclusive_or:
770 return (exp1->X_add_symbol == exp2->X_add_symbol)
771 && (exp1->X_op_symbol == exp2->X_op_symbol)
772 && (exp1->X_add_number == exp2->X_add_number);
778 /* Test for @lit and if its present make an entry in the literal pool and
779 modify the current expression to be an offset into the literal pool. */
780 static elf_suffix_type
781 s390_lit_suffix (str_p, exp_p, suffix)
784 elf_suffix_type suffix;
786 bfd_reloc_code_real_type reloc;
790 struct s390_lpe *lpe;
794 return suffix; /* No modification. */
796 /* We look for a suffix of the form "@lit1", "@lit2", "@lit4" or "@lit8". */
798 while (ISALNUM (*str))
801 if (len != 4 || strncasecmp (ident, "lit", 3) != 0
802 || (ident[3]!='1' && ident[3]!='2' && ident[3]!='4' && ident[3]!='8'))
803 return suffix; /* no modification */
804 nbytes = ident[3] - '0';
806 reloc = BFD_RELOC_UNUSED;
807 if (suffix == ELF_SUFFIX_GOT)
810 reloc = BFD_RELOC_390_GOT16;
811 else if (nbytes == 4)
812 reloc = BFD_RELOC_32_GOT_PCREL;
813 else if (nbytes == 8)
814 reloc = BFD_RELOC_390_GOT64;
816 else if (suffix == ELF_SUFFIX_PLT)
819 reloc = BFD_RELOC_390_PLT32;
820 else if (nbytes == 8)
821 reloc = BFD_RELOC_390_PLT64;
824 if (suffix != ELF_SUFFIX_NONE && reloc == BFD_RELOC_UNUSED)
825 as_bad (_("Invalid suffix for literal pool entry"));
827 /* Search the pool if the new entry is a duplicate. */
828 if (exp_p->X_op == O_big)
830 /* Special processing for big numbers. */
831 for (lpe = lpe_list; lpe != NULL; lpe = lpe->next)
833 if (lpe->ex.X_op == O_big)
835 if (exp_p->X_add_number <= 0 && lpe->ex.X_add_number <= 0)
837 if (memcmp (&generic_floating_point_number, &lpe->floatnum,
838 sizeof (FLONUM_TYPE)) == 0)
841 else if (exp_p->X_add_number == lpe->ex.X_add_number)
843 if (memcmp (generic_bignum, lpe->bignum,
844 sizeof (LITTLENUM_TYPE)*exp_p->X_add_number) == 0)
852 /* Processing for 'normal' data types. */
853 for (lpe = lpe_list; lpe != NULL; lpe = lpe->next)
854 if (lpe->nbytes == nbytes && lpe->reloc == reloc
855 && s390_exp_compare(exp_p, &lpe->ex) != 0)
862 if (lpe_free_list != NULL)
865 lpe_free_list = lpe_free_list->next;
869 lpe = (struct s390_lpe *) xmalloc(sizeof (struct s390_lpe));
874 if (exp_p->X_op == O_big)
876 if (exp_p->X_add_number <= 0)
877 lpe->floatnum = generic_floating_point_number;
878 else if (exp_p->X_add_number <= 4)
879 memcpy (lpe->bignum, generic_bignum,
880 exp_p->X_add_number*sizeof (LITTLENUM_TYPE));
882 as_bad (_("Big number is too big"));
885 lpe->nbytes = nbytes;
887 /* Literal pool name defined ? */
890 sprintf (tmp_name, ".L\001%i", lp_count);
891 lp_sym = symbol_make(tmp_name);
894 /* Make name for literal pool entry. */
895 sprintf (tmp_name, ".L\001%i\002%i", lp_count, lpe_count);
897 lpe->sym = symbol_make(tmp_name);
899 /* Add to literal pool list. */
901 if (lpe_list_tail != NULL)
903 lpe_list_tail->next = lpe;
907 lpe_list = lpe_list_tail = lpe;
910 /* Now change exp_p to the offset into the literal pool.
911 Thats the expression: .L^Ax^By-.L^Ax */
912 exp_p->X_add_symbol = lpe->sym;
913 exp_p->X_op_symbol = lp_sym;
914 exp_p->X_op = O_subtract;
915 exp_p->X_add_number = 0;
919 /* We change the suffix type to ELF_SUFFIX_NONE, because
920 the difference of two local labels is just a number. */
921 return ELF_SUFFIX_NONE;
924 /* Like normal .long/.short/.word, except support @got, etc.
925 clobbers input_line_pointer, checks end-of-line. */
927 s390_elf_cons (nbytes)
928 register int nbytes; /* 1=.byte, 2=.word, 4=.long */
931 elf_suffix_type suffix;
933 if (is_it_end_of_statement ())
935 demand_empty_rest_of_line ();
943 if (exp.X_op == O_symbol
944 && *input_line_pointer == '@'
945 && (suffix = s390_elf_suffix (&input_line_pointer, &exp)) != ELF_SUFFIX_NONE)
947 bfd_reloc_code_real_type reloc;
948 reloc_howto_type *reloc_howto;
952 if (nbytes == 2 && suffix == ELF_SUFFIX_GOT)
953 reloc = BFD_RELOC_390_GOT16;
954 else if (nbytes == 4 && suffix == ELF_SUFFIX_GOT)
955 reloc = BFD_RELOC_32_GOT_PCREL;
956 else if (nbytes == 8 && suffix == ELF_SUFFIX_GOT)
957 reloc = BFD_RELOC_390_GOT64;
958 else if (nbytes == 4 && suffix == ELF_SUFFIX_PLT)
959 reloc = BFD_RELOC_390_PLT32;
960 else if (nbytes == 8 && suffix == ELF_SUFFIX_PLT)
961 reloc = BFD_RELOC_390_PLT64;
963 reloc = BFD_RELOC_UNUSED;
965 if (reloc != BFD_RELOC_UNUSED)
967 reloc_howto = bfd_reloc_type_lookup (stdoutput, reloc);
968 size = bfd_get_reloc_size (reloc_howto);
970 as_bad (_("%s relocations do not fit in %d bytes"),
971 reloc_howto->name, nbytes);
972 where = frag_more (nbytes);
973 md_number_to_chars (where, 0, size);
974 /* To make fixup_segment do the pc relative conversion the
975 pcrel parameter on the fix_new_exp call needs to be false. */
976 fix_new_exp (frag_now, where - frag_now->fr_literal,
977 size, &exp, false, reloc);
980 as_bad (_("relocation not applicable"));
983 emit_expr (&exp, (unsigned int) nbytes);
985 while (*input_line_pointer++ == ',');
987 input_line_pointer--; /* Put terminator back into stream. */
988 demand_empty_rest_of_line ();
991 /* We need to keep a list of fixups. We can't simply generate them as
992 we go, because that would require us to first create the frag, and
993 that would screw up references to ``.''. */
999 bfd_reloc_code_real_type reloc;
1002 #define MAX_INSN_FIXUPS (4)
1004 /* This routine is called for each instruction to be assembled. */
1007 md_gather_operands (str, insn, opcode)
1009 unsigned char *insn;
1010 const struct s390_opcode *opcode;
1012 struct s390_fixup fixups[MAX_INSN_FIXUPS];
1013 const struct s390_operand *operand;
1014 const unsigned char *opindex_ptr;
1015 elf_suffix_type suffix;
1016 bfd_reloc_code_real_type reloc;
1022 while (ISSPACE (*str)) str++;
1027 /* Gather the operands. */
1029 for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++)
1034 operand = s390_operands + *opindex_ptr;
1036 if (skip_optional && (operand->flags & S390_OPERAND_INDEX))
1038 /* We do an early skip. For D(X,B) constructions the index
1039 register is skipped (X is optional). For D(L,B) the base
1040 register will be the skipped operand, because L is NOT
1046 /* Gather the operand. */
1047 hold = input_line_pointer;
1048 input_line_pointer = str;
1050 if (! register_name (&ex)) /* parse the operand */
1053 str = input_line_pointer;
1054 input_line_pointer = hold;
1056 /* Write the operand to the insn. */
1057 if (ex.X_op == O_illegal)
1058 as_bad (_("illegal operand"));
1059 else if (ex.X_op == O_absent)
1060 as_bad (_("missing operand"));
1061 else if (ex.X_op == O_register || ex.X_op == O_constant)
1063 s390_lit_suffix (&str, &ex, ELF_SUFFIX_NONE);
1065 if (ex.X_op != O_register && ex.X_op != O_constant)
1067 /* We need to generate a fixup for the
1068 expression returned by s390_lit_suffix. */
1069 if (fc >= MAX_INSN_FIXUPS)
1070 as_fatal (_("too many fixups"));
1071 fixups[fc].exp = ex;
1072 fixups[fc].opindex = *opindex_ptr;
1073 fixups[fc].reloc = BFD_RELOC_UNUSED;
1078 if ((operand->flags & S390_OPERAND_INDEX)
1079 && ex.X_add_number == 0
1080 && warn_areg_zero == TRUE)
1081 as_warn ("index register specified but zero");
1082 if ((operand->flags & S390_OPERAND_BASE)
1083 && ex.X_add_number == 0
1084 && warn_areg_zero == TRUE)
1085 as_warn ("base register specified but zero");
1086 s390_insert_operand (insn, operand, ex.X_add_number, NULL, 0);
1091 suffix = s390_elf_suffix (&str, &ex);
1092 suffix = s390_lit_suffix (&str, &ex, suffix);
1093 reloc = BFD_RELOC_UNUSED;
1095 if (suffix == ELF_SUFFIX_GOT)
1097 if (operand->flags & S390_OPERAND_DISP)
1098 reloc = BFD_RELOC_390_GOT12;
1099 else if ((operand->flags & S390_OPERAND_SIGNED)
1100 && (operand->bits == 16))
1101 reloc = BFD_RELOC_390_GOT16;
1102 else if ((operand->flags & S390_OPERAND_PCREL)
1103 && (operand->bits == 32))
1104 reloc = BFD_RELOC_390_GOTENT;
1106 else if (suffix == ELF_SUFFIX_PLT)
1108 if ((operand->flags & S390_OPERAND_PCREL)
1109 && (operand->bits == 16))
1110 reloc = BFD_RELOC_390_PLT16DBL;
1111 else if ((operand->flags & S390_OPERAND_PCREL)
1112 && (operand->bits == 32))
1113 reloc = BFD_RELOC_390_PLT32DBL;
1115 else if (suffix == ELF_SUFFIX_GOTENT)
1117 if ((operand->flags & S390_OPERAND_PCREL)
1118 && (operand->bits == 32))
1119 reloc = BFD_RELOC_390_GOTENT;
1122 if (suffix != ELF_SUFFIX_NONE && reloc == BFD_RELOC_UNUSED)
1123 as_bad (_("invalid operand suffix"));
1124 /* We need to generate a fixup of type 'reloc' for this
1126 if (fc >= MAX_INSN_FIXUPS)
1127 as_fatal (_("too many fixups"));
1128 fixups[fc].exp = ex;
1129 fixups[fc].opindex = *opindex_ptr;
1130 fixups[fc].reloc = reloc;
1134 /* Check the next character. The call to expression has advanced
1135 str past any whitespace. */
1136 if (operand->flags & S390_OPERAND_DISP)
1138 /* After a displacement a block in parentheses can start. */
1141 /* Check if parethesed block can be skipped. If the next
1142 operand is neiter an optional operand nor a base register
1143 then we have a syntax error. */
1144 operand = s390_operands + *(++opindex_ptr);
1145 if (!(operand->flags & (S390_OPERAND_INDEX|S390_OPERAND_BASE)))
1146 as_bad (_("syntax error; missing '(' after displacement"));
1148 /* Ok, skip all operands until S390_OPERAND_BASE. */
1149 while (!(operand->flags & S390_OPERAND_BASE))
1150 operand = s390_operands + *(++opindex_ptr);
1152 /* If there is a next operand it must be seperated by a comma. */
1153 if (opindex_ptr[1] != '\0')
1156 as_bad (_("syntax error; expected ,"));
1161 /* We found an opening parentheses. */
1163 for (f = str; *f != '\0'; f++)
1164 if (*f == ',' || *f == ')')
1166 /* If there is no comma until the closing parentheses OR
1167 there is a comma right after the opening parentheses,
1168 we have to skip optional operands. */
1169 if (*f == ',' && f == str)
1171 /* comma directly after '(' ? */
1176 skip_optional = (*f != ',');
1179 else if (operand->flags & S390_OPERAND_BASE)
1181 /* After the base register the parenthesed block ends. */
1183 as_bad (_("syntax error; missing ')' after base register"));
1185 /* If there is a next operand it must be seperated by a comma. */
1186 if (opindex_ptr[1] != '\0')
1189 as_bad (_("syntax error; expected ,"));
1194 /* We can find an 'early' closing parentheses in e.g. D(L) instead
1195 of D(L,B). In this case the base register has to be skipped. */
1198 operand = s390_operands + *(++opindex_ptr);
1200 if (!(operand->flags & S390_OPERAND_BASE))
1201 as_bad (_("syntax error; ')' not allowed here"));
1204 /* If there is a next operand it must be seperated by a comma. */
1205 if (opindex_ptr[1] != '\0')
1208 as_bad (_("syntax error; expected ,"));
1213 while (ISSPACE (*str))
1220 if ((linefeed = strchr (str, '\n')) != NULL)
1222 as_bad (_("junk at end of line: `%s'"), str);
1223 if (linefeed != NULL)
1227 /* Write out the instruction. */
1228 f = frag_more (opcode->oplen);
1229 memcpy (f, insn, opcode->oplen);
1230 dwarf2_emit_insn (opcode->oplen);
1232 /* Create any fixups. At this point we do not use a
1233 bfd_reloc_code_real_type, but instead just use the
1234 BFD_RELOC_UNUSED plus the operand index. This lets us easily
1235 handle fixups for any operand type, although that is admittedly
1236 not a very exciting feature. We pick a BFD reloc type in
1238 for (i = 0; i < fc; i++)
1240 operand = s390_operands + fixups[i].opindex;
1242 if (fixups[i].reloc != BFD_RELOC_UNUSED)
1244 reloc_howto_type *reloc_howto;
1248 reloc_howto = bfd_reloc_type_lookup (stdoutput, fixups[i].reloc);
1252 size = bfd_get_reloc_size (reloc_howto);
1254 if (size < 1 || size > 4)
1257 fixP = fix_new_exp (frag_now,
1258 f - frag_now->fr_literal + (operand->shift/8),
1259 size, &fixups[i].exp, reloc_howto->pc_relative,
1261 /* Turn off overflow checking in fixup_segment. This is necessary
1262 because fixup_segment will signal an overflow for large 4 byte
1263 quantities for GOT12 relocations. */
1264 if ( fixups[i].reloc == BFD_RELOC_390_GOT12
1265 || fixups[i].reloc == BFD_RELOC_390_GOT16)
1266 fixP->fx_no_overflow = 1;
1269 fix_new_exp (frag_now, f - frag_now->fr_literal, 4, &fixups[i].exp,
1270 (operand->flags & S390_OPERAND_PCREL) != 0,
1271 ((bfd_reloc_code_real_type)
1272 (fixups[i].opindex + (int) BFD_RELOC_UNUSED)));
1277 /* This routine is called for each instruction to be assembled. */
1283 const struct s390_opcode *opcode;
1284 unsigned char insn[6];
1287 /* Get the opcode. */
1288 for (s = str; *s != '\0' && ! ISSPACE (*s); s++)
1293 /* Look up the opcode in the hash table. */
1294 opcode = (struct s390_opcode *) hash_find (s390_opcode_hash, str);
1295 if (opcode == (const struct s390_opcode *) NULL)
1297 as_bad (_("Unrecognized opcode: `%s'"), str);
1300 else if (!(opcode->architecture & current_arch_mask))
1302 as_bad ("Opcode %s not available in this architecture", str);
1306 memcpy (insn, opcode->opcode, sizeof (insn));
1307 md_gather_operands (s, insn, opcode);
1310 #ifndef WORKING_DOT_WORD
1311 /* Handle long and short jumps. We don't support these */
1313 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
1315 addressT from_addr, to_addr;
1323 md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
1325 addressT from_addr, to_addr;
1335 int ignore ATTRIBUTE_UNUSED;
1337 /* We don't support putting frags in the BSS segment, we fake it
1338 by marking in_bss, then looking at s_skip for clues. */
1340 subseg_set (bss_section, 0);
1341 demand_empty_rest_of_line ();
1344 /* Pseudo-op handling. */
1348 int ignore ATTRIBUTE_UNUSED;
1351 const struct s390_opcode *opformat;
1352 unsigned char insn[6];
1355 /* Get the opcode format. */
1356 s = input_line_pointer;
1357 while (*s != '\0' && *s != ',' && ! ISSPACE (*s))
1360 as_bad (_("Invalid .insn format\n"));
1363 /* Look up the opcode in the hash table. */
1364 opformat = (struct s390_opcode *)
1365 hash_find (s390_opformat_hash, input_line_pointer);
1366 if (opformat == (const struct s390_opcode *) NULL)
1368 as_bad (_("Unrecognized opcode format: `%s'"), input_line_pointer);
1371 input_line_pointer = s;
1373 if (exp.X_op == O_constant)
1375 if ( ((opformat->oplen == 6) && (exp.X_op > 0) && (exp.X_op < (1ULL << 48)))
1376 || ((opformat->oplen == 4) && (exp.X_op > 0) && (exp.X_op < (1ULL << 32)))
1377 || ((opformat->oplen == 2) && (exp.X_op > 0) && (exp.X_op < (1ULL << 16))))
1378 md_number_to_chars (insn, exp.X_add_number, opformat->oplen);
1380 as_bad (_("Invalid .insn format\n"));
1382 else if (exp.X_op == O_big)
1384 if (exp.X_add_number > 0
1385 && opformat->oplen == 6
1386 && generic_bignum[3] == 0)
1388 md_number_to_chars (insn, generic_bignum[2], 2);
1389 md_number_to_chars (&insn[2], generic_bignum[1], 2);
1390 md_number_to_chars (&insn[4], generic_bignum[0], 2);
1393 as_bad (_("Invalid .insn format\n"));
1396 as_bad (_("second operand of .insn not a constant\n"));
1398 if (strcmp (opformat->name, "e") != 0 && *input_line_pointer++ != ',')
1399 as_bad (_("missing comma after insn constant\n"));
1401 if ((s = strchr (input_line_pointer, '\n')) != NULL)
1403 input_line_pointer = md_gather_operands (input_line_pointer, insn,
1407 demand_empty_rest_of_line ();
1410 /* The .byte pseudo-op. This is similar to the normal .byte
1411 pseudo-op, but it can also take a single ASCII string. */
1415 int ignore ATTRIBUTE_UNUSED;
1417 if (*input_line_pointer != '\"')
1423 /* Gather characters. A real double quote is doubled. Unusual
1424 characters are not permitted. */
1425 ++input_line_pointer;
1430 c = *input_line_pointer++;
1434 if (*input_line_pointer != '\"')
1436 ++input_line_pointer;
1439 FRAG_APPEND_1_CHAR (c);
1442 demand_empty_rest_of_line ();
1445 /* The .ltorg pseudo-op.This emits all literals defined since the last
1446 .ltorg or the invocation of gas. Literals are defined with the
1450 s390_literals (ignore)
1451 int ignore ATTRIBUTE_UNUSED;
1453 struct s390_lpe *lpe;
1455 if (lp_sym == NULL || lpe_count == 0)
1456 return; /* nothing to be done */
1458 /* Emit symbol for start of literal pool. */
1459 S_SET_SEGMENT (lp_sym, now_seg);
1460 S_SET_VALUE (lp_sym, (valueT) frag_now_fix ());
1461 lp_sym->sy_frag = frag_now;
1466 lpe_list = lpe_list->next;
1467 S_SET_SEGMENT (lpe->sym, now_seg);
1468 S_SET_VALUE (lpe->sym, (valueT) frag_now_fix ());
1469 lpe->sym->sy_frag = frag_now;
1471 /* Emit literal pool entry. */
1472 if (lpe->reloc != BFD_RELOC_UNUSED)
1474 reloc_howto_type *reloc_howto =
1475 bfd_reloc_type_lookup (stdoutput, lpe->reloc);
1476 int size = bfd_get_reloc_size (reloc_howto);
1479 if (size > lpe->nbytes)
1480 as_bad (_("%s relocations do not fit in %d bytes"),
1481 reloc_howto->name, lpe->nbytes);
1482 where = frag_more (lpe->nbytes);
1483 md_number_to_chars (where, 0, size);
1484 fix_new_exp (frag_now, where - frag_now->fr_literal,
1485 size, &lpe->ex, reloc_howto->pc_relative, lpe->reloc);
1489 if (lpe->ex.X_op == O_big)
1491 if (lpe->ex.X_add_number <= 0)
1492 generic_floating_point_number = lpe->floatnum;
1494 memcpy (generic_bignum, lpe->bignum,
1495 lpe->ex.X_add_number*sizeof (LITTLENUM_TYPE));
1497 emit_expr (&lpe->ex, lpe->nbytes);
1500 lpe->next = lpe_free_list;
1501 lpe_free_list = lpe;
1503 lpe_list_tail = NULL;
1509 /* Turn a string in input_line_pointer into a floating point constant
1510 of type type, and store the appropriate bytes in *litp. The number
1511 of LITTLENUMS emitted is stored in *sizep . An error message is
1512 returned, or NULL on OK. */
1515 md_atof (type, litp, sizep)
1521 LITTLENUM_TYPE words[4];
1537 return "bad call to md_atof";
1540 t = atof_ieee (input_line_pointer, type, words);
1542 input_line_pointer = t;
1546 for (i = 0; i < prec; i++)
1548 md_number_to_chars (litp, (valueT) words[i], 2);
1555 /* Align a section (I don't know why this is machine dependent). */
1558 md_section_align (seg, addr)
1562 int align = bfd_get_section_alignment (stdoutput, seg);
1564 return ((addr + (1 << align) - 1) & (-1 << align));
1567 /* We don't have any form of relaxing. */
1570 md_estimate_size_before_relax (fragp, seg)
1571 fragS *fragp ATTRIBUTE_UNUSED;
1572 asection *seg ATTRIBUTE_UNUSED;
1578 /* Convert a machine dependent frag. We never generate these. */
1581 md_convert_frag (abfd, sec, fragp)
1582 bfd *abfd ATTRIBUTE_UNUSED;
1583 asection *sec ATTRIBUTE_UNUSED;
1584 fragS *fragp ATTRIBUTE_UNUSED;
1590 md_undefined_symbol (name)
1593 if (*name == '_' && *(name+1) == 'G'
1594 && strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
1598 if (symbol_find (name))
1599 as_bad (_("GOT already in symbol table"));
1600 GOT_symbol = symbol_new (name, undefined_section,
1601 (valueT) 0, &zero_address_frag);
1608 /* Functions concerning relocs. */
1610 /* The location from which a PC relative jump should be calculated,
1611 given a PC relative reloc. */
1614 md_pcrel_from_section (fixp, sec)
1616 segT sec ATTRIBUTE_UNUSED;
1618 return fixp->fx_frag->fr_address + fixp->fx_where;
1621 /* Here we decide which fixups can be adjusted to make them relative to
1622 the beginning of the section instead of the symbol. Basically we need
1623 to make sure that the dynamic relocations are done correctly, so in
1624 some cases we force the original symbol to be used. */
1626 tc_s390_fix_adjustable(fixP)
1629 /* Prevent all adjustments to global symbols. */
1630 if (S_IS_EXTERN (fixP->fx_addsy))
1632 if (S_IS_WEAK (fixP->fx_addsy))
1634 /* Don't adjust pc-relative references to merge sections. */
1635 if ((S_GET_SEGMENT(fixP->fx_addsy)->flags & SEC_MERGE) != 0
1638 /* adjust_reloc_syms doesn't know about the GOT. */
1639 if ( fixP->fx_r_type == BFD_RELOC_32_GOTOFF
1640 || fixP->fx_r_type == BFD_RELOC_390_PLT16DBL
1641 || fixP->fx_r_type == BFD_RELOC_390_PLT32
1642 || fixP->fx_r_type == BFD_RELOC_390_PLT32DBL
1643 || fixP->fx_r_type == BFD_RELOC_390_PLT64
1644 || fixP->fx_r_type == BFD_RELOC_390_GOT12
1645 || fixP->fx_r_type == BFD_RELOC_390_GOT16
1646 || fixP->fx_r_type == BFD_RELOC_32_GOT_PCREL
1647 || fixP->fx_r_type == BFD_RELOC_390_GOT64
1648 || fixP->fx_r_type == BFD_RELOC_390_GOTENT
1649 || fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
1650 || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
1655 /* Return true if we must always emit a reloc for a type and false if
1656 there is some hope of resolving it a assembly time. */
1658 tc_s390_force_relocation (fixp)
1661 /* Ensure we emit a relocation for every reference to the global
1662 offset table or to the procedure link table. */
1663 switch (fixp->fx_r_type)
1665 case BFD_RELOC_390_GOT12:
1666 case BFD_RELOC_32_GOT_PCREL:
1667 case BFD_RELOC_32_GOTOFF:
1668 case BFD_RELOC_390_GOTPC:
1669 case BFD_RELOC_390_GOT16:
1670 case BFD_RELOC_390_GOTPCDBL:
1671 case BFD_RELOC_390_GOT64:
1672 case BFD_RELOC_390_GOTENT:
1673 case BFD_RELOC_390_PLT32:
1674 case BFD_RELOC_390_PLT16DBL:
1675 case BFD_RELOC_390_PLT32DBL:
1676 case BFD_RELOC_390_PLT64:
1677 case BFD_RELOC_VTABLE_INHERIT:
1678 case BFD_RELOC_VTABLE_ENTRY:
1685 /* Apply a fixup to the object code. This is called for all the
1686 fixups we generated by the call to fix_new_exp, above. In the call
1687 above we used a reloc code which was the largest legal reloc code
1688 plus the operand index. Here we undo that to recover the operand
1689 index. At this point all symbol values should be fully resolved,
1690 and we attempt to completely resolve the reloc. If we can not do
1691 that, we determine the correct reloc code and put it back in the
1695 md_apply_fix3 (fixP, valP, seg)
1701 valueT value = * valP;
1703 where = fixP->fx_frag->fr_literal + fixP->fx_where;
1705 if (fixP->fx_subsy != NULL)
1707 if ((fixP->fx_addsy != NULL
1708 && S_GET_SEGMENT (fixP->fx_addsy) == S_GET_SEGMENT (fixP->fx_subsy)
1709 && SEG_NORMAL (S_GET_SEGMENT (fixP->fx_addsy)))
1710 || (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section))
1711 value += S_GET_VALUE (fixP->fx_subsy);
1712 if (!S_IS_DEFINED (fixP->fx_subsy))
1713 as_bad_where (fixP->fx_file, fixP->fx_line,
1714 _("unresolved fx_subsy symbol that must be resolved"));
1715 value -= S_GET_VALUE(fixP->fx_subsy);
1717 if (S_GET_SEGMENT (fixP->fx_subsy) == seg && ! fixP->fx_pcrel)
1718 value += MD_PCREL_FROM_SECTION (fixP, seg);
1721 if (fixP->fx_addsy != NULL)
1723 if ((fixP->fx_subsy != NULL
1724 && S_GET_SEGMENT (fixP->fx_addsy) == S_GET_SEGMENT (fixP->fx_subsy)
1725 && SEG_NORMAL (S_GET_SEGMENT(fixP->fx_addsy)))
1726 || (S_GET_SEGMENT (fixP->fx_addsy) == seg
1727 && fixP->fx_pcrel && TC_RELOC_RTSYM_LOC_FIXUP (fixP))
1729 && S_GET_SEGMENT (fixP->fx_addsy) == absolute_section)
1730 || (S_GET_SEGMENT (fixP->fx_addsy) != undefined_section
1731 && !bfd_is_com_section (S_GET_SEGMENT (fixP->fx_addsy))
1732 && TC_FIX_ADJUSTABLE(fixP)))
1733 value -= S_GET_VALUE (fixP->fx_addsy);
1736 value += fixP->fx_frag->fr_address + fixP->fx_where;
1741 if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
1743 const struct s390_operand *operand;
1746 opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED;
1747 operand = &s390_operands[opindex];
1751 /* Insert the fully resolved operand value. */
1752 s390_insert_operand (where, operand, (offsetT) value,
1753 fixP->fx_file, fixP->fx_line);
1757 /* Determine a BFD reloc value based on the operand information.
1758 We are only prepared to turn a few of the operands into
1760 fixP->fx_offset = value;
1761 if (operand->bits == 12 && operand->shift == 20)
1764 fixP->fx_where += 2;
1765 fixP->fx_r_type = BFD_RELOC_390_12;
1767 else if (operand->bits == 12 && operand->shift == 36)
1770 fixP->fx_where += 4;
1771 fixP->fx_r_type = BFD_RELOC_390_12;
1773 else if (operand->bits == 8 && operand->shift == 8)
1776 fixP->fx_where += 1;
1777 fixP->fx_r_type = BFD_RELOC_8;
1779 else if (operand->bits == 16 && operand->shift == 16)
1782 fixP->fx_where += 2;
1783 if (operand->flags & S390_OPERAND_PCREL)
1785 fixP->fx_r_type = BFD_RELOC_390_PC16DBL;
1786 fixP->fx_offset += 2;
1789 fixP->fx_r_type = BFD_RELOC_16;
1791 else if (operand->bits == 32 && operand->shift == 16
1792 && (operand->flags & S390_OPERAND_PCREL))
1795 fixP->fx_where += 2;
1796 fixP->fx_offset += 2;
1797 fixP->fx_r_type = BFD_RELOC_390_PC32DBL;
1804 /* Use expr_symbol_where to see if this is an expression
1806 if (expr_symbol_where (fixP->fx_addsy, &sfile, &sline))
1807 as_bad_where (fixP->fx_file, fixP->fx_line,
1808 _("unresolved expression that must be resolved"));
1810 as_bad_where (fixP->fx_file, fixP->fx_line,
1811 _("unsupported relocation type"));
1818 switch (fixP->fx_r_type)
1824 md_number_to_chars (where, value, 1);
1826 case BFD_RELOC_390_12:
1827 case BFD_RELOC_390_GOT12:
1832 mop = bfd_getb16 ((unsigned char *) where);
1833 mop |= (unsigned short) (value & 0xfff);
1834 bfd_putb16 ((bfd_vma) mop, (unsigned char *) where);
1839 case BFD_RELOC_GPREL16:
1840 case BFD_RELOC_16_GOT_PCREL:
1841 case BFD_RELOC_16_GOTOFF:
1843 as_bad_where (fixP->fx_file, fixP->fx_line,
1844 "cannot emit PC relative %s relocation%s%s",
1845 bfd_get_reloc_code_name (fixP->fx_r_type),
1846 fixP->fx_addsy != NULL ? " against " : "",
1847 (fixP->fx_addsy != NULL
1848 ? S_GET_NAME (fixP->fx_addsy)
1851 md_number_to_chars (where, value, 2);
1853 case BFD_RELOC_390_GOT16:
1855 md_number_to_chars (where, value, 2);
1857 case BFD_RELOC_390_PC16DBL:
1858 case BFD_RELOC_390_PLT16DBL:
1861 md_number_to_chars (where, (offsetT) value >> 1, 2);
1866 fixP->fx_r_type = BFD_RELOC_32_PCREL;
1868 fixP->fx_r_type = BFD_RELOC_32;
1870 md_number_to_chars (where, value, 4);
1872 case BFD_RELOC_32_PCREL:
1873 case BFD_RELOC_32_BASEREL:
1874 fixP->fx_r_type = BFD_RELOC_32_PCREL;
1876 md_number_to_chars (where, value, 4);
1878 case BFD_RELOC_32_GOT_PCREL:
1879 case BFD_RELOC_390_PLT32:
1881 md_number_to_chars (where, value, 4);
1883 case BFD_RELOC_390_PC32DBL:
1884 case BFD_RELOC_390_PLT32DBL:
1885 case BFD_RELOC_390_GOTPCDBL:
1886 case BFD_RELOC_390_GOTENT:
1889 md_number_to_chars (where, (offsetT) value >> 1, 4);
1892 case BFD_RELOC_32_GOTOFF:
1894 md_number_to_chars (where, value, sizeof (int));
1897 case BFD_RELOC_390_GOT64:
1898 case BFD_RELOC_390_PLT64:
1900 md_number_to_chars (where, value, 8);
1905 fixP->fx_r_type = BFD_RELOC_64_PCREL;
1907 fixP->fx_r_type = BFD_RELOC_64;
1909 md_number_to_chars (where, value, 8);
1912 case BFD_RELOC_64_PCREL:
1913 fixP->fx_r_type = BFD_RELOC_64_PCREL;
1915 md_number_to_chars (where, value, 8);
1918 case BFD_RELOC_VTABLE_INHERIT:
1919 case BFD_RELOC_VTABLE_ENTRY:
1925 const char *reloc_name = bfd_get_reloc_code_name (fixP->fx_r_type);
1927 if (reloc_name != NULL)
1928 fprintf (stderr, "Gas failure, reloc type %s\n", reloc_name);
1930 fprintf (stderr, "Gas failure, reloc type #%i\n", fixP->fx_r_type);
1936 fixP->fx_offset = value;
1940 /* Generate a reloc for a fixup. */
1943 tc_gen_reloc (seg, fixp)
1944 asection *seg ATTRIBUTE_UNUSED;
1947 bfd_reloc_code_real_type code;
1950 code = fixp->fx_r_type;
1951 if (GOT_symbol && fixp->fx_addsy == GOT_symbol)
1953 if ( (s390_arch_size == 32 && code == BFD_RELOC_32_PCREL)
1954 || (s390_arch_size == 64 && code == BFD_RELOC_64_PCREL))
1955 code = BFD_RELOC_390_GOTPC;
1956 if (code == BFD_RELOC_390_PC32DBL)
1957 code = BFD_RELOC_390_GOTPCDBL;
1960 reloc = (arelent *) xmalloc (sizeof (arelent));
1961 reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
1962 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
1963 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
1964 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
1965 if (reloc->howto == NULL)
1967 as_bad_where (fixp->fx_file, fixp->fx_line,
1968 _("cannot represent relocation type %s"),
1969 bfd_get_reloc_code_name (code));
1970 /* Set howto to a garbage value so that we can keep going. */
1971 reloc->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32);
1972 assert (reloc->howto != NULL);
1974 reloc->addend = fixp->fx_offset;