1 /* tc-s390.c -- Assemble for the S390
2 Copyright 2000, 2001 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
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 /* Generic assembler global variables which must be defined by all
53 const char comment_chars
[] = "#";
55 /* Characters which start a comment at the beginning of a line. */
56 const char line_comment_chars
[] = "#";
58 /* Characters which may be used to separate multiple commands on a
60 const char line_separator_chars
[] = ";";
62 /* Characters which are used to indicate an exponent in a floating
64 const char EXP_CHARS
[] = "eE";
66 /* Characters which mean that a number is a floating point constant,
68 const char FLT_CHARS
[] = "dD";
70 /* The target specific pseudo-ops which we support. */
72 /* Define the prototypes for the pseudo-ops */
73 static void s390_byte
PARAMS ((int));
74 static void s390_elf_cons
PARAMS ((int));
75 static void s390_bss
PARAMS ((int));
76 static void s390_insn
PARAMS ((int));
77 static void s390_literals
PARAMS ((int));
79 const pseudo_typeS md_pseudo_table
[] =
81 { "align", s_align_bytes
, 0 },
82 /* Pseudo-ops which must be defined. */
83 { "bss", s390_bss
, 0 },
84 { "insn", s390_insn
, 0 },
85 /* Pseudo-ops which must be overridden. */
86 { "byte", s390_byte
, 0 },
87 { "short", s390_elf_cons
, 2 },
88 { "long", s390_elf_cons
, 4 },
89 { "quad", s390_elf_cons
, 8 },
90 { "ltorg", s390_literals
, 0 },
91 { "string", stringer
, 2 },
96 /* Structure to hold information about predefined registers. */
103 /* List of registers that are pre-defined:
105 Each access register has a predefined name of the form:
106 a<reg_num> which has the value <reg_num>.
108 Each control register has a predefined name of the form:
109 c<reg_num> which has the value <reg_num>.
111 Each general register has a predefined name of the form:
112 r<reg_num> which has the value <reg_num>.
114 Each floating point register a has predefined name of the form:
115 f<reg_num> which has the value <reg_num>.
117 There are individual registers as well:
121 The table is sorted. Suitable for searching by a binary search. */
123 static const struct pd_reg pre_defined_registers
[] =
125 { "a0", 0 }, /* Access registers */
142 { "c0", 0 }, /* Control registers */
159 { "f0", 0 }, /* Floating point registers */
176 { "lit", 13 }, /* Pointer to literal pool */
178 { "r0", 0 }, /* General purpose registers */
195 { "sp", 15 }, /* Stack pointer */
199 #define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg))
201 /* Given NAME, find the register number associated with that name, return
202 the integer value associated with the given name or -1 on failure. */
205 reg_name_search (regs
, regcount
, name
)
206 const struct pd_reg
*regs
;
210 int middle
, low
, high
;
218 middle
= (low
+ high
) / 2;
219 cmp
= strcasecmp (name
, regs
[middle
].name
);
225 return regs
[middle
].value
;
234 * Summary of register_name().
236 * in: Input_line_pointer points to 1st char of operand.
238 * out: A expressionS.
239 * The operand may have been a register: in this case, X_op == O_register,
240 * X_add_number is set to the register number, and truth is returned.
241 * Input_line_pointer->(next non-blank) char after operand, or is in its
246 register_name (expressionP
)
247 expressionS
*expressionP
;
254 /* Find the spelling of the operand. */
255 start
= name
= input_line_pointer
;
256 if (name
[0] == '%' && isalpha (name
[1]))
257 name
= ++input_line_pointer
;
261 c
= get_symbol_end ();
262 reg_number
= reg_name_search (pre_defined_registers
, REG_NAME_CNT
, name
);
264 /* Put back the delimiting char. */
265 *input_line_pointer
= c
;
267 /* Look to see if it's in the register table. */
270 expressionP
->X_op
= O_register
;
271 expressionP
->X_add_number
= reg_number
;
273 /* Make the rest nice. */
274 expressionP
->X_add_symbol
= NULL
;
275 expressionP
->X_op_symbol
= NULL
;
279 /* Reset the line as if we had not done anything. */
280 input_line_pointer
= start
;
284 /* Local variables. */
286 /* Opformat hash table. */
287 static struct hash_control
*s390_opformat_hash
;
289 /* Opcode hash table. */
290 static struct hash_control
*s390_opcode_hash
;
292 /* Flags to set in the elf header */
293 static flagword s390_flags
= 0;
295 symbolS
*GOT_symbol
; /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
297 #ifndef WORKING_DOT_WORD
298 const int md_short_jump_size
= 4;
299 const int md_long_jump_size
= 4;
302 CONST
char *md_shortopts
= "A:m:kVQ:";
303 struct option md_longopts
[] = {
304 {NULL
, no_argument
, NULL
, 0}
306 size_t md_longopts_size
= sizeof (md_longopts
);
308 /* Initialize the default opcode arch and word size from the default
309 architecture name. */
313 if (current_arch_requested
)
316 if (strcmp (default_arch
, "s390") == 0)
319 current_architecture
= S390_OPCODE_ESA
;
321 else if (strcmp (default_arch
, "s390x") == 0)
324 current_architecture
= S390_OPCODE_ESAME
;
327 as_fatal ("Invalid default architecture, broken assembler.");
328 current_arch_mask
= 1 << current_architecture
;
331 /* Called by TARGET_FORMAT. */
333 s390_target_format ()
335 /* We don't get a chance to initialize anything before we're called,
336 so handle that now. */
337 if (! s390_arch_size
)
338 init_default_arch ();
340 return s390_arch_size
== 64 ? "elf64-s390" : "elf32-s390";
344 md_parse_option (c
, arg
)
350 /* -k: Ignore for FreeBSD compatibility. */
354 if (arg
!= NULL
&& strcmp (arg
, "regnames") == 0)
357 else if (arg
!= NULL
&& strcmp (arg
, "no-regnames") == 0)
362 as_bad (_("invalid switch -m%s"), arg
);
368 if (arg
!= NULL
&& strcmp (arg
, "esa") == 0)
370 current_architecture
= S390_OPCODE_ESA
;
373 else if (arg
!= NULL
&& strcmp (arg
, "esame") == 0)
375 current_architecture
= S390_OPCODE_ESAME
;
379 as_bad ("invalid architecture -A%s", arg
);
380 current_arch_mask
= 1 << current_architecture
;
381 current_arch_requested
= 1;
384 /* -V: SVR4 argument to print version ID. */
389 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
390 should be emitted or not. FIXME: Not implemented. */
402 md_show_usage (stream
)
405 fprintf (stream
, _("\
407 -mregnames \tAllow symbolic names for registers\n\
408 -mno-regnames\tDo not allow symbolic names for registers\n"));
409 fprintf (stream
, _("\
410 -V \tprint assembler version number\n\
411 -Qy, -Qn \tignored\n"));
414 /* This function is called when the assembler starts up. It is called
415 after the options have been parsed and the output file has been
421 register const struct s390_opcode
*op
;
422 const struct s390_opcode
*op_end
;
423 boolean dup_insn
= false;
426 /* Set the ELF flags if desired. */
428 bfd_set_private_flags (stdoutput
, s390_flags
);
430 /* Insert the opcode formats into a hash table. */
431 s390_opformat_hash
= hash_new ();
433 op_end
= s390_opformats
+ s390_num_opformats
;
434 for (op
= s390_opformats
; op
< op_end
; op
++)
436 retval
= hash_insert (s390_opformat_hash
, op
->name
, (PTR
) op
);
437 if (retval
!= (const char *) NULL
)
439 as_bad (_("Internal assembler error for instruction format %s"),
445 /* Insert the opcodes into a hash table. */
446 s390_opcode_hash
= hash_new ();
448 op_end
= s390_opcodes
+ s390_num_opcodes
;
449 for (op
= s390_opcodes
; op
< op_end
; op
++)
451 retval
= hash_insert (s390_opcode_hash
, op
->name
, (PTR
) op
);
452 if (retval
!= (const char *) NULL
)
454 as_bad (_("Internal assembler error for instruction %s"), op
->name
);
462 record_alignment (text_section
, 2);
463 record_alignment (data_section
, 2);
464 record_alignment (bss_section
, 2);
468 /* Called after all assembly has been done. */
472 if (s390_arch_size
== 64)
473 bfd_set_arch_mach (stdoutput
, bfd_arch_s390
, bfd_mach_s390_esame
);
475 bfd_set_arch_mach (stdoutput
, bfd_arch_s390
, bfd_mach_s390_esa
);
479 s390_align_code (fragP
, count
)
483 /* We use nop pattern 0x0707. */
486 memset (fragP
->fr_literal
+ fragP
->fr_fix
, 0x07, count
);
487 fragP
->fr_var
= count
;
491 /* Insert an operand value into an instruction. */
494 s390_insert_operand (insn
, operand
, val
, file
, line
)
496 const struct s390_operand
*operand
;
504 if (operand
->flags
& (S390_OPERAND_SIGNED
|S390_OPERAND_PCREL
))
508 max
= ((offsetT
) 1 << (operand
->bits
- 1)) - 1;
509 min
= - ((offsetT
) 1 << (operand
->bits
- 1));
510 /* Halve PCREL operands. */
511 if (operand
->flags
& S390_OPERAND_PCREL
)
513 /* Check for underflow / overflow. */
514 if (val
< min
|| val
> max
)
517 "operand out of range (%s not between %ld and %ld)";
520 if (operand
->flags
& S390_OPERAND_PCREL
)
526 sprint_value (buf
, val
);
527 if (file
== (char *) NULL
)
528 as_bad (err
, buf
, (int) min
, (int) max
);
530 as_bad_where (file
, line
, err
, buf
, (int) min
, (int) max
);
533 /* val is ok, now restrict it to operand->bits bits. */
534 uval
= (addressT
) val
& ((((addressT
) 1 << (operand
->bits
-1)) << 1) - 1);
540 max
= (((addressT
) 1 << (operand
->bits
- 1))<<1) - 1;
542 uval
= (addressT
) val
;
543 /* Length x in an instructions has real length x+1. */
544 if (operand
->flags
& S390_OPERAND_LENGTH
)
546 /* Check for underflow / overflow. */
547 if (uval
< min
|| uval
> max
)
550 "operand out of range (%s not between %ld and %ld)";
553 if (operand
->flags
& S390_OPERAND_LENGTH
)
559 sprint_value (buf
, uval
);
560 if (file
== (char *) NULL
)
561 as_bad (err
, buf
, (int) min
, (int) max
);
563 as_bad_where (file
, line
, err
, buf
, (int) min
, (int) max
);
568 /* Insert fragments of the operand byte for byte. */
569 offset
= operand
->shift
+ operand
->bits
;
570 uval
<<= (-offset
) & 7;
571 insn
+= (offset
- 1)/8;
579 /* Structure used to hold suffixes. */
593 elf_suffix_type suffix
;
596 /* Parse @got/@plt/@gotoff. and return the desired relocation. */
597 static elf_suffix_type
598 s390_elf_suffix (str_p
, exp_p
)
602 static struct map_bfd mapping
[] =
604 { "got", 3, ELF_SUFFIX_GOT
},
605 { "got12", 5, ELF_SUFFIX_GOT
},
606 { "plt", 3, ELF_SUFFIX_PLT
},
607 { "gotent", 6, ELF_SUFFIX_GOTENT
},
608 { NULL
, 0, ELF_SUFFIX_NONE
}
617 return ELF_SUFFIX_NONE
;
620 while (isalnum (*str
))
624 for (ptr
= &mapping
[0]; ptr
->length
> 0; ptr
++)
625 if (len
== ptr
->length
&&
626 strncasecmp (ident
, ptr
->string
, ptr
->length
) == 0)
628 if (exp_p
->X_add_number
!= 0)
629 as_warn (_("identifier+constant@%s means identifier@%s+constant"),
630 ptr
->string
, ptr
->string
);
631 /* Now check for identifier@suffix+constant. */
632 if (*str
== '-' || *str
== '+')
634 char *orig_line
= input_line_pointer
;
637 input_line_pointer
= str
;
638 expression (&new_exp
);
640 switch (new_exp
.X_op
)
642 case O_constant
: /* X_add_number (a constant expression). */
643 exp_p
->X_add_number
+= new_exp
.X_add_number
;
644 str
= input_line_pointer
;
646 case O_symbol
: /* X_add_symbol + X_add_number. */
647 /* this case is used for e.g. xyz@PLT+.Label. */
648 exp_p
->X_add_number
+= new_exp
.X_add_number
;
649 exp_p
->X_op_symbol
= new_exp
.X_add_symbol
;
651 str
= input_line_pointer
;
653 case O_uminus
: /* (- X_add_symbol) + X_add_number. */
654 /* this case is used for e.g. xyz@PLT-.Label. */
655 exp_p
->X_add_number
+= new_exp
.X_add_number
;
656 exp_p
->X_op_symbol
= new_exp
.X_add_symbol
;
657 exp_p
->X_op
= O_subtract
;
658 str
= input_line_pointer
;
664 /* If s390_elf_suffix has not been called with
665 &input_line_pointer as first parameter, we have
666 clobbered the input_line_pointer. We have to
668 if (&input_line_pointer
!= str_p
)
669 input_line_pointer
= orig_line
;
675 return BFD_RELOC_UNUSED
;
678 /* Structure used to hold a literal pool entry. */
681 struct s390_lpe
*next
;
683 FLONUM_TYPE floatnum
; /* used if X_op == O_big && X_add_number <= 0 */
684 LITTLENUM_TYPE bignum
[4]; /* used if X_op == O_big && X_add_number > 0 */
686 bfd_reloc_code_real_type reloc
;
690 static struct s390_lpe
*lpe_free_list
= NULL
;
691 static struct s390_lpe
*lpe_list
= NULL
;
692 static struct s390_lpe
*lpe_list_tail
= NULL
;
693 static symbolS
*lp_sym
= NULL
;
694 static int lp_count
= 0;
695 static int lpe_count
= 0;
698 s390_exp_compare(exp1
, exp2
)
702 if (exp1
->X_op
!= exp2
->X_op
)
707 case O_constant
: /* X_add_number must be equal. */
709 return exp1
->X_add_number
== exp2
->X_add_number
;
712 as_bad (_("Can't handle O_big in s390_exp_compare"));
714 case O_symbol
: /* X_add_symbol & X_add_number must be equal. */
719 return (exp1
->X_add_symbol
== exp2
->X_add_symbol
) &&
720 (exp1
->X_add_number
== exp2
->X_add_number
);
722 case O_multiply
: /* X_add_symbol,X_op_symbol&X_add_number must be equal. */
727 case O_bit_inclusive_or
:
729 case O_bit_exclusive_or
:
741 return (exp1
->X_add_symbol
== exp2
->X_add_symbol
) &&
742 (exp1
->X_op_symbol
== exp2
->X_op_symbol
) &&
743 (exp1
->X_add_number
== exp2
->X_add_number
);
749 /* Test for @lit and if its present make an entry in the literal pool and
750 modify the current expression to be an offset into the literal pool. */
751 static elf_suffix_type
752 s390_lit_suffix (str_p
, exp_p
, suffix
)
755 elf_suffix_type suffix
;
757 bfd_reloc_code_real_type reloc
;
761 struct s390_lpe
*lpe
;
765 return suffix
; /* No modification. */
767 /* We look for a suffix of the form "@lit1", "@lit2", "@lit4" or "@lit8". */
769 while (isalnum (*str
))
772 if (len
!= 4 || strncasecmp (ident
, "lit", 3) != 0 ||
773 (ident
[3]!='1' && ident
[3]!='2' && ident
[3]!='4' && ident
[3]!='8'))
774 return suffix
; /* no modification */
775 nbytes
= ident
[3] - '0';
777 reloc
= BFD_RELOC_UNUSED
;
778 if (suffix
== ELF_SUFFIX_GOT
)
781 reloc
= BFD_RELOC_390_GOT16
;
782 else if (nbytes
== 4)
783 reloc
= BFD_RELOC_32_GOT_PCREL
;
784 else if (nbytes
== 8)
785 reloc
= BFD_RELOC_390_GOT64
;
787 else if (suffix
== ELF_SUFFIX_PLT
)
790 reloc
= BFD_RELOC_390_PLT32
;
791 else if (nbytes
== 8)
792 reloc
= BFD_RELOC_390_PLT64
;
795 if (suffix
!= ELF_SUFFIX_NONE
&& reloc
== BFD_RELOC_UNUSED
)
796 as_bad (_("Invalid suffix for literal pool entry"));
798 /* Search the pool if the new entry is a duplicate. */
799 if (exp_p
->X_op
== O_big
)
801 /* Special processing for big numbers. */
802 for (lpe
= lpe_list
; lpe
!= NULL
; lpe
= lpe
->next
)
804 if (lpe
->ex
.X_op
== O_big
)
806 if (exp_p
->X_add_number
<= 0 && lpe
->ex
.X_add_number
<= 0)
808 if (memcmp (&generic_floating_point_number
, &lpe
->floatnum
,
809 sizeof (FLONUM_TYPE
)) == 0)
812 else if (exp_p
->X_add_number
== lpe
->ex
.X_add_number
)
814 if (memcmp (generic_bignum
, lpe
->bignum
,
815 sizeof (LITTLENUM_TYPE
)*exp_p
->X_add_number
) == 0)
823 /* Processing for 'normal' data types. */
824 for (lpe
= lpe_list
; lpe
!= NULL
; lpe
= lpe
->next
)
825 if (lpe
->nbytes
== nbytes
&& lpe
->reloc
== reloc
&&
826 s390_exp_compare(exp_p
, &lpe
->ex
) != 0)
833 if (lpe_free_list
!= NULL
)
836 lpe_free_list
= lpe_free_list
->next
;
840 lpe
= (struct s390_lpe
*) xmalloc(sizeof (struct s390_lpe
));
845 if (exp_p
->X_op
== O_big
)
847 if (exp_p
->X_add_number
<= 0)
848 lpe
->floatnum
= generic_floating_point_number
;
849 else if (exp_p
->X_add_number
<= 4)
850 memcpy (lpe
->bignum
, generic_bignum
,
851 exp_p
->X_add_number
*sizeof (LITTLENUM_TYPE
));
853 as_bad (_("Big number is too big"));
856 lpe
->nbytes
= nbytes
;
858 /* Literal pool name defined ? */
861 sprintf (tmp_name
, ".L\001%i", lp_count
);
862 lp_sym
= symbol_make(tmp_name
);
865 /* Make name for literal pool entry. */
866 sprintf (tmp_name
, ".L\001%i\002%i", lp_count
, lpe_count
);
868 lpe
->sym
= symbol_make(tmp_name
);
870 /* Add to literal pool list. */
872 if (lpe_list_tail
!= NULL
)
874 lpe_list_tail
->next
= lpe
;
878 lpe_list
= lpe_list_tail
= lpe
;
881 /* Now change exp_p to the offset into the literal pool.
882 Thats the expression: .L^Ax^By-.L^Ax */
883 exp_p
->X_add_symbol
= lpe
->sym
;
884 exp_p
->X_op_symbol
= lp_sym
;
885 exp_p
->X_op
= O_subtract
;
886 exp_p
->X_add_number
= 0;
890 /* We change the suffix type to ELF_SUFFIX_NONE, because
891 the difference of two local labels is just a number. */
892 return ELF_SUFFIX_NONE
;
895 /* Like normal .long/.short/.word, except support @got, etc.
896 clobbers input_line_pointer, checks end-of-line. */
898 s390_elf_cons (nbytes
)
899 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
902 elf_suffix_type suffix
;
904 if (is_it_end_of_statement ())
906 demand_empty_rest_of_line ();
914 if (exp
.X_op
== O_symbol
915 && *input_line_pointer
== '@'
916 && (suffix
= s390_elf_suffix (&input_line_pointer
, &exp
)) != ELF_SUFFIX_NONE
)
918 bfd_reloc_code_real_type reloc
;
919 reloc_howto_type
*reloc_howto
;
923 if (nbytes
== 2 && suffix
== ELF_SUFFIX_GOT
)
924 reloc
= BFD_RELOC_390_GOT16
;
925 else if (nbytes
== 4 && suffix
== ELF_SUFFIX_GOT
)
926 reloc
= BFD_RELOC_32_GOT_PCREL
;
927 else if (nbytes
== 8 && suffix
== ELF_SUFFIX_GOT
)
928 reloc
= BFD_RELOC_390_GOT64
;
929 else if (nbytes
== 4 && suffix
== ELF_SUFFIX_PLT
)
930 reloc
= BFD_RELOC_390_PLT32
;
931 else if (nbytes
== 8 && suffix
== ELF_SUFFIX_PLT
)
932 reloc
= BFD_RELOC_390_PLT64
;
934 reloc
= BFD_RELOC_UNUSED
;
936 if (reloc
!= BFD_RELOC_UNUSED
)
938 reloc_howto
= bfd_reloc_type_lookup (stdoutput
, reloc
);
939 size
= bfd_get_reloc_size (reloc_howto
);
941 as_bad (_("%s relocations do not fit in %d bytes"),
942 reloc_howto
->name
, nbytes
);
943 where
= frag_more (nbytes
);
944 md_number_to_chars (where
, 0, size
);
945 fix_new_exp (frag_now
, where
- frag_now
->fr_literal
,
946 size
, &exp
, reloc_howto
->pc_relative
, reloc
);
949 as_bad (_("relocation not applicable"));
952 emit_expr (&exp
, (unsigned int) nbytes
);
954 while (*input_line_pointer
++ == ',');
956 input_line_pointer
--; /* Put terminator back into stream. */
957 demand_empty_rest_of_line ();
960 /* We need to keep a list of fixups. We can't simply generate them as
961 we go, because that would require us to first create the frag, and
962 that would screw up references to ``.''. */
968 bfd_reloc_code_real_type reloc
;
971 #define MAX_INSN_FIXUPS (4)
973 /* This routine is called for each instruction to be assembled. */
976 md_gather_operands (str
, insn
, opcode
)
979 const struct s390_opcode
*opcode
;
981 struct s390_fixup fixups
[MAX_INSN_FIXUPS
];
982 const struct s390_operand
*operand
;
983 const unsigned char *opindex_ptr
;
984 elf_suffix_type suffix
;
985 bfd_reloc_code_real_type reloc
;
991 while (isspace(*str
)) str
++;
996 /* Gather the operands. */
998 for (opindex_ptr
= opcode
->operands
; *opindex_ptr
!= 0; opindex_ptr
++)
1003 operand
= s390_operands
+ *opindex_ptr
;
1005 if (skip_optional
&& (operand
->flags
& S390_OPERAND_INDEX
))
1007 /* We do an early skip. For D(X,B) constructions the index
1008 register is skipped (X is optional). For D(L,B) the base
1009 register will be the skipped operand, because L is NOT
1015 /* Gather the operand. */
1016 hold
= input_line_pointer
;
1017 input_line_pointer
= str
;
1019 if (! register_name (&ex
)) /* parse the operand */
1022 str
= input_line_pointer
;
1023 input_line_pointer
= hold
;
1025 /* Write the operand to the insn. */
1026 if (ex
.X_op
== O_illegal
)
1027 as_bad (_("illegal operand"));
1028 else if (ex
.X_op
== O_absent
)
1029 as_bad (_("missing operand"));
1030 else if (ex
.X_op
== O_register
|| ex
.X_op
== O_constant
)
1032 s390_lit_suffix (&str
, &ex
, ELF_SUFFIX_NONE
);
1034 if (ex
.X_op
!= O_register
&& ex
.X_op
!= O_constant
)
1036 /* We need to generate a fixup for the
1037 expression returned by s390_lit_suffix. */
1038 if (fc
>= MAX_INSN_FIXUPS
)
1039 as_fatal (_("too many fixups"));
1040 fixups
[fc
].exp
= ex
;
1041 fixups
[fc
].opindex
= *opindex_ptr
;
1042 fixups
[fc
].reloc
= BFD_RELOC_UNUSED
;
1047 if ((operand
->flags
& S390_OPERAND_INDEX
) && ex
.X_add_number
== 0)
1048 as_warn ("index register specified but zero");
1049 if ((operand
->flags
& S390_OPERAND_BASE
) && ex
.X_add_number
== 0)
1050 as_warn ("base register specified but zero");
1051 s390_insert_operand (insn
, operand
, ex
.X_add_number
, NULL
, 0);
1056 suffix
= s390_elf_suffix (&str
, &ex
);
1057 suffix
= s390_lit_suffix (&str
, &ex
, suffix
);
1058 reloc
= BFD_RELOC_UNUSED
;
1060 if (suffix
== ELF_SUFFIX_GOT
)
1062 if (operand
->flags
& S390_OPERAND_DISP
)
1063 reloc
= BFD_RELOC_390_GOT12
;
1064 else if ((operand
->flags
& S390_OPERAND_SIGNED
) &&
1065 (operand
->bits
== 16))
1066 reloc
= BFD_RELOC_390_GOT16
;
1067 else if ((operand
->flags
& S390_OPERAND_PCREL
) &&
1068 (operand
->bits
== 32))
1069 reloc
= BFD_RELOC_390_GOTENT
;
1071 else if (suffix
== ELF_SUFFIX_PLT
)
1073 if ((operand
->flags
& S390_OPERAND_PCREL
) &&
1074 (operand
->bits
== 16))
1075 reloc
= BFD_RELOC_390_PLT16DBL
;
1076 else if ((operand
->flags
& S390_OPERAND_PCREL
) &&
1077 (operand
->bits
== 32))
1078 reloc
= BFD_RELOC_390_PLT32DBL
;
1080 else if (suffix
== ELF_SUFFIX_GOTENT
)
1082 if ((operand
->flags
& S390_OPERAND_PCREL
) &&
1083 (operand
->bits
== 32))
1084 reloc
= BFD_RELOC_390_GOTENT
;
1087 if (suffix
!= ELF_SUFFIX_NONE
&& reloc
== BFD_RELOC_UNUSED
)
1088 as_bad (_("invalid operand suffix"));
1089 /* We need to generate a fixup of type 'reloc' for this
1091 if (fc
>= MAX_INSN_FIXUPS
)
1092 as_fatal (_("too many fixups"));
1093 fixups
[fc
].exp
= ex
;
1094 fixups
[fc
].opindex
= *opindex_ptr
;
1095 fixups
[fc
].reloc
= reloc
;
1099 /* Check the next character. The call to expression has advanced
1100 str past any whitespace. */
1101 if (operand
->flags
& S390_OPERAND_DISP
)
1103 /* After a displacement a block in parentheses can start. */
1106 /* Check if parethesed block can be skipped. If the next
1107 operand is neiter an optional operand nor a base register
1108 then we have a syntax error. */
1109 operand
= s390_operands
+ *(++opindex_ptr
);
1110 if (!(operand
->flags
& (S390_OPERAND_INDEX
|S390_OPERAND_BASE
)))
1111 as_bad (_("syntax error; missing '(' after displacement"));
1113 /* Ok, skip all operands until S390_OPERAND_BASE. */
1114 while (!(operand
->flags
& S390_OPERAND_BASE
))
1115 operand
= s390_operands
+ *(++opindex_ptr
);
1117 /* If there is a next operand it must be seperated by a comma. */
1118 if (opindex_ptr
[1] != '\0')
1121 as_bad (_("syntax error; expected ,"));
1126 /* We found an opening parentheses. */
1128 for (f
= str
; *f
!= '\0'; f
++)
1129 if (*f
== ',' || *f
== ')')
1131 /* If there is no comma until the closing parentheses OR
1132 there is a comma right after the opening parentheses,
1133 we have to skip optional operands. */
1134 if (*f
== ',' && f
== str
)
1136 /* comma directly after '(' ? */
1141 skip_optional
= (*f
!= ',');
1144 else if (operand
->flags
& S390_OPERAND_BASE
)
1146 /* After the base register the parenthesed block ends. */
1148 as_bad (_("syntax error; missing ')' after base register"));
1150 /* If there is a next operand it must be seperated by a comma. */
1151 if (opindex_ptr
[1] != '\0')
1154 as_bad (_("syntax error; expected ,"));
1159 /* We can find an 'early' closing parentheses in e.g. D(L) instead
1160 of D(L,B). In this case the base register has to be skipped. */
1163 operand
= s390_operands
+ *(++opindex_ptr
);
1165 if (!(operand
->flags
& S390_OPERAND_BASE
))
1166 as_bad (_("syntax error; ')' not allowed here"));
1169 /* If there is a next operand it must be seperated by a comma. */
1170 if (opindex_ptr
[1] != '\0')
1173 as_bad (_("syntax error; expected ,"));
1178 while (isspace (*str
))
1185 if ((linefeed
= strchr (str
, '\n')) != NULL
)
1187 as_bad (_("junk at end of line: `%s'"), str
);
1188 if (linefeed
!= NULL
)
1192 /* Write out the instruction. */
1193 f
= frag_more (opcode
->oplen
);
1194 memcpy (f
, insn
, opcode
->oplen
);
1196 /* Create any fixups. At this point we do not use a
1197 bfd_reloc_code_real_type, but instead just use the
1198 BFD_RELOC_UNUSED plus the operand index. This lets us easily
1199 handle fixups for any operand type, although that is admittedly
1200 not a very exciting feature. We pick a BFD reloc type in
1202 for (i
= 0; i
< fc
; i
++)
1204 operand
= s390_operands
+ fixups
[i
].opindex
;
1206 if (fixups
[i
].reloc
!= BFD_RELOC_UNUSED
)
1208 reloc_howto_type
*reloc_howto
;
1212 reloc_howto
= bfd_reloc_type_lookup (stdoutput
, fixups
[i
].reloc
);
1216 size
= bfd_get_reloc_size (reloc_howto
);
1218 if (size
< 1 || size
> 4)
1221 fixP
= fix_new_exp (frag_now
,
1222 f
- frag_now
->fr_literal
+ (operand
->shift
/8),
1223 size
, &fixups
[i
].exp
, reloc_howto
->pc_relative
,
1225 /* Turn off overflow checking in fixup_segment. This is necessary
1226 because fixup_segment will signal an overflow for large 4 byte
1227 quantities for GOT12 relocations. */
1228 if (fixups
[i
].reloc
== BFD_RELOC_390_GOT12
||
1229 fixups
[i
].reloc
== BFD_RELOC_390_GOT16
)
1230 fixP
->fx_no_overflow
= 1;
1233 fix_new_exp (frag_now
, f
- frag_now
->fr_literal
, 4, &fixups
[i
].exp
,
1234 (operand
->flags
& S390_OPERAND_PCREL
) != 0,
1235 ((bfd_reloc_code_real_type
)
1236 (fixups
[i
].opindex
+ (int) BFD_RELOC_UNUSED
)));
1241 /* This routine is called for each instruction to be assembled. */
1247 const struct s390_opcode
*opcode
;
1248 unsigned char insn
[6];
1251 /* Get the opcode. */
1252 for (s
= str
; *s
!= '\0' && ! isspace (*s
); s
++)
1257 /* Look up the opcode in the hash table. */
1258 opcode
= (struct s390_opcode
*) hash_find (s390_opcode_hash
, str
);
1259 if (opcode
== (const struct s390_opcode
*) NULL
)
1261 as_bad (_("Unrecognized opcode: `%s'"), str
);
1264 else if (!(opcode
->architecture
& current_arch_mask
))
1266 as_bad ("Opcode %s not available in this architecture", str
);
1270 memcpy (insn
, opcode
->opcode
, sizeof (insn
));
1271 md_gather_operands (s
, insn
, opcode
);
1274 #ifndef WORKING_DOT_WORD
1275 /* Handle long and short jumps. We don't support these */
1277 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1279 addressT from_addr
, to_addr
;
1287 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1289 addressT from_addr
, to_addr
;
1299 int ignore ATTRIBUTE_UNUSED
;
1301 /* We don't support putting frags in the BSS segment, we fake it
1302 by marking in_bss, then looking at s_skip for clues. */
1304 subseg_set (bss_section
, 0);
1305 demand_empty_rest_of_line ();
1308 /* Pseudo-op handling. */
1312 int ignore ATTRIBUTE_UNUSED
;
1315 const struct s390_opcode
*opformat
;
1316 unsigned char insn
[6];
1319 /* Get the opcode format. */
1320 s
= input_line_pointer
;
1321 while (*s
!= '\0' && *s
!= ',' && ! isspace (*s
))
1324 as_bad (_("Invalid .insn format\n"));
1327 /* Look up the opcode in the hash table. */
1328 opformat
= (struct s390_opcode
*)
1329 hash_find (s390_opformat_hash
, input_line_pointer
);
1330 if (opformat
== (const struct s390_opcode
*) NULL
)
1332 as_bad (_("Unrecognized opcode format: `%s'"), input_line_pointer
);
1335 input_line_pointer
= s
;
1337 if (exp
.X_op
== O_constant
)
1339 if (opformat
->oplen
== 4 ||
1340 (opformat
->oplen
== 2 && exp
.X_op
< 0x10000))
1341 md_number_to_chars (insn
, exp
.X_add_number
, opformat
->oplen
);
1343 as_bad (_("Invalid .insn format\n"));
1345 else if (exp
.X_op
== O_big
)
1347 if (exp
.X_add_number
> 0 &&
1348 opformat
->oplen
== 6 &&
1349 generic_bignum
[3] == 0)
1351 md_number_to_chars (insn
, generic_bignum
[2], 2);
1352 md_number_to_chars (&insn
[2], generic_bignum
[1], 2);
1353 md_number_to_chars (&insn
[4], generic_bignum
[0], 2);
1356 as_bad (_("Invalid .insn format\n"));
1359 as_bad (_("second operand of .insn not a constant\n"));
1360 if (*input_line_pointer
++ != ',')
1361 as_bad (_("missing comma after insn constant\n"));
1363 if ((s
= strchr (input_line_pointer
, '\n')) != NULL
)
1365 input_line_pointer
= md_gather_operands (input_line_pointer
, insn
, opformat
);
1368 demand_empty_rest_of_line ();
1371 /* The .byte pseudo-op. This is similar to the normal .byte
1372 pseudo-op, but it can also take a single ASCII string. */
1376 int ignore ATTRIBUTE_UNUSED
;
1378 if (*input_line_pointer
!= '\"')
1384 /* Gather characters. A real double quote is doubled. Unusual
1385 characters are not permitted. */
1386 ++input_line_pointer
;
1391 c
= *input_line_pointer
++;
1395 if (*input_line_pointer
!= '\"')
1397 ++input_line_pointer
;
1400 FRAG_APPEND_1_CHAR (c
);
1403 demand_empty_rest_of_line ();
1406 /* The .ltorg pseudo-op.This emits all literals defined since the last
1407 .ltorg or the invocation of gas. Literals are defined with the
1411 s390_literals (ignore
)
1412 int ignore ATTRIBUTE_UNUSED
;
1414 struct s390_lpe
*lpe
;
1416 if (lp_sym
== NULL
|| lpe_count
== 0)
1417 return; /* nothing to be done */
1419 /* Emit symbol for start of literal pool. */
1420 S_SET_SEGMENT (lp_sym
, now_seg
);
1421 S_SET_VALUE (lp_sym
, (valueT
) frag_now_fix ());
1422 lp_sym
->sy_frag
= frag_now
;
1427 lpe_list
= lpe_list
->next
;
1428 S_SET_SEGMENT (lpe
->sym
, now_seg
);
1429 S_SET_VALUE (lpe
->sym
, (valueT
) frag_now_fix ());
1430 lpe
->sym
->sy_frag
= frag_now
;
1432 /* Emit literal pool entry. */
1433 if (lpe
->reloc
!= BFD_RELOC_UNUSED
)
1435 reloc_howto_type
*reloc_howto
=
1436 bfd_reloc_type_lookup (stdoutput
, lpe
->reloc
);
1437 int size
= bfd_get_reloc_size (reloc_howto
);
1440 if (size
> lpe
->nbytes
)
1441 as_bad (_("%s relocations do not fit in %d bytes"),
1442 reloc_howto
->name
, lpe
->nbytes
);
1443 where
= frag_more (lpe
->nbytes
);
1444 md_number_to_chars (where
, 0, size
);
1445 fix_new_exp (frag_now
, where
- frag_now
->fr_literal
,
1446 size
, &lpe
->ex
, reloc_howto
->pc_relative
, lpe
->reloc
);
1450 if (lpe
->ex
.X_op
== O_big
)
1452 if (lpe
->ex
.X_add_number
<= 0)
1453 generic_floating_point_number
= lpe
->floatnum
;
1455 memcpy (generic_bignum
, lpe
->bignum
,
1456 lpe
->ex
.X_add_number
*sizeof (LITTLENUM_TYPE
));
1458 emit_expr (&lpe
->ex
, lpe
->nbytes
);
1461 lpe
->next
= lpe_free_list
;
1462 lpe_free_list
= lpe
;
1464 lpe_list_tail
= NULL
;
1470 /* Turn a string in input_line_pointer into a floating point constant
1471 of type type, and store the appropriate bytes in *litp. The number
1472 of LITTLENUMS emitted is stored in *sizep . An error message is
1473 returned, or NULL on OK. */
1476 md_atof (type
, litp
, sizep
)
1482 LITTLENUM_TYPE words
[4];
1498 return "bad call to md_atof";
1501 t
= atof_ieee (input_line_pointer
, type
, words
);
1503 input_line_pointer
= t
;
1507 for (i
= 0; i
< prec
; i
++)
1509 md_number_to_chars (litp
, (valueT
) words
[i
], 2);
1516 /* Align a section (I don't know why this is machine dependent). */
1519 md_section_align (seg
, addr
)
1523 int align
= bfd_get_section_alignment (stdoutput
, seg
);
1525 return ((addr
+ (1 << align
) - 1) & (-1 << align
));
1528 /* We don't have any form of relaxing. */
1531 md_estimate_size_before_relax (fragp
, seg
)
1532 fragS
*fragp ATTRIBUTE_UNUSED
;
1533 asection
*seg ATTRIBUTE_UNUSED
;
1539 /* Convert a machine dependent frag. We never generate these. */
1542 md_convert_frag (abfd
, sec
, fragp
)
1543 bfd
*abfd ATTRIBUTE_UNUSED
;
1544 asection
*sec ATTRIBUTE_UNUSED
;
1545 fragS
*fragp ATTRIBUTE_UNUSED
;
1551 md_undefined_symbol (name
)
1554 if (*name
== '_' && *(name
+1) == 'G'
1555 && strcmp (name
, "_GLOBAL_OFFSET_TABLE_") == 0)
1559 if (symbol_find (name
))
1560 as_bad (_("GOT already in symbol table"));
1561 GOT_symbol
= symbol_new (name
, undefined_section
,
1562 (valueT
) 0, &zero_address_frag
);
1569 /* Functions concerning relocs. */
1571 /* The location from which a PC relative jump should be calculated,
1572 given a PC relative reloc. */
1575 md_pcrel_from_section (fixp
, sec
)
1577 segT sec ATTRIBUTE_UNUSED
;
1579 return fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1582 /* Here we decide which fixups can be adjusted to make them relative to
1583 the beginning of the section instead of the symbol. Basically we need
1584 to make sure that the dynamic relocations are done correctly, so in
1585 some cases we force the original symbol to be used. */
1587 tc_s390_fix_adjustable(fixP
)
1590 /* Prevent all adjustments to global symbols. */
1591 if (S_IS_EXTERN (fixP
->fx_addsy
))
1593 if (S_IS_WEAK (fixP
->fx_addsy
))
1595 /* adjust_reloc_syms doesn't know about the GOT. */
1596 if (fixP
->fx_r_type
== BFD_RELOC_32_GOTOFF
1597 || fixP
->fx_r_type
== BFD_RELOC_390_PLT16DBL
1598 || fixP
->fx_r_type
== BFD_RELOC_390_PLT32
1599 || fixP
->fx_r_type
== BFD_RELOC_390_PLT32DBL
1600 || fixP
->fx_r_type
== BFD_RELOC_390_PLT64
1601 || fixP
->fx_r_type
== BFD_RELOC_390_GOT12
1602 || fixP
->fx_r_type
== BFD_RELOC_390_GOT16
1603 || fixP
->fx_r_type
== BFD_RELOC_32_GOT_PCREL
1604 || fixP
->fx_r_type
== BFD_RELOC_390_GOT64
1605 || fixP
->fx_r_type
== BFD_RELOC_390_GOTENT
1606 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
1607 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
1612 /* Apply a fixup to the object code. This is called for all the
1613 fixups we generated by the call to fix_new_exp, above. In the call
1614 above we used a reloc code which was the largest legal reloc code
1615 plus the operand index. Here we undo that to recover the operand
1616 index. At this point all symbol values should be fully resolved,
1617 and we attempt to completely resolve the reloc. If we can not do
1618 that, we determine the correct reloc code and put it back in the
1622 md_apply_fix3 (fixp
, valuep
, seg
)
1625 segT seg ATTRIBUTE_UNUSED
;
1631 where
= fixp
->fx_frag
->fr_literal
+ fixp
->fx_where
;
1633 if (fixp
->fx_subsy
!= NULL
)
1635 if (!S_IS_DEFINED (fixp
->fx_subsy
))
1636 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1637 _("unresolved fx_subsy symbol that must be resolved"));
1638 value
-= S_GET_VALUE(fixp
->fx_subsy
);
1641 if (fixp
->fx_addsy
!= NULL
)
1643 /* `*valuep' may contain the value of the symbol on which the reloc
1644 will be based; we have to remove it. */
1645 if (fixp
->fx_addsy
->sy_used_in_reloc
1646 && S_GET_SEGMENT (fixp
->fx_addsy
) != absolute_section
1647 && S_GET_SEGMENT (fixp
->fx_addsy
) != undefined_section
1648 && ! bfd_is_com_section (S_GET_SEGMENT (fixp
->fx_addsy
)))
1649 value
-= S_GET_VALUE (fixp
->fx_addsy
);
1652 value
+= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1657 if ((int) fixp
->fx_r_type
>= (int) BFD_RELOC_UNUSED
)
1659 const struct s390_operand
*operand
;
1662 opindex
= (int) fixp
->fx_r_type
- (int) BFD_RELOC_UNUSED
;
1663 operand
= &s390_operands
[opindex
];
1667 /* Insert the fully resolved operand value. */
1668 s390_insert_operand (where
, operand
, (offsetT
) value
,
1669 fixp
->fx_file
, fixp
->fx_line
);
1674 /* Determine a BFD reloc value based on the operand information.
1675 We are only prepared to turn a few of the operands into
1677 fixp
->fx_offset
= value
;
1678 if (operand
->bits
== 12 && operand
->shift
== 20)
1681 fixp
->fx_where
+= 2;
1682 fixp
->fx_r_type
= BFD_RELOC_390_12
;
1684 else if (operand
->bits
== 12 && operand
->shift
== 36)
1687 fixp
->fx_where
+= 4;
1688 fixp
->fx_r_type
= BFD_RELOC_390_12
;
1690 else if (operand
->bits
== 8 && operand
->shift
== 8)
1693 fixp
->fx_where
+= 1;
1694 fixp
->fx_r_type
= BFD_RELOC_8
;
1696 else if (operand
->bits
== 16 && operand
->shift
== 16)
1699 fixp
->fx_where
+= 2;
1700 if (operand
->flags
& S390_OPERAND_PCREL
)
1702 fixp
->fx_r_type
= BFD_RELOC_390_PC16DBL
;
1703 fixp
->fx_offset
+= 2;
1706 fixp
->fx_r_type
= BFD_RELOC_16
;
1708 else if (operand
->bits
== 32 && operand
->shift
== 16 &&
1709 (operand
->flags
& S390_OPERAND_PCREL
))
1712 fixp
->fx_where
+= 2;
1713 fixp
->fx_offset
+= 2;
1714 fixp
->fx_r_type
= BFD_RELOC_390_PC32DBL
;
1721 /* Use expr_symbol_where to see if this is an expression
1723 if (expr_symbol_where (fixp
->fx_addsy
, &sfile
, &sline
))
1724 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1725 _("unresolved expression that must be resolved"));
1727 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1728 _("unsupported relocation type"));
1735 switch (fixp
->fx_r_type
)
1741 md_number_to_chars (where
, value
, 1);
1743 case BFD_RELOC_390_12
:
1744 case BFD_RELOC_390_GOT12
:
1749 mop
= bfd_getb16 ((unsigned char *) where
);
1750 mop
|= (unsigned short) (value
& 0xfff);
1751 bfd_putb16 ((bfd_vma
) mop
, (unsigned char *) where
);
1756 case BFD_RELOC_GPREL16
:
1757 case BFD_RELOC_16_GOT_PCREL
:
1758 case BFD_RELOC_16_GOTOFF
:
1760 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1761 "cannot emit PC relative %s relocation%s%s",
1762 bfd_get_reloc_code_name (fixp
->fx_r_type
),
1763 fixp
->fx_addsy
!= NULL
? " against " : "",
1764 (fixp
->fx_addsy
!= NULL
1765 ? S_GET_NAME (fixp
->fx_addsy
)
1768 md_number_to_chars (where
, value
, 2);
1770 case BFD_RELOC_390_GOT16
:
1772 md_number_to_chars (where
, value
, 2);
1774 case BFD_RELOC_390_PC16DBL
:
1775 case BFD_RELOC_390_PLT16DBL
:
1778 md_number_to_chars (where
, (offsetT
) value
>> 1, 2);
1783 fixp
->fx_r_type
= BFD_RELOC_32_PCREL
;
1785 fixp
->fx_r_type
= BFD_RELOC_32
;
1787 md_number_to_chars (where
, value
, 4);
1789 case BFD_RELOC_32_PCREL
:
1790 case BFD_RELOC_32_BASEREL
:
1791 fixp
->fx_r_type
= BFD_RELOC_32_PCREL
;
1793 md_number_to_chars (where
, value
, 4);
1795 case BFD_RELOC_32_GOT_PCREL
:
1796 case BFD_RELOC_390_PLT32
:
1798 md_number_to_chars (where
, value
, 4);
1800 case BFD_RELOC_390_PC32DBL
:
1801 case BFD_RELOC_390_PLT32DBL
:
1802 case BFD_RELOC_390_GOTPCDBL
:
1803 case BFD_RELOC_390_GOTENT
:
1806 md_number_to_chars (where
, (offsetT
) value
>> 1, 4);
1809 case BFD_RELOC_32_GOTOFF
:
1811 md_number_to_chars (where
, value
, sizeof (int));
1814 case BFD_RELOC_390_GOT64
:
1815 case BFD_RELOC_390_PLT64
:
1817 md_number_to_chars (where
, value
, 8);
1822 fixp
->fx_r_type
= BFD_RELOC_64_PCREL
;
1824 fixp
->fx_r_type
= BFD_RELOC_64
;
1826 md_number_to_chars (where
, value
, 8);
1829 case BFD_RELOC_64_PCREL
:
1830 fixp
->fx_r_type
= BFD_RELOC_64_PCREL
;
1832 md_number_to_chars (where
, value
, 8);
1835 case BFD_RELOC_VTABLE_INHERIT
:
1836 case BFD_RELOC_VTABLE_ENTRY
:
1842 const char *reloc_name
= bfd_get_reloc_code_name (fixp
->fx_r_type
);
1844 if (reloc_name
!= NULL
)
1845 fprintf (stderr
, "Gas failure, reloc type %s\n", reloc_name
);
1847 fprintf (stderr
, "Gas failure, reloc type #%i\n", fixp
->fx_r_type
);
1853 fixp
->fx_offset
= value
;
1859 /* Generate a reloc for a fixup. */
1862 tc_gen_reloc (seg
, fixp
)
1863 asection
*seg ATTRIBUTE_UNUSED
;
1866 bfd_reloc_code_real_type code
;
1869 code
= fixp
->fx_r_type
;
1870 if (GOT_symbol
&& fixp
->fx_addsy
== GOT_symbol
)
1872 if ((s390_arch_size
== 32 && code
== BFD_RELOC_32_PCREL
) ||
1873 (s390_arch_size
== 64 && code
== BFD_RELOC_64_PCREL
))
1874 code
= BFD_RELOC_390_GOTPC
;
1875 if (code
== BFD_RELOC_390_PC32DBL
)
1876 code
= BFD_RELOC_390_GOTPCDBL
;
1879 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1880 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1881 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1882 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1883 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
1884 if (reloc
->howto
== NULL
)
1886 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1887 _("cannot represent relocation type %s"),
1888 bfd_get_reloc_code_name (code
));
1889 /* Set howto to a garbage value so that we can keep going. */
1890 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_32
);
1891 assert (reloc
->howto
!= NULL
);
1893 reloc
->addend
= fixp
->fx_offset
;