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"
27 #include "dwarf2dbg.h"
29 #include "opcode/s390.h"
32 /* The default architecture. */
34 #define DEFAULT_ARCH "s390"
36 static char *default_arch = DEFAULT_ARCH;
37 /* Either 32 or 64, selects file format. */
38 static int s390_arch_size;
39 /* Current architecture. Start with the smallest instruction set. */
40 static enum s390_opcode_arch_val current_architecture = S390_OPCODE_ESA;
41 static int current_arch_mask = 1 << S390_OPCODE_ESA;
42 static int current_arch_requested = 0;
44 /* Whether to use user friendly register names. Default is true. */
45 #ifndef TARGET_REG_NAMES_P
46 #define TARGET_REG_NAMES_P true
49 static boolean reg_names_p = TARGET_REG_NAMES_P;
51 /* Set to TRUE if we want to warn about zero base/index registers. */
52 static boolean warn_areg_zero = FALSE;
54 /* Generic assembler global variables which must be defined by all
57 const char comment_chars[] = "#";
59 /* Characters which start a comment at the beginning of a line. */
60 const char line_comment_chars[] = "#";
62 /* Characters which may be used to separate multiple commands on a
64 const char line_separator_chars[] = ";";
66 /* Characters which are used to indicate an exponent in a floating
68 const char EXP_CHARS[] = "eE";
70 /* Characters which mean that a number is a floating point constant,
72 const char FLT_CHARS[] = "dD";
74 /* The target specific pseudo-ops which we support. */
76 /* Define the prototypes for the pseudo-ops */
77 static void s390_byte PARAMS ((int));
78 static void s390_elf_cons PARAMS ((int));
79 static void s390_bss PARAMS ((int));
80 static void s390_insn PARAMS ((int));
81 static void s390_literals PARAMS ((int));
83 const pseudo_typeS md_pseudo_table[] =
85 { "align", s_align_bytes, 0 },
86 /* Pseudo-ops which must be defined. */
87 { "bss", s390_bss, 0 },
88 { "insn", s390_insn, 0 },
89 /* Pseudo-ops which must be overridden. */
90 { "byte", s390_byte, 0 },
91 { "short", s390_elf_cons, 2 },
92 { "long", s390_elf_cons, 4 },
93 { "quad", s390_elf_cons, 8 },
94 { "ltorg", s390_literals, 0 },
95 { "string", stringer, 2 },
100 /* Structure to hold information about predefined registers. */
107 /* List of registers that are pre-defined:
109 Each access register has a predefined name of the form:
110 a<reg_num> which has the value <reg_num>.
112 Each control register has a predefined name of the form:
113 c<reg_num> which has the value <reg_num>.
115 Each general register has a predefined name of the form:
116 r<reg_num> which has the value <reg_num>.
118 Each floating point register a has predefined name of the form:
119 f<reg_num> which has the value <reg_num>.
121 There are individual registers as well:
125 The table is sorted. Suitable for searching by a binary search. */
127 static const struct pd_reg pre_defined_registers[] =
129 { "a0", 0 }, /* Access registers */
146 { "c0", 0 }, /* Control registers */
163 { "f0", 0 }, /* Floating point registers */
180 { "lit", 13 }, /* Pointer to literal pool */
182 { "r0", 0 }, /* General purpose registers */
199 { "sp", 15 }, /* Stack pointer */
203 #define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg))
205 static int reg_name_search
206 PARAMS ((const struct pd_reg *, int, const char *));
207 static boolean register_name PARAMS ((expressionS *));
208 static void init_default_arch PARAMS ((void));
209 static void s390_insert_operand
210 PARAMS ((unsigned char *, const struct s390_operand *, offsetT, char *,
212 static char *md_gather_operands
213 PARAMS ((char *, unsigned char *, const struct s390_opcode *));
215 /* Given NAME, find the register number associated with that name, return
216 the integer value associated with the given name or -1 on failure. */
219 reg_name_search (regs, regcount, name)
220 const struct pd_reg *regs;
224 int middle, low, high;
232 middle = (low + high) / 2;
233 cmp = strcasecmp (name, regs[middle].name);
239 return regs[middle].value;
248 * Summary of register_name().
250 * in: Input_line_pointer points to 1st char of operand.
252 * out: A expressionS.
253 * The operand may have been a register: in this case, X_op == O_register,
254 * X_add_number is set to the register number, and truth is returned.
255 * Input_line_pointer->(next non-blank) char after operand, or is in its
260 register_name (expressionP)
261 expressionS *expressionP;
268 /* Find the spelling of the operand. */
269 start = name = input_line_pointer;
270 if (name[0] == '%' && ISALPHA (name[1]))
271 name = ++input_line_pointer;
275 c = get_symbol_end ();
276 reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT, name);
278 /* Put back the delimiting char. */
279 *input_line_pointer = c;
281 /* Look to see if it's in the register table. */
284 expressionP->X_op = O_register;
285 expressionP->X_add_number = reg_number;
287 /* Make the rest nice. */
288 expressionP->X_add_symbol = NULL;
289 expressionP->X_op_symbol = NULL;
293 /* Reset the line as if we had not done anything. */
294 input_line_pointer = start;
298 /* Local variables. */
300 /* Opformat hash table. */
301 static struct hash_control *s390_opformat_hash;
303 /* Opcode hash table. */
304 static struct hash_control *s390_opcode_hash;
306 /* Flags to set in the elf header */
307 static flagword s390_flags = 0;
309 symbolS *GOT_symbol; /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
311 #ifndef WORKING_DOT_WORD
312 const int md_short_jump_size = 4;
313 const int md_long_jump_size = 4;
316 const char *md_shortopts = "A:m:kVQ:";
317 struct option md_longopts[] = {
318 {NULL, no_argument, NULL, 0}
320 size_t md_longopts_size = sizeof (md_longopts);
322 /* Initialize the default opcode arch and word size from the default
323 architecture name. */
327 if (current_arch_requested)
330 if (strcmp (default_arch, "s390") == 0)
333 current_architecture = S390_OPCODE_ESA;
335 else if (strcmp (default_arch, "s390x") == 0)
338 current_architecture = S390_OPCODE_ESAME;
341 as_fatal ("Invalid default architecture, broken assembler.");
342 current_arch_mask = 1 << current_architecture;
345 /* Called by TARGET_FORMAT. */
347 s390_target_format ()
349 /* We don't get a chance to initialize anything before we're called,
350 so handle that now. */
351 if (! s390_arch_size)
352 init_default_arch ();
354 return s390_arch_size == 64 ? "elf64-s390" : "elf32-s390";
358 md_parse_option (c, arg)
364 /* -k: Ignore for FreeBSD compatibility. */
368 if (arg != NULL && strcmp (arg, "regnames") == 0)
371 else if (arg != NULL && strcmp (arg, "no-regnames") == 0)
374 else if (arg != NULL && strcmp (arg, "warn-areg-zero") == 0)
375 warn_areg_zero = TRUE;
377 else if (arg != NULL && strcmp (arg, "31") == 0)
380 else if (arg != NULL && strcmp (arg, "64") == 0)
385 as_bad (_("invalid switch -m%s"), arg);
391 if (arg != NULL && strcmp (arg, "esa") == 0)
392 current_architecture = S390_OPCODE_ESA;
393 else if (arg != NULL && strcmp (arg, "esame") == 0)
394 current_architecture = S390_OPCODE_ESAME;
396 as_bad ("invalid architecture -A%s", arg);
397 current_arch_mask = 1 << current_architecture;
398 current_arch_requested = 1;
401 /* -V: SVR4 argument to print version ID. */
406 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
407 should be emitted or not. FIXME: Not implemented. */
419 md_show_usage (stream)
422 fprintf (stream, _("\
424 -mregnames Allow symbolic names for registers\n\
425 -mwarn-areg-zero Warn about zero base/index registers\n\
426 -mno-regnames Do not allow symbolic names for registers\n\
427 -m31 Set file format to 31 bit format\n\
428 -m64 Set file format to 64 bit format\n"));
429 fprintf (stream, _("\
430 -V print assembler version number\n\
431 -Qy, -Qn ignored\n"));
434 /* This function is called when the assembler starts up. It is called
435 after the options have been parsed and the output file has been
441 register const struct s390_opcode *op;
442 const struct s390_opcode *op_end;
443 boolean dup_insn = false;
446 /* Give a warning if the combination -m64-bit and -Aesa is used. */
447 if (s390_arch_size == 64 && current_arch_mask == (1 << S390_OPCODE_ESA))
448 as_warn ("The 64 bit file format is used without esame instructions.");
450 /* Set the ELF flags if desired. */
452 bfd_set_private_flags (stdoutput, s390_flags);
454 /* Insert the opcode formats into a hash table. */
455 s390_opformat_hash = hash_new ();
457 op_end = s390_opformats + s390_num_opformats;
458 for (op = s390_opformats; op < op_end; op++)
460 retval = hash_insert (s390_opformat_hash, op->name, (PTR) op);
461 if (retval != (const char *) NULL)
463 as_bad (_("Internal assembler error for instruction format %s"),
469 /* Insert the opcodes into a hash table. */
470 s390_opcode_hash = hash_new ();
472 op_end = s390_opcodes + s390_num_opcodes;
473 for (op = s390_opcodes; op < op_end; op++)
475 retval = hash_insert (s390_opcode_hash, op->name, (PTR) op);
476 if (retval != (const char *) NULL)
478 as_bad (_("Internal assembler error for instruction %s"), op->name);
486 record_alignment (text_section, 2);
487 record_alignment (data_section, 2);
488 record_alignment (bss_section, 2);
492 /* Called after all assembly has been done. */
496 if (s390_arch_size == 64)
497 bfd_set_arch_mach (stdoutput, bfd_arch_s390, bfd_mach_s390_64);
499 bfd_set_arch_mach (stdoutput, bfd_arch_s390, bfd_mach_s390_31);
503 s390_align_code (fragP, count)
507 /* We use nop pattern 0x0707. */
510 memset (fragP->fr_literal + fragP->fr_fix, 0x07, count);
511 fragP->fr_var = count;
515 /* Insert an operand value into an instruction. */
518 s390_insert_operand (insn, operand, val, file, line)
520 const struct s390_operand *operand;
528 if (operand->flags & (S390_OPERAND_SIGNED|S390_OPERAND_PCREL))
532 max = ((offsetT) 1 << (operand->bits - 1)) - 1;
533 min = - ((offsetT) 1 << (operand->bits - 1));
534 /* Halve PCREL operands. */
535 if (operand->flags & S390_OPERAND_PCREL)
537 /* Check for underflow / overflow. */
538 if (val < min || val > max)
541 "operand out of range (%s not between %ld and %ld)";
544 if (operand->flags & S390_OPERAND_PCREL)
550 sprint_value (buf, val);
551 if (file == (char *) NULL)
552 as_bad (err, buf, (int) min, (int) max);
554 as_bad_where (file, line, err, buf, (int) min, (int) max);
557 /* val is ok, now restrict it to operand->bits bits. */
558 uval = (addressT) val & ((((addressT) 1 << (operand->bits-1)) << 1) - 1);
564 max = (((addressT) 1 << (operand->bits - 1)) << 1) - 1;
566 uval = (addressT) val;
567 /* Length x in an instructions has real length x+1. */
568 if (operand->flags & S390_OPERAND_LENGTH)
570 /* Check for underflow / overflow. */
571 if (uval < min || uval > max)
574 "operand out of range (%s not between %ld and %ld)";
577 if (operand->flags & S390_OPERAND_LENGTH)
583 sprint_value (buf, uval);
584 if (file == (char *) NULL)
585 as_bad (err, buf, (int) min, (int) max);
587 as_bad_where (file, line, err, buf, (int) min, (int) max);
592 /* Insert fragments of the operand byte for byte. */
593 offset = operand->shift + operand->bits;
594 uval <<= (-offset) & 7;
595 insn += (offset - 1) / 8;
603 /* Structure used to hold suffixes. */
617 elf_suffix_type suffix;
620 static elf_suffix_type s390_elf_suffix PARAMS ((char **, expressionS *));
621 static int s390_exp_compare PARAMS ((expressionS *exp1, expressionS *exp2));
622 static elf_suffix_type s390_lit_suffix
623 PARAMS ((char **, expressionS *, elf_suffix_type));
626 /* Parse @got/@plt/@gotoff. and return the desired relocation. */
627 static elf_suffix_type
628 s390_elf_suffix (str_p, exp_p)
632 static struct map_bfd mapping[] =
634 { "got", 3, ELF_SUFFIX_GOT },
635 { "got12", 5, ELF_SUFFIX_GOT },
636 { "plt", 3, ELF_SUFFIX_PLT },
637 { "gotent", 6, ELF_SUFFIX_GOTENT },
638 { NULL, 0, ELF_SUFFIX_NONE }
647 return ELF_SUFFIX_NONE;
650 while (ISALNUM (*str))
654 for (ptr = &mapping[0]; ptr->length > 0; ptr++)
655 if (len == ptr->length
656 && strncasecmp (ident, ptr->string, ptr->length) == 0)
658 if (exp_p->X_add_number != 0)
659 as_warn (_("identifier+constant@%s means identifier@%s+constant"),
660 ptr->string, ptr->string);
661 /* Now check for identifier@suffix+constant. */
662 if (*str == '-' || *str == '+')
664 char *orig_line = input_line_pointer;
667 input_line_pointer = str;
668 expression (&new_exp);
670 switch (new_exp.X_op)
672 case O_constant: /* X_add_number (a constant expression). */
673 exp_p->X_add_number += new_exp.X_add_number;
674 str = input_line_pointer;
676 case O_symbol: /* X_add_symbol + X_add_number. */
677 /* this case is used for e.g. xyz@PLT+.Label. */
678 exp_p->X_add_number += new_exp.X_add_number;
679 exp_p->X_op_symbol = new_exp.X_add_symbol;
681 str = input_line_pointer;
683 case O_uminus: /* (- X_add_symbol) + X_add_number. */
684 /* this case is used for e.g. xyz@PLT-.Label. */
685 exp_p->X_add_number += new_exp.X_add_number;
686 exp_p->X_op_symbol = new_exp.X_add_symbol;
687 exp_p->X_op = O_subtract;
688 str = input_line_pointer;
694 /* If s390_elf_suffix has not been called with
695 &input_line_pointer as first parameter, we have
696 clobbered the input_line_pointer. We have to
698 if (&input_line_pointer != str_p)
699 input_line_pointer = orig_line;
705 return BFD_RELOC_UNUSED;
708 /* Structure used to hold a literal pool entry. */
711 struct s390_lpe *next;
713 FLONUM_TYPE floatnum; /* used if X_op == O_big && X_add_number <= 0 */
714 LITTLENUM_TYPE bignum[4]; /* used if X_op == O_big && X_add_number > 0 */
716 bfd_reloc_code_real_type reloc;
720 static struct s390_lpe *lpe_free_list = NULL;
721 static struct s390_lpe *lpe_list = NULL;
722 static struct s390_lpe *lpe_list_tail = NULL;
723 static symbolS *lp_sym = NULL;
724 static int lp_count = 0;
725 static int lpe_count = 0;
728 s390_exp_compare (exp1, exp2)
732 if (exp1->X_op != exp2->X_op)
737 case O_constant: /* X_add_number must be equal. */
739 return exp1->X_add_number == exp2->X_add_number;
742 as_bad (_("Can't handle O_big in s390_exp_compare"));
744 case O_symbol: /* X_add_symbol & X_add_number must be equal. */
749 return (exp1->X_add_symbol == exp2->X_add_symbol)
750 && (exp1->X_add_number == exp2->X_add_number);
752 case O_multiply: /* X_add_symbol,X_op_symbol&X_add_number must be equal. */
757 case O_bit_inclusive_or:
759 case O_bit_exclusive_or:
771 return (exp1->X_add_symbol == exp2->X_add_symbol)
772 && (exp1->X_op_symbol == exp2->X_op_symbol)
773 && (exp1->X_add_number == exp2->X_add_number);
779 /* Test for @lit and if its present make an entry in the literal pool and
780 modify the current expression to be an offset into the literal pool. */
781 static elf_suffix_type
782 s390_lit_suffix (str_p, exp_p, suffix)
785 elf_suffix_type suffix;
787 bfd_reloc_code_real_type reloc;
791 struct s390_lpe *lpe;
795 return suffix; /* No modification. */
797 /* We look for a suffix of the form "@lit1", "@lit2", "@lit4" or "@lit8". */
799 while (ISALNUM (*str))
802 if (len != 4 || strncasecmp (ident, "lit", 3) != 0
803 || (ident[3]!='1' && ident[3]!='2' && ident[3]!='4' && ident[3]!='8'))
804 return suffix; /* no modification */
805 nbytes = ident[3] - '0';
807 reloc = BFD_RELOC_UNUSED;
808 if (suffix == ELF_SUFFIX_GOT)
811 reloc = BFD_RELOC_390_GOT16;
812 else if (nbytes == 4)
813 reloc = BFD_RELOC_32_GOT_PCREL;
814 else if (nbytes == 8)
815 reloc = BFD_RELOC_390_GOT64;
817 else if (suffix == ELF_SUFFIX_PLT)
820 reloc = BFD_RELOC_390_PLT32;
821 else if (nbytes == 8)
822 reloc = BFD_RELOC_390_PLT64;
825 if (suffix != ELF_SUFFIX_NONE && reloc == BFD_RELOC_UNUSED)
826 as_bad (_("Invalid suffix for literal pool entry"));
828 /* Search the pool if the new entry is a duplicate. */
829 if (exp_p->X_op == O_big)
831 /* Special processing for big numbers. */
832 for (lpe = lpe_list; lpe != NULL; lpe = lpe->next)
834 if (lpe->ex.X_op == O_big)
836 if (exp_p->X_add_number <= 0 && lpe->ex.X_add_number <= 0)
838 if (memcmp (&generic_floating_point_number, &lpe->floatnum,
839 sizeof (FLONUM_TYPE)) == 0)
842 else if (exp_p->X_add_number == lpe->ex.X_add_number)
844 if (memcmp (generic_bignum, lpe->bignum,
845 sizeof (LITTLENUM_TYPE)*exp_p->X_add_number) == 0)
853 /* Processing for 'normal' data types. */
854 for (lpe = lpe_list; lpe != NULL; lpe = lpe->next)
855 if (lpe->nbytes == nbytes && lpe->reloc == reloc
856 && s390_exp_compare (exp_p, &lpe->ex) != 0)
863 if (lpe_free_list != NULL)
866 lpe_free_list = lpe_free_list->next;
870 lpe = (struct s390_lpe *) xmalloc (sizeof (struct s390_lpe));
875 if (exp_p->X_op == O_big)
877 if (exp_p->X_add_number <= 0)
878 lpe->floatnum = generic_floating_point_number;
879 else if (exp_p->X_add_number <= 4)
880 memcpy (lpe->bignum, generic_bignum,
881 exp_p->X_add_number * sizeof (LITTLENUM_TYPE));
883 as_bad (_("Big number is too big"));
886 lpe->nbytes = nbytes;
888 /* Literal pool name defined ? */
891 sprintf (tmp_name, ".L\001%i", lp_count);
892 lp_sym = symbol_make (tmp_name);
895 /* Make name for literal pool entry. */
896 sprintf (tmp_name, ".L\001%i\002%i", lp_count, lpe_count);
898 lpe->sym = symbol_make (tmp_name);
900 /* Add to literal pool list. */
902 if (lpe_list_tail != NULL)
904 lpe_list_tail->next = lpe;
908 lpe_list = lpe_list_tail = lpe;
911 /* Now change exp_p to the offset into the literal pool.
912 Thats the expression: .L^Ax^By-.L^Ax */
913 exp_p->X_add_symbol = lpe->sym;
914 exp_p->X_op_symbol = lp_sym;
915 exp_p->X_op = O_subtract;
916 exp_p->X_add_number = 0;
920 /* We change the suffix type to ELF_SUFFIX_NONE, because
921 the difference of two local labels is just a number. */
922 return ELF_SUFFIX_NONE;
925 /* Like normal .long/.short/.word, except support @got, etc.
926 clobbers input_line_pointer, checks end-of-line. */
928 s390_elf_cons (nbytes)
929 register int nbytes; /* 1=.byte, 2=.word, 4=.long */
932 elf_suffix_type suffix;
934 if (is_it_end_of_statement ())
936 demand_empty_rest_of_line ();
944 if (exp.X_op == O_symbol
945 && *input_line_pointer == '@'
946 && (suffix = s390_elf_suffix (&input_line_pointer, &exp)) != ELF_SUFFIX_NONE)
948 bfd_reloc_code_real_type reloc;
949 reloc_howto_type *reloc_howto;
953 if (nbytes == 2 && suffix == ELF_SUFFIX_GOT)
954 reloc = BFD_RELOC_390_GOT16;
955 else if (nbytes == 4 && suffix == ELF_SUFFIX_GOT)
956 reloc = BFD_RELOC_32_GOT_PCREL;
957 else if (nbytes == 8 && suffix == ELF_SUFFIX_GOT)
958 reloc = BFD_RELOC_390_GOT64;
959 else if (nbytes == 4 && suffix == ELF_SUFFIX_PLT)
960 reloc = BFD_RELOC_390_PLT32;
961 else if (nbytes == 8 && suffix == ELF_SUFFIX_PLT)
962 reloc = BFD_RELOC_390_PLT64;
964 reloc = BFD_RELOC_UNUSED;
966 if (reloc != BFD_RELOC_UNUSED)
968 reloc_howto = bfd_reloc_type_lookup (stdoutput, reloc);
969 size = bfd_get_reloc_size (reloc_howto);
971 as_bad (_("%s relocations do not fit in %d bytes"),
972 reloc_howto->name, nbytes);
973 where = frag_more (nbytes);
974 md_number_to_chars (where, 0, size);
975 /* To make fixup_segment do the pc relative conversion the
976 pcrel parameter on the fix_new_exp call needs to be false. */
977 fix_new_exp (frag_now, where - frag_now->fr_literal,
978 size, &exp, false, reloc);
981 as_bad (_("relocation not applicable"));
984 emit_expr (&exp, (unsigned int) nbytes);
986 while (*input_line_pointer++ == ',');
988 input_line_pointer--; /* Put terminator back into stream. */
989 demand_empty_rest_of_line ();
992 /* We need to keep a list of fixups. We can't simply generate them as
993 we go, because that would require us to first create the frag, and
994 that would screw up references to ``.''. */
1000 bfd_reloc_code_real_type reloc;
1003 #define MAX_INSN_FIXUPS (4)
1005 /* This routine is called for each instruction to be assembled. */
1008 md_gather_operands (str, insn, opcode)
1010 unsigned char *insn;
1011 const struct s390_opcode *opcode;
1013 struct s390_fixup fixups[MAX_INSN_FIXUPS];
1014 const struct s390_operand *operand;
1015 const unsigned char *opindex_ptr;
1016 elf_suffix_type suffix;
1017 bfd_reloc_code_real_type reloc;
1023 while (ISSPACE (*str))
1029 /* Gather the operands. */
1031 for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++)
1036 operand = s390_operands + *opindex_ptr;
1038 if (skip_optional && (operand->flags & S390_OPERAND_INDEX))
1040 /* We do an early skip. For D(X,B) constructions the index
1041 register is skipped (X is optional). For D(L,B) the base
1042 register will be the skipped operand, because L is NOT
1048 /* Gather the operand. */
1049 hold = input_line_pointer;
1050 input_line_pointer = str;
1052 /* Parse the operand. */
1053 if (! register_name (&ex))
1056 str = input_line_pointer;
1057 input_line_pointer = hold;
1059 /* Write the operand to the insn. */
1060 if (ex.X_op == O_illegal)
1061 as_bad (_("illegal operand"));
1062 else if (ex.X_op == O_absent)
1063 as_bad (_("missing operand"));
1064 else if (ex.X_op == O_register || ex.X_op == O_constant)
1066 s390_lit_suffix (&str, &ex, ELF_SUFFIX_NONE);
1068 if (ex.X_op != O_register && ex.X_op != O_constant)
1070 /* We need to generate a fixup for the
1071 expression returned by s390_lit_suffix. */
1072 if (fc >= MAX_INSN_FIXUPS)
1073 as_fatal (_("too many fixups"));
1074 fixups[fc].exp = ex;
1075 fixups[fc].opindex = *opindex_ptr;
1076 fixups[fc].reloc = BFD_RELOC_UNUSED;
1081 if ((operand->flags & S390_OPERAND_INDEX)
1082 && ex.X_add_number == 0
1083 && warn_areg_zero == TRUE)
1084 as_warn ("index register specified but zero");
1085 if ((operand->flags & S390_OPERAND_BASE)
1086 && ex.X_add_number == 0
1087 && warn_areg_zero == TRUE)
1088 as_warn ("base register specified but zero");
1089 s390_insert_operand (insn, operand, ex.X_add_number, NULL, 0);
1094 suffix = s390_elf_suffix (&str, &ex);
1095 suffix = s390_lit_suffix (&str, &ex, suffix);
1096 reloc = BFD_RELOC_UNUSED;
1098 if (suffix == ELF_SUFFIX_GOT)
1100 if (operand->flags & S390_OPERAND_DISP)
1101 reloc = BFD_RELOC_390_GOT12;
1102 else if ((operand->flags & S390_OPERAND_SIGNED)
1103 && (operand->bits == 16))
1104 reloc = BFD_RELOC_390_GOT16;
1105 else if ((operand->flags & S390_OPERAND_PCREL)
1106 && (operand->bits == 32))
1107 reloc = BFD_RELOC_390_GOTENT;
1109 else if (suffix == ELF_SUFFIX_PLT)
1111 if ((operand->flags & S390_OPERAND_PCREL)
1112 && (operand->bits == 16))
1113 reloc = BFD_RELOC_390_PLT16DBL;
1114 else if ((operand->flags & S390_OPERAND_PCREL)
1115 && (operand->bits == 32))
1116 reloc = BFD_RELOC_390_PLT32DBL;
1118 else if (suffix == ELF_SUFFIX_GOTENT)
1120 if ((operand->flags & S390_OPERAND_PCREL)
1121 && (operand->bits == 32))
1122 reloc = BFD_RELOC_390_GOTENT;
1125 if (suffix != ELF_SUFFIX_NONE && reloc == BFD_RELOC_UNUSED)
1126 as_bad (_("invalid operand suffix"));
1127 /* We need to generate a fixup of type 'reloc' for this
1129 if (fc >= MAX_INSN_FIXUPS)
1130 as_fatal (_("too many fixups"));
1131 fixups[fc].exp = ex;
1132 fixups[fc].opindex = *opindex_ptr;
1133 fixups[fc].reloc = reloc;
1137 /* Check the next character. The call to expression has advanced
1138 str past any whitespace. */
1139 if (operand->flags & S390_OPERAND_DISP)
1141 /* After a displacement a block in parentheses can start. */
1144 /* Check if parethesed block can be skipped. If the next
1145 operand is neiter an optional operand nor a base register
1146 then we have a syntax error. */
1147 operand = s390_operands + *(++opindex_ptr);
1148 if (!(operand->flags & (S390_OPERAND_INDEX|S390_OPERAND_BASE)))
1149 as_bad (_("syntax error; missing '(' after displacement"));
1151 /* Ok, skip all operands until S390_OPERAND_BASE. */
1152 while (!(operand->flags & S390_OPERAND_BASE))
1153 operand = s390_operands + *(++opindex_ptr);
1155 /* If there is a next operand it must be seperated by a comma. */
1156 if (opindex_ptr[1] != '\0')
1159 as_bad (_("syntax error; expected ,"));
1164 /* We found an opening parentheses. */
1166 for (f = str; *f != '\0'; f++)
1167 if (*f == ',' || *f == ')')
1169 /* If there is no comma until the closing parentheses OR
1170 there is a comma right after the opening parentheses,
1171 we have to skip optional operands. */
1172 if (*f == ',' && f == str)
1174 /* comma directly after '(' ? */
1179 skip_optional = (*f != ',');
1182 else if (operand->flags & S390_OPERAND_BASE)
1184 /* After the base register the parenthesed block ends. */
1186 as_bad (_("syntax error; missing ')' after base register"));
1188 /* If there is a next operand it must be seperated by a comma. */
1189 if (opindex_ptr[1] != '\0')
1192 as_bad (_("syntax error; expected ,"));
1197 /* We can find an 'early' closing parentheses in e.g. D(L) instead
1198 of D(L,B). In this case the base register has to be skipped. */
1201 operand = s390_operands + *(++opindex_ptr);
1203 if (!(operand->flags & S390_OPERAND_BASE))
1204 as_bad (_("syntax error; ')' not allowed here"));
1207 /* If there is a next operand it must be seperated by a comma. */
1208 if (opindex_ptr[1] != '\0')
1211 as_bad (_("syntax error; expected ,"));
1216 while (ISSPACE (*str))
1223 if ((linefeed = strchr (str, '\n')) != NULL)
1225 as_bad (_("junk at end of line: `%s'"), str);
1226 if (linefeed != NULL)
1230 /* Write out the instruction. */
1231 f = frag_more (opcode->oplen);
1232 memcpy (f, insn, opcode->oplen);
1233 dwarf2_emit_insn (opcode->oplen);
1235 /* Create any fixups. At this point we do not use a
1236 bfd_reloc_code_real_type, but instead just use the
1237 BFD_RELOC_UNUSED plus the operand index. This lets us easily
1238 handle fixups for any operand type, although that is admittedly
1239 not a very exciting feature. We pick a BFD reloc type in
1241 for (i = 0; i < fc; i++)
1243 operand = s390_operands + fixups[i].opindex;
1245 if (fixups[i].reloc != BFD_RELOC_UNUSED)
1247 reloc_howto_type *reloc_howto;
1251 reloc_howto = bfd_reloc_type_lookup (stdoutput, fixups[i].reloc);
1255 size = bfd_get_reloc_size (reloc_howto);
1257 if (size < 1 || size > 4)
1260 fixP = fix_new_exp (frag_now,
1261 f - frag_now->fr_literal + (operand->shift/8),
1262 size, &fixups[i].exp, reloc_howto->pc_relative,
1264 /* Turn off overflow checking in fixup_segment. This is necessary
1265 because fixup_segment will signal an overflow for large 4 byte
1266 quantities for GOT12 relocations. */
1267 if ( fixups[i].reloc == BFD_RELOC_390_GOT12
1268 || fixups[i].reloc == BFD_RELOC_390_GOT16)
1269 fixP->fx_no_overflow = 1;
1272 fix_new_exp (frag_now, f - frag_now->fr_literal, 4, &fixups[i].exp,
1273 (operand->flags & S390_OPERAND_PCREL) != 0,
1274 ((bfd_reloc_code_real_type)
1275 (fixups[i].opindex + (int) BFD_RELOC_UNUSED)));
1280 /* This routine is called for each instruction to be assembled. */
1286 const struct s390_opcode *opcode;
1287 unsigned char insn[6];
1290 /* Get the opcode. */
1291 for (s = str; *s != '\0' && ! ISSPACE (*s); s++)
1296 /* Look up the opcode in the hash table. */
1297 opcode = (struct s390_opcode *) hash_find (s390_opcode_hash, str);
1298 if (opcode == (const struct s390_opcode *) NULL)
1300 as_bad (_("Unrecognized opcode: `%s'"), str);
1303 else if (!(opcode->architecture & current_arch_mask))
1305 as_bad ("Opcode %s not available in this architecture", str);
1309 memcpy (insn, opcode->opcode, sizeof (insn));
1310 md_gather_operands (s, insn, opcode);
1313 #ifndef WORKING_DOT_WORD
1314 /* Handle long and short jumps. We don't support these */
1316 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
1318 addressT from_addr, to_addr;
1326 md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
1328 addressT from_addr, to_addr;
1338 int ignore ATTRIBUTE_UNUSED;
1340 /* We don't support putting frags in the BSS segment, we fake it
1341 by marking in_bss, then looking at s_skip for clues. */
1343 subseg_set (bss_section, 0);
1344 demand_empty_rest_of_line ();
1347 /* Pseudo-op handling. */
1351 int ignore ATTRIBUTE_UNUSED;
1354 const struct s390_opcode *opformat;
1355 unsigned char insn[6];
1358 /* Get the opcode format. */
1359 s = input_line_pointer;
1360 while (*s != '\0' && *s != ',' && ! ISSPACE (*s))
1363 as_bad (_("Invalid .insn format\n"));
1366 /* Look up the opcode in the hash table. */
1367 opformat = (struct s390_opcode *)
1368 hash_find (s390_opformat_hash, input_line_pointer);
1369 if (opformat == (const struct s390_opcode *) NULL)
1371 as_bad (_("Unrecognized opcode format: `%s'"), input_line_pointer);
1374 input_line_pointer = s;
1376 if (exp.X_op == O_constant)
1378 if ( (opformat->oplen == 6 && exp.X_op > 0 && exp.X_op < (1ULL << 48))
1379 || (opformat->oplen == 4 && exp.X_op > 0 && exp.X_op < (1ULL << 32))
1380 || (opformat->oplen == 2 && exp.X_op > 0 && exp.X_op < (1ULL << 16)))
1381 md_number_to_chars (insn, exp.X_add_number, opformat->oplen);
1383 as_bad (_("Invalid .insn format\n"));
1385 else if (exp.X_op == O_big)
1387 if (exp.X_add_number > 0
1388 && opformat->oplen == 6
1389 && generic_bignum[3] == 0)
1391 md_number_to_chars (insn, generic_bignum[2], 2);
1392 md_number_to_chars (&insn[2], generic_bignum[1], 2);
1393 md_number_to_chars (&insn[4], generic_bignum[0], 2);
1396 as_bad (_("Invalid .insn format\n"));
1399 as_bad (_("second operand of .insn not a constant\n"));
1401 if (strcmp (opformat->name, "e") != 0 && *input_line_pointer++ != ',')
1402 as_bad (_("missing comma after insn constant\n"));
1404 if ((s = strchr (input_line_pointer, '\n')) != NULL)
1406 input_line_pointer = md_gather_operands (input_line_pointer, insn,
1410 demand_empty_rest_of_line ();
1413 /* The .byte pseudo-op. This is similar to the normal .byte
1414 pseudo-op, but it can also take a single ASCII string. */
1418 int ignore ATTRIBUTE_UNUSED;
1420 if (*input_line_pointer != '\"')
1426 /* Gather characters. A real double quote is doubled. Unusual
1427 characters are not permitted. */
1428 ++input_line_pointer;
1433 c = *input_line_pointer++;
1437 if (*input_line_pointer != '\"')
1439 ++input_line_pointer;
1442 FRAG_APPEND_1_CHAR (c);
1445 demand_empty_rest_of_line ();
1448 /* The .ltorg pseudo-op.This emits all literals defined since the last
1449 .ltorg or the invocation of gas. Literals are defined with the
1453 s390_literals (ignore)
1454 int ignore ATTRIBUTE_UNUSED;
1456 struct s390_lpe *lpe;
1458 if (lp_sym == NULL || lpe_count == 0)
1459 return; /* Nothing to be done. */
1461 /* Emit symbol for start of literal pool. */
1462 S_SET_SEGMENT (lp_sym, now_seg);
1463 S_SET_VALUE (lp_sym, (valueT) frag_now_fix ());
1464 lp_sym->sy_frag = frag_now;
1469 lpe_list = lpe_list->next;
1470 S_SET_SEGMENT (lpe->sym, now_seg);
1471 S_SET_VALUE (lpe->sym, (valueT) frag_now_fix ());
1472 lpe->sym->sy_frag = frag_now;
1474 /* Emit literal pool entry. */
1475 if (lpe->reloc != BFD_RELOC_UNUSED)
1477 reloc_howto_type *reloc_howto =
1478 bfd_reloc_type_lookup (stdoutput, lpe->reloc);
1479 int size = bfd_get_reloc_size (reloc_howto);
1482 if (size > lpe->nbytes)
1483 as_bad (_("%s relocations do not fit in %d bytes"),
1484 reloc_howto->name, lpe->nbytes);
1485 where = frag_more (lpe->nbytes);
1486 md_number_to_chars (where, 0, size);
1487 fix_new_exp (frag_now, where - frag_now->fr_literal,
1488 size, &lpe->ex, reloc_howto->pc_relative, lpe->reloc);
1492 if (lpe->ex.X_op == O_big)
1494 if (lpe->ex.X_add_number <= 0)
1495 generic_floating_point_number = lpe->floatnum;
1497 memcpy (generic_bignum, lpe->bignum,
1498 lpe->ex.X_add_number * sizeof (LITTLENUM_TYPE));
1500 emit_expr (&lpe->ex, lpe->nbytes);
1503 lpe->next = lpe_free_list;
1504 lpe_free_list = lpe;
1506 lpe_list_tail = NULL;
1512 /* Turn a string in input_line_pointer into a floating point constant
1513 of type type, and store the appropriate bytes in *litp. The number
1514 of LITTLENUMS emitted is stored in *sizep . An error message is
1515 returned, or NULL on OK. */
1518 md_atof (type, litp, sizep)
1524 LITTLENUM_TYPE words[4];
1540 return "bad call to md_atof";
1543 t = atof_ieee (input_line_pointer, type, words);
1545 input_line_pointer = t;
1549 for (i = 0; i < prec; i++)
1551 md_number_to_chars (litp, (valueT) words[i], 2);
1558 /* Align a section (I don't know why this is machine dependent). */
1561 md_section_align (seg, addr)
1565 int align = bfd_get_section_alignment (stdoutput, seg);
1567 return ((addr + (1 << align) - 1) & (-1 << align));
1570 /* We don't have any form of relaxing. */
1573 md_estimate_size_before_relax (fragp, seg)
1574 fragS *fragp ATTRIBUTE_UNUSED;
1575 asection *seg ATTRIBUTE_UNUSED;
1581 /* Convert a machine dependent frag. We never generate these. */
1584 md_convert_frag (abfd, sec, fragp)
1585 bfd *abfd ATTRIBUTE_UNUSED;
1586 asection *sec ATTRIBUTE_UNUSED;
1587 fragS *fragp ATTRIBUTE_UNUSED;
1593 md_undefined_symbol (name)
1596 if (*name == '_' && *(name + 1) == 'G'
1597 && strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
1601 if (symbol_find (name))
1602 as_bad (_("GOT already in symbol table"));
1603 GOT_symbol = symbol_new (name, undefined_section,
1604 (valueT) 0, &zero_address_frag);
1611 /* Functions concerning relocs. */
1613 /* The location from which a PC relative jump should be calculated,
1614 given a PC relative reloc. */
1617 md_pcrel_from_section (fixp, sec)
1619 segT sec ATTRIBUTE_UNUSED;
1621 return fixp->fx_frag->fr_address + fixp->fx_where;
1624 /* Here we decide which fixups can be adjusted to make them relative to
1625 the beginning of the section instead of the symbol. Basically we need
1626 to make sure that the dynamic relocations are done correctly, so in
1627 some cases we force the original symbol to be used. */
1629 tc_s390_fix_adjustable (fixP)
1632 /* adjust_reloc_syms doesn't know about the GOT. */
1633 if ( fixP->fx_r_type == BFD_RELOC_32_GOTOFF
1634 || fixP->fx_r_type == BFD_RELOC_390_PLT16DBL
1635 || fixP->fx_r_type == BFD_RELOC_390_PLT32
1636 || fixP->fx_r_type == BFD_RELOC_390_PLT32DBL
1637 || fixP->fx_r_type == BFD_RELOC_390_PLT64
1638 || fixP->fx_r_type == BFD_RELOC_390_GOT12
1639 || fixP->fx_r_type == BFD_RELOC_390_GOT16
1640 || fixP->fx_r_type == BFD_RELOC_32_GOT_PCREL
1641 || fixP->fx_r_type == BFD_RELOC_390_GOT64
1642 || fixP->fx_r_type == BFD_RELOC_390_GOTENT
1643 || fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
1644 || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
1649 /* Return true if we must always emit a reloc for a type and false if
1650 there is some hope of resolving it a assembly time. */
1652 tc_s390_force_relocation (fixp)
1655 /* Ensure we emit a relocation for every reference to the global
1656 offset table or to the procedure link table. */
1657 switch (fixp->fx_r_type)
1659 case BFD_RELOC_390_GOT12:
1660 case BFD_RELOC_32_GOT_PCREL:
1661 case BFD_RELOC_32_GOTOFF:
1662 case BFD_RELOC_390_GOTPC:
1663 case BFD_RELOC_390_GOT16:
1664 case BFD_RELOC_390_GOTPCDBL:
1665 case BFD_RELOC_390_GOT64:
1666 case BFD_RELOC_390_GOTENT:
1667 case BFD_RELOC_390_PLT32:
1668 case BFD_RELOC_390_PLT16DBL:
1669 case BFD_RELOC_390_PLT32DBL:
1670 case BFD_RELOC_390_PLT64:
1671 case BFD_RELOC_VTABLE_INHERIT:
1672 case BFD_RELOC_VTABLE_ENTRY:
1678 return S_FORCE_RELOC (fixp->fx_addsy);
1681 /* Apply a fixup to the object code. This is called for all the
1682 fixups we generated by the call to fix_new_exp, above. In the call
1683 above we used a reloc code which was the largest legal reloc code
1684 plus the operand index. Here we undo that to recover the operand
1685 index. At this point all symbol values should be fully resolved,
1686 and we attempt to completely resolve the reloc. If we can not do
1687 that, we determine the correct reloc code and put it back in the
1691 md_apply_fix3 (fixP, valP, seg)
1694 segT seg ATTRIBUTE_UNUSED;
1697 valueT value = *valP;
1699 where = fixP->fx_frag->fr_literal + fixP->fx_where;
1701 if (fixP->fx_subsy != NULL)
1704 if (fixP->fx_addsy != NULL)
1707 value += fixP->fx_frag->fr_address + fixP->fx_where;
1712 if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
1714 const struct s390_operand *operand;
1717 opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED;
1718 operand = &s390_operands[opindex];
1722 /* Insert the fully resolved operand value. */
1723 s390_insert_operand (where, operand, (offsetT) value,
1724 fixP->fx_file, fixP->fx_line);
1728 /* Determine a BFD reloc value based on the operand information.
1729 We are only prepared to turn a few of the operands into
1731 fixP->fx_offset = value;
1732 if (operand->bits == 12 && operand->shift == 20)
1735 fixP->fx_where += 2;
1736 fixP->fx_r_type = BFD_RELOC_390_12;
1738 else if (operand->bits == 12 && operand->shift == 36)
1741 fixP->fx_where += 4;
1742 fixP->fx_r_type = BFD_RELOC_390_12;
1744 else if (operand->bits == 8 && operand->shift == 8)
1747 fixP->fx_where += 1;
1748 fixP->fx_r_type = BFD_RELOC_8;
1750 else if (operand->bits == 16 && operand->shift == 16)
1753 fixP->fx_where += 2;
1754 if (operand->flags & S390_OPERAND_PCREL)
1756 fixP->fx_r_type = BFD_RELOC_390_PC16DBL;
1757 fixP->fx_offset += 2;
1760 fixP->fx_r_type = BFD_RELOC_16;
1762 else if (operand->bits == 32 && operand->shift == 16
1763 && (operand->flags & S390_OPERAND_PCREL))
1766 fixP->fx_where += 2;
1767 fixP->fx_offset += 2;
1768 fixP->fx_r_type = BFD_RELOC_390_PC32DBL;
1775 /* Use expr_symbol_where to see if this is an expression
1777 if (expr_symbol_where (fixP->fx_addsy, &sfile, &sline))
1778 as_bad_where (fixP->fx_file, fixP->fx_line,
1779 _("unresolved expression that must be resolved"));
1781 as_bad_where (fixP->fx_file, fixP->fx_line,
1782 _("unsupported relocation type"));
1789 switch (fixP->fx_r_type)
1795 md_number_to_chars (where, value, 1);
1797 case BFD_RELOC_390_12:
1798 case BFD_RELOC_390_GOT12:
1803 mop = bfd_getb16 ((unsigned char *) where);
1804 mop |= (unsigned short) (value & 0xfff);
1805 bfd_putb16 ((bfd_vma) mop, (unsigned char *) where);
1810 case BFD_RELOC_GPREL16:
1811 case BFD_RELOC_16_GOT_PCREL:
1812 case BFD_RELOC_16_GOTOFF:
1814 as_bad_where (fixP->fx_file, fixP->fx_line,
1815 "cannot emit PC relative %s relocation%s%s",
1816 bfd_get_reloc_code_name (fixP->fx_r_type),
1817 fixP->fx_addsy != NULL ? " against " : "",
1818 (fixP->fx_addsy != NULL
1819 ? S_GET_NAME (fixP->fx_addsy)
1822 md_number_to_chars (where, value, 2);
1824 case BFD_RELOC_390_GOT16:
1826 md_number_to_chars (where, value, 2);
1828 case BFD_RELOC_390_PC16DBL:
1829 case BFD_RELOC_390_PLT16DBL:
1832 md_number_to_chars (where, (offsetT) value >> 1, 2);
1837 fixP->fx_r_type = BFD_RELOC_32_PCREL;
1839 fixP->fx_r_type = BFD_RELOC_32;
1841 md_number_to_chars (where, value, 4);
1843 case BFD_RELOC_32_PCREL:
1844 case BFD_RELOC_32_BASEREL:
1845 fixP->fx_r_type = BFD_RELOC_32_PCREL;
1847 md_number_to_chars (where, value, 4);
1849 case BFD_RELOC_32_GOT_PCREL:
1850 case BFD_RELOC_390_PLT32:
1852 md_number_to_chars (where, value, 4);
1854 case BFD_RELOC_390_PC32DBL:
1855 case BFD_RELOC_390_PLT32DBL:
1856 case BFD_RELOC_390_GOTPCDBL:
1857 case BFD_RELOC_390_GOTENT:
1860 md_number_to_chars (where, (offsetT) value >> 1, 4);
1863 case BFD_RELOC_32_GOTOFF:
1865 md_number_to_chars (where, value, sizeof (int));
1868 case BFD_RELOC_390_GOT64:
1869 case BFD_RELOC_390_PLT64:
1871 md_number_to_chars (where, value, 8);
1876 fixP->fx_r_type = BFD_RELOC_64_PCREL;
1878 fixP->fx_r_type = BFD_RELOC_64;
1880 md_number_to_chars (where, value, 8);
1883 case BFD_RELOC_64_PCREL:
1884 fixP->fx_r_type = BFD_RELOC_64_PCREL;
1886 md_number_to_chars (where, value, 8);
1889 case BFD_RELOC_VTABLE_INHERIT:
1890 case BFD_RELOC_VTABLE_ENTRY:
1896 const char *reloc_name = bfd_get_reloc_code_name (fixP->fx_r_type);
1898 if (reloc_name != NULL)
1899 fprintf (stderr, "Gas failure, reloc type %s\n", reloc_name);
1901 fprintf (stderr, "Gas failure, reloc type #%i\n", fixP->fx_r_type);
1907 fixP->fx_offset = value;
1911 /* Generate a reloc for a fixup. */
1914 tc_gen_reloc (seg, fixp)
1915 asection *seg ATTRIBUTE_UNUSED;
1918 bfd_reloc_code_real_type code;
1921 code = fixp->fx_r_type;
1922 if (GOT_symbol && fixp->fx_addsy == GOT_symbol)
1924 if ( (s390_arch_size == 32 && code == BFD_RELOC_32_PCREL)
1925 || (s390_arch_size == 64 && code == BFD_RELOC_64_PCREL))
1926 code = BFD_RELOC_390_GOTPC;
1927 if (code == BFD_RELOC_390_PC32DBL)
1928 code = BFD_RELOC_390_GOTPCDBL;
1931 reloc = (arelent *) xmalloc (sizeof (arelent));
1932 reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
1933 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
1934 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
1935 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
1936 if (reloc->howto == NULL)
1938 as_bad_where (fixp->fx_file, fixp->fx_line,
1939 _("cannot represent relocation type %s"),
1940 bfd_get_reloc_code_name (code));
1941 /* Set howto to a garbage value so that we can keep going. */
1942 reloc->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32);
1943 assert (reloc->howto != NULL);
1945 reloc->addend = fixp->fx_offset;