1 /* tc-s390.c -- Assemble for the S390
2 Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
3 2009, 2010 Free Software Foundation, Inc.
4 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
24 #include "safe-ctype.h"
26 #include "struc-symbol.h"
27 #include "dwarf2dbg.h"
28 #include "dw2gencfi.h"
30 #include "opcode/s390.h"
33 /* The default architecture. */
35 #define DEFAULT_ARCH "s390"
37 static char *default_arch
= DEFAULT_ARCH
;
38 /* Either 32 or 64, selects file format. */
39 static int s390_arch_size
= 0;
41 /* If no -march option was given default to the highest available CPU.
42 Since with S/390 a newer CPU always supports everything from its
43 predecessors this will accept every valid asm input. */
44 static unsigned int current_cpu
= S390_OPCODE_MAXCPU
- 1;
45 static unsigned int current_mode_mask
= 0;
47 /* Set to TRUE if the highgprs flag in the ELF header needs to be set
48 for the output file. */
49 static bfd_boolean set_highgprs_p
= FALSE
;
51 /* Whether to use user friendly register names. Default is TRUE. */
52 #ifndef TARGET_REG_NAMES_P
53 #define TARGET_REG_NAMES_P TRUE
56 static bfd_boolean reg_names_p
= TARGET_REG_NAMES_P
;
58 /* Set to TRUE if we want to warn about zero base/index registers. */
59 static bfd_boolean warn_areg_zero
= FALSE
;
61 /* Generic assembler global variables which must be defined by all
64 const char comment_chars
[] = "#";
66 /* Characters which start a comment at the beginning of a line. */
67 const char line_comment_chars
[] = "#";
69 /* Characters which may be used to separate multiple commands on a
71 const char line_separator_chars
[] = ";";
73 /* Characters which are used to indicate an exponent in a floating
75 const char EXP_CHARS
[] = "eE";
77 /* Characters which mean that a number is a floating point constant,
79 const char FLT_CHARS
[] = "dD";
81 /* The dwarf2 data alignment, adjusted for 32 or 64 bit. */
82 int s390_cie_data_alignment
;
84 /* The target specific pseudo-ops which we support. */
86 /* Define the prototypes for the pseudo-ops */
87 static void s390_byte (int);
88 static void s390_elf_cons (int);
89 static void s390_bss (int);
90 static void s390_insn (int);
91 static void s390_literals (int);
92 static void s390_machine (int);
93 static void s390_machinemode (int);
95 const pseudo_typeS md_pseudo_table
[] =
97 { "align", s_align_bytes
, 0 },
98 /* Pseudo-ops which must be defined. */
99 { "bss", s390_bss
, 0 },
100 { "insn", s390_insn
, 0 },
101 /* Pseudo-ops which must be overridden. */
102 { "byte", s390_byte
, 0 },
103 { "short", s390_elf_cons
, 2 },
104 { "long", s390_elf_cons
, 4 },
105 { "quad", s390_elf_cons
, 8 },
106 { "ltorg", s390_literals
, 0 },
107 { "string", stringer
, 8 + 1 },
108 { "machine", s390_machine
, 0 },
109 { "machinemode", s390_machinemode
, 0 },
114 /* Structure to hold information about predefined registers. */
121 /* List of registers that are pre-defined:
123 Each access register has a predefined name of the form:
124 a<reg_num> which has the value <reg_num>.
126 Each control register has a predefined name of the form:
127 c<reg_num> which has the value <reg_num>.
129 Each general register has a predefined name of the form:
130 r<reg_num> which has the value <reg_num>.
132 Each floating point register a has predefined name of the form:
133 f<reg_num> which has the value <reg_num>.
135 There are individual registers as well:
139 The table is sorted. Suitable for searching by a binary search. */
141 static const struct pd_reg pre_defined_registers
[] =
143 { "a0", 0 }, /* Access registers */
160 { "c0", 0 }, /* Control registers */
177 { "f0", 0 }, /* Floating point registers */
194 { "lit", 13 }, /* Pointer to literal pool */
196 { "r0", 0 }, /* General purpose registers */
213 { "sp", 15 }, /* Stack pointer */
217 #define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg))
219 /* Given NAME, find the register number associated with that name, return
220 the integer value associated with the given name or -1 on failure. */
223 reg_name_search (const struct pd_reg
*regs
, int regcount
, const char *name
)
225 int middle
, low
, high
;
233 middle
= (low
+ high
) / 2;
234 cmp
= strcasecmp (name
, regs
[middle
].name
);
240 return regs
[middle
].value
;
249 * Summary of register_name().
251 * in: Input_line_pointer points to 1st char of operand.
253 * out: A expressionS.
254 * The operand may have been a register: in this case, X_op == O_register,
255 * X_add_number is set to the register number, and truth is returned.
256 * Input_line_pointer->(next non-blank) char after operand, or is in its
261 register_name (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
= NULL
;
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 int md_short_jump_size
= 4;
313 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 if not specified by an option. */
325 init_default_arch (void)
327 if (strcmp (default_arch
, "s390") == 0)
329 if (s390_arch_size
== 0)
332 else if (strcmp (default_arch
, "s390x") == 0)
334 if (s390_arch_size
== 0)
338 as_fatal (_("Invalid default architecture, broken assembler."));
340 if (current_mode_mask
== 0)
342 /* Default to z/Architecture mode if the CPU supports it. */
343 if (current_cpu
< S390_OPCODE_Z900
)
344 current_mode_mask
= 1 << S390_OPCODE_ESA
;
346 current_mode_mask
= 1 << S390_OPCODE_ZARCH
;
350 /* Called by TARGET_FORMAT. */
352 s390_target_format (void)
354 /* We don't get a chance to initialize anything before we're called,
355 so handle that now. */
356 init_default_arch ();
358 return s390_arch_size
== 64 ? "elf64-s390" : "elf32-s390";
361 /* Map a CPU string as given with -march= or .machine to the
362 respective enum s390_opcode_cpu_val value. 0xffffffff is returned
363 in case of an error. */
366 s390_parse_cpu (char *arg
)
368 if (strcmp (arg
, "g5") == 0)
369 return S390_OPCODE_G5
;
370 else if (strcmp (arg
, "g6") == 0)
371 return S390_OPCODE_G6
;
372 else if (strcmp (arg
, "z900") == 0)
373 return S390_OPCODE_Z900
;
374 else if (strcmp (arg
, "z990") == 0)
375 return S390_OPCODE_Z990
;
376 else if (strcmp (arg
, "z9-109") == 0)
377 return S390_OPCODE_Z9_109
;
378 else if (strcmp (arg
, "z9-ec") == 0)
379 return S390_OPCODE_Z9_EC
;
380 else if (strcmp (arg
, "z10") == 0)
381 return S390_OPCODE_Z10
;
382 else if (strcmp (arg
, "z196") == 0)
383 return S390_OPCODE_Z196
;
384 else if (strcmp (arg
, "zEC12") == 0)
385 return S390_OPCODE_ZEC12
;
386 else if (strcmp (arg
, "all") == 0)
387 return S390_OPCODE_MAXCPU
- 1;
393 md_parse_option (int c
, char *arg
)
397 /* -k: Ignore for FreeBSD compatibility. */
401 if (arg
!= NULL
&& strcmp (arg
, "regnames") == 0)
404 else if (arg
!= NULL
&& strcmp (arg
, "no-regnames") == 0)
407 else if (arg
!= NULL
&& strcmp (arg
, "warn-areg-zero") == 0)
408 warn_areg_zero
= TRUE
;
410 else if (arg
!= NULL
&& strcmp (arg
, "31") == 0)
413 else if (arg
!= NULL
&& strcmp (arg
, "64") == 0)
416 else if (arg
!= NULL
&& strcmp (arg
, "esa") == 0)
417 current_mode_mask
= 1 << S390_OPCODE_ESA
;
419 else if (arg
!= NULL
&& strcmp (arg
, "zarch") == 0)
421 if (s390_arch_size
== 32)
422 set_highgprs_p
= TRUE
;
423 current_mode_mask
= 1 << S390_OPCODE_ZARCH
;
426 else if (arg
!= NULL
&& strncmp (arg
, "arch=", 5) == 0)
428 current_cpu
= s390_parse_cpu (arg
+ 5);
430 if (current_cpu
== (unsigned int)-1)
432 as_bad (_("invalid switch -m%s"), arg
);
439 as_bad (_("invalid switch -m%s"), arg
);
445 /* Option -A is deprecated. Still available for compatibility. */
446 if (arg
!= NULL
&& strcmp (arg
, "esa") == 0)
447 current_cpu
= S390_OPCODE_G5
;
448 else if (arg
!= NULL
&& strcmp (arg
, "esame") == 0)
449 current_cpu
= S390_OPCODE_Z900
;
451 as_bad (_("invalid architecture -A%s"), arg
);
454 /* -V: SVR4 argument to print version ID. */
459 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
460 should be emitted or not. FIXME: Not implemented. */
472 md_show_usage (FILE *stream
)
474 fprintf (stream
, _("\
476 -mregnames Allow symbolic names for registers\n\
477 -mwarn-areg-zero Warn about zero base/index registers\n\
478 -mno-regnames Do not allow symbolic names for registers\n\
479 -m31 Set file format to 31 bit format\n\
480 -m64 Set file format to 64 bit format\n"));
481 fprintf (stream
, _("\
482 -V print assembler version number\n\
483 -Qy, -Qn ignored\n"));
486 /* Generate the hash table mapping mnemonics to struct s390_opcode.
487 This table is built at startup and whenever the CPU level is
488 changed using .machine. */
491 s390_setup_opcodes (void)
493 register const struct s390_opcode
*op
;
494 const struct s390_opcode
*op_end
;
495 bfd_boolean dup_insn
= FALSE
;
498 if (s390_opcode_hash
!= NULL
)
499 hash_die (s390_opcode_hash
);
501 /* Insert the opcodes into a hash table. */
502 s390_opcode_hash
= hash_new ();
504 op_end
= s390_opcodes
+ s390_num_opcodes
;
505 for (op
= s390_opcodes
; op
< op_end
; op
++)
507 while (op
< op_end
- 1 && strcmp(op
->name
, op
[1].name
) == 0)
509 if (op
->min_cpu
<= current_cpu
&& (op
->modes
& current_mode_mask
))
514 if (op
->min_cpu
<= current_cpu
&& (op
->modes
& current_mode_mask
))
516 retval
= hash_insert (s390_opcode_hash
, op
->name
, (void *) op
);
517 if (retval
!= (const char *) NULL
)
519 as_bad (_("Internal assembler error for instruction %s"),
525 while (op
< op_end
- 1 && strcmp (op
->name
, op
[1].name
) == 0)
533 /* This function is called when the assembler starts up. It is called
534 after the options have been parsed and the output file has been
540 register const struct s390_opcode
*op
;
541 const struct s390_opcode
*op_end
;
544 /* Give a warning if the combination -m64-bit and -Aesa is used. */
545 if (s390_arch_size
== 64 && current_cpu
< S390_OPCODE_Z900
)
546 as_warn (_("The 64 bit file format is used without esame instructions."));
548 s390_cie_data_alignment
= -s390_arch_size
/ 8;
550 /* Set the ELF flags if desired. */
552 bfd_set_private_flags (stdoutput
, s390_flags
);
554 /* Insert the opcode formats into a hash table. */
555 s390_opformat_hash
= hash_new ();
557 op_end
= s390_opformats
+ s390_num_opformats
;
558 for (op
= s390_opformats
; op
< op_end
; op
++)
560 retval
= hash_insert (s390_opformat_hash
, op
->name
, (void *) op
);
561 if (retval
!= (const char *) NULL
)
562 as_bad (_("Internal assembler error for instruction format %s"),
566 s390_setup_opcodes ();
568 record_alignment (text_section
, 2);
569 record_alignment (data_section
, 2);
570 record_alignment (bss_section
, 2);
573 /* Called after all assembly has been done. */
577 if (s390_arch_size
== 64)
578 bfd_set_arch_mach (stdoutput
, bfd_arch_s390
, bfd_mach_s390_64
);
580 bfd_set_arch_mach (stdoutput
, bfd_arch_s390
, bfd_mach_s390_31
);
583 /* Insert an operand value into an instruction. */
586 s390_insert_operand (unsigned char *insn
,
587 const struct s390_operand
*operand
,
595 if (operand
->flags
& (S390_OPERAND_SIGNED
|S390_OPERAND_PCREL
))
599 max
= ((offsetT
) 1 << (operand
->bits
- 1)) - 1;
600 min
= - ((offsetT
) 1 << (operand
->bits
- 1));
601 /* Halve PCREL operands. */
602 if (operand
->flags
& S390_OPERAND_PCREL
)
604 /* Check for underflow / overflow. */
605 if (val
< min
|| val
> max
)
608 _("operand out of range (%s not between %ld and %ld)");
611 if (operand
->flags
& S390_OPERAND_PCREL
)
617 sprint_value (buf
, val
);
618 if (file
== (char *) NULL
)
619 as_bad (err
, buf
, (int) min
, (int) max
);
621 as_bad_where (file
, line
, err
, buf
, (int) min
, (int) max
);
624 /* val is ok, now restrict it to operand->bits bits. */
625 uval
= (addressT
) val
& ((((addressT
) 1 << (operand
->bits
-1)) << 1) - 1);
626 /* val is restrict, now check for special case. */
627 if (operand
->bits
== 20 && operand
->shift
== 20)
628 uval
= (uval
>> 12) | ((uval
& 0xfff) << 8);
634 max
= (((addressT
) 1 << (operand
->bits
- 1)) << 1) - 1;
636 uval
= (addressT
) val
;
637 /* Length x in an instructions has real length x+1. */
638 if (operand
->flags
& S390_OPERAND_LENGTH
)
640 /* Check for underflow / overflow. */
641 if (uval
< min
|| uval
> max
)
643 if (operand
->flags
& S390_OPERAND_LENGTH
)
650 as_bad_value_out_of_range (_("operand"), uval
, (offsetT
) min
, (offsetT
) max
, file
, line
);
656 /* Insert fragments of the operand byte for byte. */
657 offset
= operand
->shift
+ operand
->bits
;
658 uval
<<= (-offset
) & 7;
659 insn
+= (offset
- 1) / 8;
671 bfd_reloc_code_real_type reloc
;
674 /* Parse tls marker and return the desired relocation. */
675 static bfd_reloc_code_real_type
676 s390_tls_suffix (char **str_p
, expressionS
*exp_p
)
678 static struct map_tls mapping
[] =
680 { "tls_load", 8, BFD_RELOC_390_TLS_LOAD
},
681 { "tls_gdcall", 10, BFD_RELOC_390_TLS_GDCALL
},
682 { "tls_ldcall", 10, BFD_RELOC_390_TLS_LDCALL
},
683 { NULL
, 0, BFD_RELOC_UNUSED
}
693 return BFD_RELOC_UNUSED
;
696 while (ISIDNUM (*str
))
700 return BFD_RELOC_UNUSED
;
702 orig_line
= input_line_pointer
;
703 input_line_pointer
= str
;
705 str
= input_line_pointer
;
706 if (&input_line_pointer
!= str_p
)
707 input_line_pointer
= orig_line
;
709 if (exp_p
->X_op
!= O_symbol
)
710 return BFD_RELOC_UNUSED
;
712 for (ptr
= &mapping
[0]; ptr
->length
> 0; ptr
++)
713 if (len
== ptr
->length
714 && strncasecmp (ident
, ptr
->string
, ptr
->length
) == 0)
716 /* Found a matching tls suffix. */
720 return BFD_RELOC_UNUSED
;
723 /* Structure used to hold suffixes. */
734 ELF_SUFFIX_TLS_GOTIE
,
746 elf_suffix_type suffix
;
750 /* Parse @got/@plt/@gotoff. and return the desired relocation. */
751 static elf_suffix_type
752 s390_elf_suffix (char **str_p
, expressionS
*exp_p
)
754 static struct map_bfd mapping
[] =
756 { "got", 3, ELF_SUFFIX_GOT
},
757 { "got12", 5, ELF_SUFFIX_GOT
},
758 { "plt", 3, ELF_SUFFIX_PLT
},
759 { "gotent", 6, ELF_SUFFIX_GOTENT
},
760 { "gotoff", 6, ELF_SUFFIX_GOTOFF
},
761 { "gotplt", 6, ELF_SUFFIX_GOTPLT
},
762 { "pltoff", 6, ELF_SUFFIX_PLTOFF
},
763 { "tlsgd", 5, ELF_SUFFIX_TLS_GD
},
764 { "gotntpoff", 9, ELF_SUFFIX_TLS_GOTIE
},
765 { "indntpoff", 9, ELF_SUFFIX_TLS_IE
},
766 { "tlsldm", 6, ELF_SUFFIX_TLS_LDM
},
767 { "dtpoff", 6, ELF_SUFFIX_TLS_LDO
},
768 { "ntpoff", 6, ELF_SUFFIX_TLS_LE
},
769 { NULL
, 0, ELF_SUFFIX_NONE
}
778 return ELF_SUFFIX_NONE
;
781 while (ISALNUM (*str
))
785 for (ptr
= &mapping
[0]; ptr
->length
> 0; ptr
++)
786 if (len
== ptr
->length
787 && strncasecmp (ident
, ptr
->string
, ptr
->length
) == 0)
789 if (exp_p
->X_add_number
!= 0)
790 as_warn (_("identifier+constant@%s means identifier@%s+constant"),
791 ptr
->string
, ptr
->string
);
792 /* Now check for identifier@suffix+constant. */
793 if (*str
== '-' || *str
== '+')
795 char *orig_line
= input_line_pointer
;
798 input_line_pointer
= str
;
799 expression (&new_exp
);
801 switch (new_exp
.X_op
)
803 case O_constant
: /* X_add_number (a constant expression). */
804 exp_p
->X_add_number
+= new_exp
.X_add_number
;
805 str
= input_line_pointer
;
807 case O_symbol
: /* X_add_symbol + X_add_number. */
808 /* this case is used for e.g. xyz@PLT+.Label. */
809 exp_p
->X_add_number
+= new_exp
.X_add_number
;
810 exp_p
->X_op_symbol
= new_exp
.X_add_symbol
;
812 str
= input_line_pointer
;
814 case O_uminus
: /* (- X_add_symbol) + X_add_number. */
815 /* this case is used for e.g. xyz@PLT-.Label. */
816 exp_p
->X_add_number
+= new_exp
.X_add_number
;
817 exp_p
->X_op_symbol
= new_exp
.X_add_symbol
;
818 exp_p
->X_op
= O_subtract
;
819 str
= input_line_pointer
;
825 /* If s390_elf_suffix has not been called with
826 &input_line_pointer as first parameter, we have
827 clobbered the input_line_pointer. We have to
829 if (&input_line_pointer
!= str_p
)
830 input_line_pointer
= orig_line
;
836 return BFD_RELOC_UNUSED
;
839 /* Structure used to hold a literal pool entry. */
842 struct s390_lpe
*next
;
844 FLONUM_TYPE floatnum
; /* used if X_op == O_big && X_add_number <= 0 */
845 LITTLENUM_TYPE bignum
[4]; /* used if X_op == O_big && X_add_number > 0 */
847 bfd_reloc_code_real_type reloc
;
851 static struct s390_lpe
*lpe_free_list
= NULL
;
852 static struct s390_lpe
*lpe_list
= NULL
;
853 static struct s390_lpe
*lpe_list_tail
= NULL
;
854 static symbolS
*lp_sym
= NULL
;
855 static int lp_count
= 0;
856 static int lpe_count
= 0;
859 s390_exp_compare (expressionS
*exp1
, expressionS
*exp2
)
861 if (exp1
->X_op
!= exp2
->X_op
)
866 case O_constant
: /* X_add_number must be equal. */
868 return exp1
->X_add_number
== exp2
->X_add_number
;
871 as_bad (_("Can't handle O_big in s390_exp_compare"));
873 case O_symbol
: /* X_add_symbol & X_add_number must be equal. */
878 return (exp1
->X_add_symbol
== exp2
->X_add_symbol
)
879 && (exp1
->X_add_number
== exp2
->X_add_number
);
881 case O_multiply
: /* X_add_symbol,X_op_symbol&X_add_number must be equal. */
886 case O_bit_inclusive_or
:
888 case O_bit_exclusive_or
:
900 return (exp1
->X_add_symbol
== exp2
->X_add_symbol
)
901 && (exp1
->X_op_symbol
== exp2
->X_op_symbol
)
902 && (exp1
->X_add_number
== exp2
->X_add_number
);
908 /* Test for @lit and if its present make an entry in the literal pool and
909 modify the current expression to be an offset into the literal pool. */
910 static elf_suffix_type
911 s390_lit_suffix (char **str_p
, expressionS
*exp_p
, elf_suffix_type suffix
)
913 bfd_reloc_code_real_type reloc
;
917 struct s390_lpe
*lpe
;
921 return suffix
; /* No modification. */
923 /* We look for a suffix of the form "@lit1", "@lit2", "@lit4" or "@lit8". */
925 while (ISALNUM (*str
))
928 if (len
!= 4 || strncasecmp (ident
, "lit", 3) != 0
929 || (ident
[3]!='1' && ident
[3]!='2' && ident
[3]!='4' && ident
[3]!='8'))
930 return suffix
; /* no modification */
931 nbytes
= ident
[3] - '0';
933 reloc
= BFD_RELOC_UNUSED
;
934 if (suffix
== ELF_SUFFIX_GOT
)
937 reloc
= BFD_RELOC_390_GOT16
;
938 else if (nbytes
== 4)
939 reloc
= BFD_RELOC_32_GOT_PCREL
;
940 else if (nbytes
== 8)
941 reloc
= BFD_RELOC_390_GOT64
;
943 else if (suffix
== ELF_SUFFIX_PLT
)
946 reloc
= BFD_RELOC_390_PLT32
;
947 else if (nbytes
== 8)
948 reloc
= BFD_RELOC_390_PLT64
;
951 if (suffix
!= ELF_SUFFIX_NONE
&& reloc
== BFD_RELOC_UNUSED
)
952 as_bad (_("Invalid suffix for literal pool entry"));
954 /* Search the pool if the new entry is a duplicate. */
955 if (exp_p
->X_op
== O_big
)
957 /* Special processing for big numbers. */
958 for (lpe
= lpe_list
; lpe
!= NULL
; lpe
= lpe
->next
)
960 if (lpe
->ex
.X_op
== O_big
)
962 if (exp_p
->X_add_number
<= 0 && lpe
->ex
.X_add_number
<= 0)
964 if (memcmp (&generic_floating_point_number
, &lpe
->floatnum
,
965 sizeof (FLONUM_TYPE
)) == 0)
968 else if (exp_p
->X_add_number
== lpe
->ex
.X_add_number
)
970 if (memcmp (generic_bignum
, lpe
->bignum
,
971 sizeof (LITTLENUM_TYPE
)*exp_p
->X_add_number
) == 0)
979 /* Processing for 'normal' data types. */
980 for (lpe
= lpe_list
; lpe
!= NULL
; lpe
= lpe
->next
)
981 if (lpe
->nbytes
== nbytes
&& lpe
->reloc
== reloc
982 && s390_exp_compare (exp_p
, &lpe
->ex
) != 0)
989 if (lpe_free_list
!= NULL
)
992 lpe_free_list
= lpe_free_list
->next
;
996 lpe
= (struct s390_lpe
*) xmalloc (sizeof (struct s390_lpe
));
1001 if (exp_p
->X_op
== O_big
)
1003 if (exp_p
->X_add_number
<= 0)
1004 lpe
->floatnum
= generic_floating_point_number
;
1005 else if (exp_p
->X_add_number
<= 4)
1006 memcpy (lpe
->bignum
, generic_bignum
,
1007 exp_p
->X_add_number
* sizeof (LITTLENUM_TYPE
));
1009 as_bad (_("Big number is too big"));
1012 lpe
->nbytes
= nbytes
;
1014 /* Literal pool name defined ? */
1017 sprintf (tmp_name
, ".L\001%i", lp_count
);
1018 lp_sym
= symbol_make (tmp_name
);
1021 /* Make name for literal pool entry. */
1022 sprintf (tmp_name
, ".L\001%i\002%i", lp_count
, lpe_count
);
1024 lpe
->sym
= symbol_make (tmp_name
);
1026 /* Add to literal pool list. */
1028 if (lpe_list_tail
!= NULL
)
1030 lpe_list_tail
->next
= lpe
;
1031 lpe_list_tail
= lpe
;
1034 lpe_list
= lpe_list_tail
= lpe
;
1037 /* Now change exp_p to the offset into the literal pool.
1038 Thats the expression: .L^Ax^By-.L^Ax */
1039 exp_p
->X_add_symbol
= lpe
->sym
;
1040 exp_p
->X_op_symbol
= lp_sym
;
1041 exp_p
->X_op
= O_subtract
;
1042 exp_p
->X_add_number
= 0;
1046 /* We change the suffix type to ELF_SUFFIX_NONE, because
1047 the difference of two local labels is just a number. */
1048 return ELF_SUFFIX_NONE
;
1051 /* Like normal .long/.short/.word, except support @got, etc.
1052 clobbers input_line_pointer, checks end-of-line. */
1054 s390_elf_cons (int nbytes
/* 1=.byte, 2=.word, 4=.long */)
1057 elf_suffix_type suffix
;
1059 if (is_it_end_of_statement ())
1061 demand_empty_rest_of_line ();
1069 if (exp
.X_op
== O_symbol
1070 && *input_line_pointer
== '@'
1071 && (suffix
= s390_elf_suffix (&input_line_pointer
, &exp
)) != ELF_SUFFIX_NONE
)
1073 bfd_reloc_code_real_type reloc
;
1074 reloc_howto_type
*reloc_howto
;
1080 static bfd_reloc_code_real_type tab2
[] =
1082 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_NONE */
1083 BFD_RELOC_390_GOT16
, /* ELF_SUFFIX_GOT */
1084 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_PLT */
1085 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_GOTENT */
1086 BFD_RELOC_16_GOTOFF
, /* ELF_SUFFIX_GOTOFF */
1087 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_GOTPLT */
1088 BFD_RELOC_390_PLTOFF16
, /* ELF_SUFFIX_PLTOFF */
1089 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_TLS_GD */
1090 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_TLS_GOTIE */
1091 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_TLS_IE */
1092 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_TLS_LDM */
1093 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_TLS_LDO */
1094 BFD_RELOC_UNUSED
/* ELF_SUFFIX_TLS_LE */
1096 reloc
= tab2
[suffix
];
1098 else if (nbytes
== 4)
1100 static bfd_reloc_code_real_type tab4
[] =
1102 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_NONE */
1103 BFD_RELOC_32_GOT_PCREL
, /* ELF_SUFFIX_GOT */
1104 BFD_RELOC_390_PLT32
, /* ELF_SUFFIX_PLT */
1105 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_GOTENT */
1106 BFD_RELOC_32_GOTOFF
, /* ELF_SUFFIX_GOTOFF */
1107 BFD_RELOC_390_GOTPLT32
, /* ELF_SUFFIX_GOTPLT */
1108 BFD_RELOC_390_PLTOFF32
, /* ELF_SUFFIX_PLTOFF */
1109 BFD_RELOC_390_TLS_GD32
, /* ELF_SUFFIX_TLS_GD */
1110 BFD_RELOC_390_TLS_GOTIE32
, /* ELF_SUFFIX_TLS_GOTIE */
1111 BFD_RELOC_390_TLS_IE32
, /* ELF_SUFFIX_TLS_IE */
1112 BFD_RELOC_390_TLS_LDM32
, /* ELF_SUFFIX_TLS_LDM */
1113 BFD_RELOC_390_TLS_LDO32
, /* ELF_SUFFIX_TLS_LDO */
1114 BFD_RELOC_390_TLS_LE32
/* ELF_SUFFIX_TLS_LE */
1116 reloc
= tab4
[suffix
];
1118 else if (nbytes
== 8)
1120 static bfd_reloc_code_real_type tab8
[] =
1122 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_NONE */
1123 BFD_RELOC_390_GOT64
, /* ELF_SUFFIX_GOT */
1124 BFD_RELOC_390_PLT64
, /* ELF_SUFFIX_PLT */
1125 BFD_RELOC_UNUSED
, /* ELF_SUFFIX_GOTENT */
1126 BFD_RELOC_390_GOTOFF64
, /* ELF_SUFFIX_GOTOFF */
1127 BFD_RELOC_390_GOTPLT64
, /* ELF_SUFFIX_GOTPLT */
1128 BFD_RELOC_390_PLTOFF64
, /* ELF_SUFFIX_PLTOFF */
1129 BFD_RELOC_390_TLS_GD64
, /* ELF_SUFFIX_TLS_GD */
1130 BFD_RELOC_390_TLS_GOTIE64
, /* ELF_SUFFIX_TLS_GOTIE */
1131 BFD_RELOC_390_TLS_IE64
, /* ELF_SUFFIX_TLS_IE */
1132 BFD_RELOC_390_TLS_LDM64
, /* ELF_SUFFIX_TLS_LDM */
1133 BFD_RELOC_390_TLS_LDO64
, /* ELF_SUFFIX_TLS_LDO */
1134 BFD_RELOC_390_TLS_LE64
/* ELF_SUFFIX_TLS_LE */
1136 reloc
= tab8
[suffix
];
1139 reloc
= BFD_RELOC_UNUSED
;
1141 if (reloc
!= BFD_RELOC_UNUSED
1142 && (reloc_howto
= bfd_reloc_type_lookup (stdoutput
, reloc
)))
1144 size
= bfd_get_reloc_size (reloc_howto
);
1146 as_bad (_("%s relocations do not fit in %d bytes"),
1147 reloc_howto
->name
, nbytes
);
1148 where
= frag_more (nbytes
);
1149 md_number_to_chars (where
, 0, size
);
1150 /* To make fixup_segment do the pc relative conversion the
1151 pcrel parameter on the fix_new_exp call needs to be FALSE. */
1152 fix_new_exp (frag_now
, where
- frag_now
->fr_literal
,
1153 size
, &exp
, FALSE
, reloc
);
1156 as_bad (_("relocation not applicable"));
1159 emit_expr (&exp
, (unsigned int) nbytes
);
1161 while (*input_line_pointer
++ == ',');
1163 input_line_pointer
--; /* Put terminator back into stream. */
1164 demand_empty_rest_of_line ();
1167 /* We need to keep a list of fixups. We can't simply generate them as
1168 we go, because that would require us to first create the frag, and
1169 that would screw up references to ``.''. */
1175 bfd_reloc_code_real_type reloc
;
1178 #define MAX_INSN_FIXUPS (4)
1180 /* This routine is called for each instruction to be assembled. */
1183 md_gather_operands (char *str
,
1184 unsigned char *insn
,
1185 const struct s390_opcode
*opcode
)
1187 struct s390_fixup fixups
[MAX_INSN_FIXUPS
];
1188 const struct s390_operand
*operand
;
1189 const unsigned char *opindex_ptr
;
1191 elf_suffix_type suffix
;
1192 bfd_reloc_code_real_type reloc
;
1197 while (ISSPACE (*str
))
1202 /* Gather the operands. */
1204 for (opindex_ptr
= opcode
->operands
; *opindex_ptr
!= 0; opindex_ptr
++)
1208 operand
= s390_operands
+ *opindex_ptr
;
1210 if (skip_optional
&& (operand
->flags
& S390_OPERAND_INDEX
))
1212 /* We do an early skip. For D(X,B) constructions the index
1213 register is skipped (X is optional). For D(L,B) the base
1214 register will be the skipped operand, because L is NOT
1220 /* Gather the operand. */
1221 hold
= input_line_pointer
;
1222 input_line_pointer
= str
;
1224 /* Parse the operand. */
1225 if (! register_name (&ex
))
1228 str
= input_line_pointer
;
1229 input_line_pointer
= hold
;
1231 /* Write the operand to the insn. */
1232 if (ex
.X_op
== O_illegal
)
1233 as_bad (_("illegal operand"));
1234 else if (ex
.X_op
== O_absent
)
1236 /* No operands, check if all operands can be skipped. */
1237 while (*opindex_ptr
!= 0 && operand
->flags
& S390_OPERAND_OPTIONAL
)
1239 if (operand
->flags
& S390_OPERAND_DISP
)
1241 /* An optional displacement makes the whole D(X,B)
1242 D(L,B) or D(B) block optional. */
1244 operand
= s390_operands
+ *(++opindex_ptr
);
1245 } while (!(operand
->flags
& S390_OPERAND_BASE
));
1247 operand
= s390_operands
+ *(++opindex_ptr
);
1249 if (opindex_ptr
[0] == '\0')
1251 as_bad (_("missing operand"));
1253 else if (ex
.X_op
== O_register
|| ex
.X_op
== O_constant
)
1255 s390_lit_suffix (&str
, &ex
, ELF_SUFFIX_NONE
);
1257 if (ex
.X_op
!= O_register
&& ex
.X_op
!= O_constant
)
1259 /* We need to generate a fixup for the
1260 expression returned by s390_lit_suffix. */
1261 if (fc
>= MAX_INSN_FIXUPS
)
1262 as_fatal (_("too many fixups"));
1263 fixups
[fc
].exp
= ex
;
1264 fixups
[fc
].opindex
= *opindex_ptr
;
1265 fixups
[fc
].reloc
= BFD_RELOC_UNUSED
;
1270 if ((operand
->flags
& S390_OPERAND_INDEX
)
1271 && ex
.X_add_number
== 0
1273 as_warn (_("index register specified but zero"));
1274 if ((operand
->flags
& S390_OPERAND_BASE
)
1275 && ex
.X_add_number
== 0
1277 as_warn (_("base register specified but zero"));
1278 if ((operand
->flags
& S390_OPERAND_GPR
)
1279 && (operand
->flags
& S390_OPERAND_REG_PAIR
)
1280 && (ex
.X_add_number
& 1))
1281 as_fatal (_("odd numbered general purpose register specified as "
1283 if ((operand
->flags
& S390_OPERAND_FPR
)
1284 && (operand
->flags
& S390_OPERAND_REG_PAIR
)
1285 && ex
.X_add_number
!= 0 && ex
.X_add_number
!= 1
1286 && ex
.X_add_number
!= 4 && ex
.X_add_number
!= 5
1287 && ex
.X_add_number
!= 8 && ex
.X_add_number
!= 9
1288 && ex
.X_add_number
!= 12 && ex
.X_add_number
!= 13)
1289 as_fatal (_("invalid floating point register pair. Valid fp "
1290 "register pair operands are 0, 1, 4, 5, 8, 9, "
1292 s390_insert_operand (insn
, operand
, ex
.X_add_number
, NULL
, 0);
1297 suffix
= s390_elf_suffix (&str
, &ex
);
1298 suffix
= s390_lit_suffix (&str
, &ex
, suffix
);
1299 reloc
= BFD_RELOC_UNUSED
;
1301 if (suffix
== ELF_SUFFIX_GOT
)
1303 if ((operand
->flags
& S390_OPERAND_DISP
) &&
1304 (operand
->bits
== 12))
1305 reloc
= BFD_RELOC_390_GOT12
;
1306 else if ((operand
->flags
& S390_OPERAND_DISP
) &&
1307 (operand
->bits
== 20))
1308 reloc
= BFD_RELOC_390_GOT20
;
1309 else if ((operand
->flags
& S390_OPERAND_SIGNED
)
1310 && (operand
->bits
== 16))
1311 reloc
= BFD_RELOC_390_GOT16
;
1312 else if ((operand
->flags
& S390_OPERAND_PCREL
)
1313 && (operand
->bits
== 32))
1314 reloc
= BFD_RELOC_390_GOTENT
;
1316 else if (suffix
== ELF_SUFFIX_PLT
)
1318 if ((operand
->flags
& S390_OPERAND_PCREL
)
1319 && (operand
->bits
== 16))
1320 reloc
= BFD_RELOC_390_PLT16DBL
;
1321 else if ((operand
->flags
& S390_OPERAND_PCREL
)
1322 && (operand
->bits
== 32))
1323 reloc
= BFD_RELOC_390_PLT32DBL
;
1325 else if (suffix
== ELF_SUFFIX_GOTENT
)
1327 if ((operand
->flags
& S390_OPERAND_PCREL
)
1328 && (operand
->bits
== 32))
1329 reloc
= BFD_RELOC_390_GOTENT
;
1331 else if (suffix
== ELF_SUFFIX_GOTOFF
)
1333 if ((operand
->flags
& S390_OPERAND_SIGNED
)
1334 && (operand
->bits
== 16))
1335 reloc
= BFD_RELOC_16_GOTOFF
;
1337 else if (suffix
== ELF_SUFFIX_PLTOFF
)
1339 if ((operand
->flags
& S390_OPERAND_SIGNED
)
1340 && (operand
->bits
== 16))
1341 reloc
= BFD_RELOC_390_PLTOFF16
;
1343 else if (suffix
== ELF_SUFFIX_GOTPLT
)
1345 if ((operand
->flags
& S390_OPERAND_DISP
)
1346 && (operand
->bits
== 12))
1347 reloc
= BFD_RELOC_390_GOTPLT12
;
1348 else if ((operand
->flags
& S390_OPERAND_SIGNED
)
1349 && (operand
->bits
== 16))
1350 reloc
= BFD_RELOC_390_GOTPLT16
;
1351 else if ((operand
->flags
& S390_OPERAND_PCREL
)
1352 && (operand
->bits
== 32))
1353 reloc
= BFD_RELOC_390_GOTPLTENT
;
1355 else if (suffix
== ELF_SUFFIX_TLS_GOTIE
)
1357 if ((operand
->flags
& S390_OPERAND_DISP
)
1358 && (operand
->bits
== 12))
1359 reloc
= BFD_RELOC_390_TLS_GOTIE12
;
1360 else if ((operand
->flags
& S390_OPERAND_DISP
)
1361 && (operand
->bits
== 20))
1362 reloc
= BFD_RELOC_390_TLS_GOTIE20
;
1364 else if (suffix
== ELF_SUFFIX_TLS_IE
)
1366 if ((operand
->flags
& S390_OPERAND_PCREL
)
1367 && (operand
->bits
== 32))
1368 reloc
= BFD_RELOC_390_TLS_IEENT
;
1371 if (suffix
!= ELF_SUFFIX_NONE
&& reloc
== BFD_RELOC_UNUSED
)
1372 as_bad (_("invalid operand suffix"));
1373 /* We need to generate a fixup of type 'reloc' for this
1375 if (fc
>= MAX_INSN_FIXUPS
)
1376 as_fatal (_("too many fixups"));
1377 fixups
[fc
].exp
= ex
;
1378 fixups
[fc
].opindex
= *opindex_ptr
;
1379 fixups
[fc
].reloc
= reloc
;
1383 /* Check the next character. The call to expression has advanced
1384 str past any whitespace. */
1385 if (operand
->flags
& S390_OPERAND_DISP
)
1387 /* After a displacement a block in parentheses can start. */
1390 /* Check if parenthesized block can be skipped. If the next
1391 operand is neiter an optional operand nor a base register
1392 then we have a syntax error. */
1393 operand
= s390_operands
+ *(++opindex_ptr
);
1394 if (!(operand
->flags
& (S390_OPERAND_INDEX
|S390_OPERAND_BASE
)))
1395 as_bad (_("syntax error; missing '(' after displacement"));
1397 /* Ok, skip all operands until S390_OPERAND_BASE. */
1398 while (!(operand
->flags
& S390_OPERAND_BASE
))
1399 operand
= s390_operands
+ *(++opindex_ptr
);
1401 /* If there is a next operand it must be separated by a comma. */
1402 if (opindex_ptr
[1] != '\0')
1406 while (opindex_ptr
[1] != '\0')
1408 operand
= s390_operands
+ *(++opindex_ptr
);
1409 if (operand
->flags
& S390_OPERAND_OPTIONAL
)
1411 as_bad (_("syntax error; expected ,"));
1421 /* We found an opening parentheses. */
1423 for (f
= str
; *f
!= '\0'; f
++)
1424 if (*f
== ',' || *f
== ')')
1426 /* If there is no comma until the closing parentheses OR
1427 there is a comma right after the opening parentheses,
1428 we have to skip optional operands. */
1429 if (*f
== ',' && f
== str
)
1431 /* comma directly after '(' ? */
1436 skip_optional
= (*f
!= ',');
1439 else if (operand
->flags
& S390_OPERAND_BASE
)
1441 /* After the base register the parenthesed block ends. */
1443 as_bad (_("syntax error; missing ')' after base register"));
1445 /* If there is a next operand it must be separated by a comma. */
1446 if (opindex_ptr
[1] != '\0')
1450 while (opindex_ptr
[1] != '\0')
1452 operand
= s390_operands
+ *(++opindex_ptr
);
1453 if (operand
->flags
& S390_OPERAND_OPTIONAL
)
1455 as_bad (_("syntax error; expected ,"));
1465 /* We can find an 'early' closing parentheses in e.g. D(L) instead
1466 of D(L,B). In this case the base register has to be skipped. */
1469 operand
= s390_operands
+ *(++opindex_ptr
);
1471 if (!(operand
->flags
& S390_OPERAND_BASE
))
1472 as_bad (_("syntax error; ')' not allowed here"));
1475 /* If there is a next operand it must be separated by a comma. */
1476 if (opindex_ptr
[1] != '\0')
1480 while (opindex_ptr
[1] != '\0')
1482 operand
= s390_operands
+ *(++opindex_ptr
);
1483 if (operand
->flags
& S390_OPERAND_OPTIONAL
)
1485 as_bad (_("syntax error; expected ,"));
1495 while (ISSPACE (*str
))
1498 /* Check for tls instruction marker. */
1499 reloc
= s390_tls_suffix (&str
, &ex
);
1500 if (reloc
!= BFD_RELOC_UNUSED
)
1502 /* We need to generate a fixup of type 'reloc' for this
1504 if (fc
>= MAX_INSN_FIXUPS
)
1505 as_fatal (_("too many fixups"));
1506 fixups
[fc
].exp
= ex
;
1507 fixups
[fc
].opindex
= -1;
1508 fixups
[fc
].reloc
= reloc
;
1516 if ((linefeed
= strchr (str
, '\n')) != NULL
)
1518 as_bad (_("junk at end of line: `%s'"), str
);
1519 if (linefeed
!= NULL
)
1523 /* Write out the instruction. */
1524 f
= frag_more (opcode
->oplen
);
1525 memcpy (f
, insn
, opcode
->oplen
);
1526 dwarf2_emit_insn (opcode
->oplen
);
1528 /* Create any fixups. At this point we do not use a
1529 bfd_reloc_code_real_type, but instead just use the
1530 BFD_RELOC_UNUSED plus the operand index. This lets us easily
1531 handle fixups for any operand type, although that is admittedly
1532 not a very exciting feature. We pick a BFD reloc type in
1534 for (i
= 0; i
< fc
; i
++)
1537 if (fixups
[i
].opindex
< 0)
1539 /* Create tls instruction marker relocation. */
1540 fix_new_exp (frag_now
, f
- frag_now
->fr_literal
, opcode
->oplen
,
1541 &fixups
[i
].exp
, 0, fixups
[i
].reloc
);
1545 operand
= s390_operands
+ fixups
[i
].opindex
;
1547 if (fixups
[i
].reloc
!= BFD_RELOC_UNUSED
)
1549 reloc_howto_type
*reloc_howto
;
1553 reloc_howto
= bfd_reloc_type_lookup (stdoutput
, fixups
[i
].reloc
);
1557 size
= bfd_get_reloc_size (reloc_howto
);
1559 if (size
< 1 || size
> 4)
1562 fixP
= fix_new_exp (frag_now
,
1563 f
- frag_now
->fr_literal
+ (operand
->shift
/8),
1564 size
, &fixups
[i
].exp
, reloc_howto
->pc_relative
,
1566 /* Turn off overflow checking in fixup_segment. This is necessary
1567 because fixup_segment will signal an overflow for large 4 byte
1568 quantities for GOT12 relocations. */
1569 if ( fixups
[i
].reloc
== BFD_RELOC_390_GOT12
1570 || fixups
[i
].reloc
== BFD_RELOC_390_GOT20
1571 || fixups
[i
].reloc
== BFD_RELOC_390_GOT16
)
1572 fixP
->fx_no_overflow
= 1;
1575 fix_new_exp (frag_now
, f
- frag_now
->fr_literal
, 4, &fixups
[i
].exp
,
1576 (operand
->flags
& S390_OPERAND_PCREL
) != 0,
1577 ((bfd_reloc_code_real_type
)
1578 (fixups
[i
].opindex
+ (int) BFD_RELOC_UNUSED
)));
1583 /* This routine is called for each instruction to be assembled. */
1586 md_assemble (char *str
)
1588 const struct s390_opcode
*opcode
;
1589 unsigned char insn
[6];
1592 /* Get the opcode. */
1593 for (s
= str
; *s
!= '\0' && ! ISSPACE (*s
); s
++)
1598 /* Look up the opcode in the hash table. */
1599 opcode
= (struct s390_opcode
*) hash_find (s390_opcode_hash
, str
);
1600 if (opcode
== (const struct s390_opcode
*) NULL
)
1602 as_bad (_("Unrecognized opcode: `%s'"), str
);
1605 else if (!(opcode
->modes
& current_mode_mask
))
1607 as_bad (_("Opcode %s not available in this mode"), str
);
1610 memcpy (insn
, opcode
->opcode
, sizeof (insn
));
1611 md_gather_operands (s
, insn
, opcode
);
1614 #ifndef WORKING_DOT_WORD
1615 /* Handle long and short jumps. We don't support these */
1617 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1619 addressT from_addr
, to_addr
;
1627 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1629 addressT from_addr
, to_addr
;
1638 s390_bss (int ignore ATTRIBUTE_UNUSED
)
1640 /* We don't support putting frags in the BSS segment, we fake it
1641 by marking in_bss, then looking at s_skip for clues. */
1643 subseg_set (bss_section
, 0);
1644 demand_empty_rest_of_line ();
1647 /* Pseudo-op handling. */
1650 s390_insn (int ignore ATTRIBUTE_UNUSED
)
1653 const struct s390_opcode
*opformat
;
1654 unsigned char insn
[6];
1657 /* Get the opcode format. */
1658 s
= input_line_pointer
;
1659 while (*s
!= '\0' && *s
!= ',' && ! ISSPACE (*s
))
1662 as_bad (_("Invalid .insn format\n"));
1665 /* Look up the opcode in the hash table. */
1666 opformat
= (struct s390_opcode
*)
1667 hash_find (s390_opformat_hash
, input_line_pointer
);
1668 if (opformat
== (const struct s390_opcode
*) NULL
)
1670 as_bad (_("Unrecognized opcode format: `%s'"), input_line_pointer
);
1673 input_line_pointer
= s
;
1675 if (exp
.X_op
== O_constant
)
1677 if ( ( opformat
->oplen
== 6
1678 && (addressT
) exp
.X_add_number
< (1ULL << 48))
1679 || ( opformat
->oplen
== 4
1680 && (addressT
) exp
.X_add_number
< (1ULL << 32))
1681 || ( opformat
->oplen
== 2
1682 && (addressT
) exp
.X_add_number
< (1ULL << 16)))
1683 md_number_to_chars ((char *) insn
, exp
.X_add_number
, opformat
->oplen
);
1685 as_bad (_("Invalid .insn format\n"));
1687 else if (exp
.X_op
== O_big
)
1689 if (exp
.X_add_number
> 0
1690 && opformat
->oplen
== 6
1691 && generic_bignum
[3] == 0)
1693 md_number_to_chars ((char *) insn
, generic_bignum
[2], 2);
1694 md_number_to_chars ((char *) &insn
[2], generic_bignum
[1], 2);
1695 md_number_to_chars ((char *) &insn
[4], generic_bignum
[0], 2);
1698 as_bad (_("Invalid .insn format\n"));
1701 as_bad (_("second operand of .insn not a constant\n"));
1703 if (strcmp (opformat
->name
, "e") != 0 && *input_line_pointer
++ != ',')
1704 as_bad (_("missing comma after insn constant\n"));
1706 if ((s
= strchr (input_line_pointer
, '\n')) != NULL
)
1708 input_line_pointer
= md_gather_operands (input_line_pointer
, insn
,
1712 demand_empty_rest_of_line ();
1715 /* The .byte pseudo-op. This is similar to the normal .byte
1716 pseudo-op, but it can also take a single ASCII string. */
1719 s390_byte (int ignore ATTRIBUTE_UNUSED
)
1721 if (*input_line_pointer
!= '\"')
1727 /* Gather characters. A real double quote is doubled. Unusual
1728 characters are not permitted. */
1729 ++input_line_pointer
;
1734 c
= *input_line_pointer
++;
1738 if (*input_line_pointer
!= '\"')
1740 ++input_line_pointer
;
1743 FRAG_APPEND_1_CHAR (c
);
1746 demand_empty_rest_of_line ();
1749 /* The .ltorg pseudo-op.This emits all literals defined since the last
1750 .ltorg or the invocation of gas. Literals are defined with the
1754 s390_literals (int ignore ATTRIBUTE_UNUSED
)
1756 struct s390_lpe
*lpe
;
1758 if (lp_sym
== NULL
|| lpe_count
== 0)
1759 return; /* Nothing to be done. */
1761 /* Emit symbol for start of literal pool. */
1762 S_SET_SEGMENT (lp_sym
, now_seg
);
1763 S_SET_VALUE (lp_sym
, (valueT
) frag_now_fix ());
1764 lp_sym
->sy_frag
= frag_now
;
1769 lpe_list
= lpe_list
->next
;
1770 S_SET_SEGMENT (lpe
->sym
, now_seg
);
1771 S_SET_VALUE (lpe
->sym
, (valueT
) frag_now_fix ());
1772 lpe
->sym
->sy_frag
= frag_now
;
1774 /* Emit literal pool entry. */
1775 if (lpe
->reloc
!= BFD_RELOC_UNUSED
)
1777 reloc_howto_type
*reloc_howto
=
1778 bfd_reloc_type_lookup (stdoutput
, lpe
->reloc
);
1779 int size
= bfd_get_reloc_size (reloc_howto
);
1782 if (size
> lpe
->nbytes
)
1783 as_bad (_("%s relocations do not fit in %d bytes"),
1784 reloc_howto
->name
, lpe
->nbytes
);
1785 where
= frag_more (lpe
->nbytes
);
1786 md_number_to_chars (where
, 0, size
);
1787 fix_new_exp (frag_now
, where
- frag_now
->fr_literal
,
1788 size
, &lpe
->ex
, reloc_howto
->pc_relative
, lpe
->reloc
);
1792 if (lpe
->ex
.X_op
== O_big
)
1794 if (lpe
->ex
.X_add_number
<= 0)
1795 generic_floating_point_number
= lpe
->floatnum
;
1797 memcpy (generic_bignum
, lpe
->bignum
,
1798 lpe
->ex
.X_add_number
* sizeof (LITTLENUM_TYPE
));
1800 emit_expr (&lpe
->ex
, lpe
->nbytes
);
1803 lpe
->next
= lpe_free_list
;
1804 lpe_free_list
= lpe
;
1806 lpe_list_tail
= NULL
;
1812 /* The .machine pseudo op allows to switch to a different CPU level in
1813 the asm listing. The current CPU setting can be stored on a stack
1814 with .machine push and restored with .machine pop. */
1817 s390_machine (int ignore ATTRIBUTE_UNUSED
)
1820 #define MAX_HISTORY 100
1821 static unsigned int *cpu_history
;
1822 static int curr_hist
;
1826 if (*input_line_pointer
== '"')
1829 cpu_string
= demand_copy_C_string (&len
);
1834 cpu_string
= input_line_pointer
;
1835 c
= get_symbol_end ();
1836 cpu_string
= xstrdup (cpu_string
);
1837 *input_line_pointer
= c
;
1840 if (cpu_string
!= NULL
)
1842 unsigned int old_cpu
= current_cpu
;
1843 unsigned int new_cpu
;
1846 for (p
= cpu_string
; *p
!= 0; p
++)
1849 if (strcmp (cpu_string
, "push") == 0)
1851 if (cpu_history
== NULL
)
1852 cpu_history
= xmalloc (MAX_HISTORY
* sizeof (*cpu_history
));
1854 if (curr_hist
>= MAX_HISTORY
)
1855 as_bad (_(".machine stack overflow"));
1857 cpu_history
[curr_hist
++] = current_cpu
;
1859 else if (strcmp (cpu_string
, "pop") == 0)
1862 as_bad (_(".machine stack underflow"));
1864 current_cpu
= cpu_history
[--curr_hist
];
1866 else if ((new_cpu
= s390_parse_cpu (cpu_string
)) != (unsigned int)-1)
1867 current_cpu
= new_cpu
;
1869 as_bad (_("invalid machine `%s'"), cpu_string
);
1871 if (current_cpu
!= old_cpu
)
1872 s390_setup_opcodes ();
1875 demand_empty_rest_of_line ();
1878 /* The .machinemode pseudo op allows to switch to a different
1879 architecture mode in the asm listing. The current architecture
1880 mode setting can be stored on a stack with .machinemode push and
1881 restored with .machinemode pop. */
1884 s390_machinemode (int ignore ATTRIBUTE_UNUSED
)
1887 #define MAX_HISTORY 100
1888 static unsigned int *mode_history
;
1889 static int curr_hist
;
1893 if (*input_line_pointer
== '"')
1896 mode_string
= demand_copy_C_string (&len
);
1901 mode_string
= input_line_pointer
;
1902 c
= get_symbol_end ();
1903 mode_string
= xstrdup (mode_string
);
1904 *input_line_pointer
= c
;
1907 if (mode_string
!= NULL
)
1909 unsigned int old_mode_mask
= current_mode_mask
;
1912 for (p
= mode_string
; *p
!= 0; p
++)
1915 if (strcmp (mode_string
, "push") == 0)
1917 if (mode_history
== NULL
)
1918 mode_history
= xmalloc (MAX_HISTORY
* sizeof (*mode_history
));
1920 if (curr_hist
>= MAX_HISTORY
)
1921 as_bad (_(".machinemode stack overflow"));
1923 mode_history
[curr_hist
++] = current_mode_mask
;
1925 else if (strcmp (mode_string
, "pop") == 0)
1928 as_bad (_(".machinemode stack underflow"));
1930 current_mode_mask
= mode_history
[--curr_hist
];
1934 if (strcmp (mode_string
, "esa") == 0)
1935 current_mode_mask
= 1 << S390_OPCODE_ESA
;
1936 else if (strcmp (mode_string
, "zarch") == 0)
1938 if (s390_arch_size
== 32)
1939 set_highgprs_p
= TRUE
;
1940 current_mode_mask
= 1 << S390_OPCODE_ZARCH
;
1942 else if (strcmp (mode_string
, "zarch_nohighgprs") == 0)
1943 current_mode_mask
= 1 << S390_OPCODE_ZARCH
;
1945 as_bad (_("invalid machine `%s'"), mode_string
);
1948 if (current_mode_mask
!= old_mode_mask
)
1949 s390_setup_opcodes ();
1952 demand_empty_rest_of_line ();
1956 md_atof (int type
, char *litp
, int *sizep
)
1958 return ieee_md_atof (type
, litp
, sizep
, TRUE
);
1961 /* Align a section (I don't know why this is machine dependent). */
1964 md_section_align (asection
*seg
, valueT addr
)
1966 int align
= bfd_get_section_alignment (stdoutput
, seg
);
1968 return ((addr
+ (1 << align
) - 1) & (-1 << align
));
1971 /* We don't have any form of relaxing. */
1974 md_estimate_size_before_relax (fragS
*fragp ATTRIBUTE_UNUSED
,
1975 asection
*seg ATTRIBUTE_UNUSED
)
1981 /* Convert a machine dependent frag. We never generate these. */
1984 md_convert_frag (bfd
*abfd ATTRIBUTE_UNUSED
,
1985 asection
*sec ATTRIBUTE_UNUSED
,
1986 fragS
*fragp ATTRIBUTE_UNUSED
)
1992 md_undefined_symbol (char *name
)
1994 if (*name
== '_' && *(name
+ 1) == 'G'
1995 && strcmp (name
, "_GLOBAL_OFFSET_TABLE_") == 0)
1999 if (symbol_find (name
))
2000 as_bad (_("GOT already in symbol table"));
2001 GOT_symbol
= symbol_new (name
, undefined_section
,
2002 (valueT
) 0, &zero_address_frag
);
2009 /* Functions concerning relocs. */
2011 /* The location from which a PC relative jump should be calculated,
2012 given a PC relative reloc. */
2015 md_pcrel_from_section (fixS
*fixp
, segT sec ATTRIBUTE_UNUSED
)
2017 return fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2020 /* Here we decide which fixups can be adjusted to make them relative to
2021 the beginning of the section instead of the symbol. Basically we need
2022 to make sure that the dynamic relocations are done correctly, so in
2023 some cases we force the original symbol to be used. */
2025 tc_s390_fix_adjustable (fixS
*fixP
)
2027 /* Don't adjust references to merge sections. */
2028 if ((S_GET_SEGMENT (fixP
->fx_addsy
)->flags
& SEC_MERGE
) != 0)
2030 /* adjust_reloc_syms doesn't know about the GOT. */
2031 if ( fixP
->fx_r_type
== BFD_RELOC_16_GOTOFF
2032 || fixP
->fx_r_type
== BFD_RELOC_32_GOTOFF
2033 || fixP
->fx_r_type
== BFD_RELOC_390_GOTOFF64
2034 || fixP
->fx_r_type
== BFD_RELOC_390_PLTOFF16
2035 || fixP
->fx_r_type
== BFD_RELOC_390_PLTOFF32
2036 || fixP
->fx_r_type
== BFD_RELOC_390_PLTOFF64
2037 || fixP
->fx_r_type
== BFD_RELOC_390_PLT16DBL
2038 || fixP
->fx_r_type
== BFD_RELOC_390_PLT32
2039 || fixP
->fx_r_type
== BFD_RELOC_390_PLT32DBL
2040 || fixP
->fx_r_type
== BFD_RELOC_390_PLT64
2041 || fixP
->fx_r_type
== BFD_RELOC_390_GOT12
2042 || fixP
->fx_r_type
== BFD_RELOC_390_GOT20
2043 || fixP
->fx_r_type
== BFD_RELOC_390_GOT16
2044 || fixP
->fx_r_type
== BFD_RELOC_32_GOT_PCREL
2045 || fixP
->fx_r_type
== BFD_RELOC_390_GOT64
2046 || fixP
->fx_r_type
== BFD_RELOC_390_GOTENT
2047 || fixP
->fx_r_type
== BFD_RELOC_390_GOTPLT12
2048 || fixP
->fx_r_type
== BFD_RELOC_390_GOTPLT16
2049 || fixP
->fx_r_type
== BFD_RELOC_390_GOTPLT20
2050 || fixP
->fx_r_type
== BFD_RELOC_390_GOTPLT32
2051 || fixP
->fx_r_type
== BFD_RELOC_390_GOTPLT64
2052 || fixP
->fx_r_type
== BFD_RELOC_390_GOTPLTENT
2053 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_LOAD
2054 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_GDCALL
2055 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_LDCALL
2056 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_GD32
2057 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_GD64
2058 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_GOTIE12
2059 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_GOTIE20
2060 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_GOTIE32
2061 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_GOTIE64
2062 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_LDM32
2063 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_LDM64
2064 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_IE32
2065 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_IE64
2066 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_IEENT
2067 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_LE32
2068 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_LE64
2069 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_LDO32
2070 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_LDO64
2071 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_DTPMOD
2072 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_DTPOFF
2073 || fixP
->fx_r_type
== BFD_RELOC_390_TLS_TPOFF
2074 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
2075 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
2080 /* Return true if we must always emit a reloc for a type and false if
2081 there is some hope of resolving it at assembly time. */
2083 tc_s390_force_relocation (struct fix
*fixp
)
2085 /* Ensure we emit a relocation for every reference to the global
2086 offset table or to the procedure link table. */
2087 switch (fixp
->fx_r_type
)
2089 case BFD_RELOC_390_GOT12
:
2090 case BFD_RELOC_390_GOT20
:
2091 case BFD_RELOC_32_GOT_PCREL
:
2092 case BFD_RELOC_32_GOTOFF
:
2093 case BFD_RELOC_390_GOTOFF64
:
2094 case BFD_RELOC_390_PLTOFF16
:
2095 case BFD_RELOC_390_PLTOFF32
:
2096 case BFD_RELOC_390_PLTOFF64
:
2097 case BFD_RELOC_390_GOTPC
:
2098 case BFD_RELOC_390_GOT16
:
2099 case BFD_RELOC_390_GOTPCDBL
:
2100 case BFD_RELOC_390_GOT64
:
2101 case BFD_RELOC_390_GOTENT
:
2102 case BFD_RELOC_390_PLT32
:
2103 case BFD_RELOC_390_PLT16DBL
:
2104 case BFD_RELOC_390_PLT32DBL
:
2105 case BFD_RELOC_390_PLT64
:
2106 case BFD_RELOC_390_GOTPLT12
:
2107 case BFD_RELOC_390_GOTPLT16
:
2108 case BFD_RELOC_390_GOTPLT20
:
2109 case BFD_RELOC_390_GOTPLT32
:
2110 case BFD_RELOC_390_GOTPLT64
:
2111 case BFD_RELOC_390_GOTPLTENT
:
2117 return generic_force_reloc (fixp
);
2120 /* Apply a fixup to the object code. This is called for all the
2121 fixups we generated by the call to fix_new_exp, above. In the call
2122 above we used a reloc code which was the largest legal reloc code
2123 plus the operand index. Here we undo that to recover the operand
2124 index. At this point all symbol values should be fully resolved,
2125 and we attempt to completely resolve the reloc. If we can not do
2126 that, we determine the correct reloc code and put it back in the
2130 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
2133 valueT value
= *valP
;
2135 where
= fixP
->fx_frag
->fr_literal
+ fixP
->fx_where
;
2137 if (fixP
->fx_subsy
!= NULL
)
2138 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
2139 _("cannot emit relocation %s against subsy symbol %s"),
2140 bfd_get_reloc_code_name (fixP
->fx_r_type
),
2141 S_GET_NAME (fixP
->fx_subsy
));
2143 if (fixP
->fx_addsy
!= NULL
)
2146 value
+= fixP
->fx_frag
->fr_address
+ fixP
->fx_where
;
2151 if ((int) fixP
->fx_r_type
>= (int) BFD_RELOC_UNUSED
)
2153 const struct s390_operand
*operand
;
2156 opindex
= (int) fixP
->fx_r_type
- (int) BFD_RELOC_UNUSED
;
2157 operand
= &s390_operands
[opindex
];
2161 /* Insert the fully resolved operand value. */
2162 s390_insert_operand ((unsigned char *) where
, operand
,
2163 (offsetT
) value
, fixP
->fx_file
, fixP
->fx_line
);
2167 /* Determine a BFD reloc value based on the operand information.
2168 We are only prepared to turn a few of the operands into
2170 fixP
->fx_offset
= value
;
2171 if (operand
->bits
== 12 && operand
->shift
== 20)
2174 fixP
->fx_where
+= 2;
2175 fixP
->fx_r_type
= BFD_RELOC_390_12
;
2177 else if (operand
->bits
== 12 && operand
->shift
== 36)
2180 fixP
->fx_where
+= 4;
2181 fixP
->fx_r_type
= BFD_RELOC_390_12
;
2183 else if (operand
->bits
== 20 && operand
->shift
== 20)
2186 fixP
->fx_where
+= 2;
2187 fixP
->fx_r_type
= BFD_RELOC_390_20
;
2189 else if (operand
->bits
== 8 && operand
->shift
== 8)
2192 fixP
->fx_where
+= 1;
2193 fixP
->fx_r_type
= BFD_RELOC_8
;
2195 else if (operand
->bits
== 16 && operand
->shift
== 16)
2198 fixP
->fx_where
+= 2;
2199 if (operand
->flags
& S390_OPERAND_PCREL
)
2201 fixP
->fx_r_type
= BFD_RELOC_390_PC16DBL
;
2202 fixP
->fx_offset
+= 2;
2205 fixP
->fx_r_type
= BFD_RELOC_16
;
2207 else if (operand
->bits
== 32 && operand
->shift
== 16
2208 && (operand
->flags
& S390_OPERAND_PCREL
))
2211 fixP
->fx_where
+= 2;
2212 fixP
->fx_offset
+= 2;
2213 fixP
->fx_r_type
= BFD_RELOC_390_PC32DBL
;
2220 /* Use expr_symbol_where to see if this is an expression
2222 if (expr_symbol_where (fixP
->fx_addsy
, &sfile
, &sline
))
2223 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
2224 _("unresolved expression that must be resolved"));
2226 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
2227 _("unsupported relocation type"));
2234 switch (fixP
->fx_r_type
)
2240 md_number_to_chars (where
, value
, 1);
2242 case BFD_RELOC_390_12
:
2243 case BFD_RELOC_390_GOT12
:
2244 case BFD_RELOC_390_GOTPLT12
:
2249 mop
= bfd_getb16 ((unsigned char *) where
);
2250 mop
|= (unsigned short) (value
& 0xfff);
2251 bfd_putb16 ((bfd_vma
) mop
, (unsigned char *) where
);
2255 case BFD_RELOC_390_20
:
2256 case BFD_RELOC_390_GOT20
:
2257 case BFD_RELOC_390_GOTPLT20
:
2261 mop
= bfd_getb32 ((unsigned char *) where
);
2262 mop
|= (unsigned int) ((value
& 0xfff) << 8 |
2263 (value
& 0xff000) >> 12);
2264 bfd_putb32 ((bfd_vma
) mop
, (unsigned char *) where
);
2269 case BFD_RELOC_GPREL16
:
2270 case BFD_RELOC_16_GOT_PCREL
:
2271 case BFD_RELOC_16_GOTOFF
:
2273 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
2274 _("cannot emit PC relative %s relocation%s%s"),
2275 bfd_get_reloc_code_name (fixP
->fx_r_type
),
2276 fixP
->fx_addsy
!= NULL
? " against " : "",
2277 (fixP
->fx_addsy
!= NULL
2278 ? S_GET_NAME (fixP
->fx_addsy
)
2281 md_number_to_chars (where
, value
, 2);
2283 case BFD_RELOC_390_GOT16
:
2284 case BFD_RELOC_390_PLTOFF16
:
2285 case BFD_RELOC_390_GOTPLT16
:
2287 md_number_to_chars (where
, value
, 2);
2289 case BFD_RELOC_390_PC16DBL
:
2290 case BFD_RELOC_390_PLT16DBL
:
2293 md_number_to_chars (where
, (offsetT
) value
>> 1, 2);
2298 fixP
->fx_r_type
= BFD_RELOC_32_PCREL
;
2300 fixP
->fx_r_type
= BFD_RELOC_32
;
2302 md_number_to_chars (where
, value
, 4);
2304 case BFD_RELOC_32_PCREL
:
2305 case BFD_RELOC_32_BASEREL
:
2306 fixP
->fx_r_type
= BFD_RELOC_32_PCREL
;
2308 md_number_to_chars (where
, value
, 4);
2310 case BFD_RELOC_32_GOT_PCREL
:
2311 case BFD_RELOC_390_PLTOFF32
:
2312 case BFD_RELOC_390_PLT32
:
2313 case BFD_RELOC_390_GOTPLT32
:
2315 md_number_to_chars (where
, value
, 4);
2317 case BFD_RELOC_390_PC32DBL
:
2318 case BFD_RELOC_390_PLT32DBL
:
2319 case BFD_RELOC_390_GOTPCDBL
:
2320 case BFD_RELOC_390_GOTENT
:
2321 case BFD_RELOC_390_GOTPLTENT
:
2324 md_number_to_chars (where
, (offsetT
) value
>> 1, 4);
2327 case BFD_RELOC_32_GOTOFF
:
2329 md_number_to_chars (where
, value
, sizeof (int));
2332 case BFD_RELOC_390_GOTOFF64
:
2334 md_number_to_chars (where
, value
, 8);
2337 case BFD_RELOC_390_GOT64
:
2338 case BFD_RELOC_390_PLTOFF64
:
2339 case BFD_RELOC_390_PLT64
:
2340 case BFD_RELOC_390_GOTPLT64
:
2342 md_number_to_chars (where
, value
, 8);
2347 fixP
->fx_r_type
= BFD_RELOC_64_PCREL
;
2349 fixP
->fx_r_type
= BFD_RELOC_64
;
2351 md_number_to_chars (where
, value
, 8);
2354 case BFD_RELOC_64_PCREL
:
2355 fixP
->fx_r_type
= BFD_RELOC_64_PCREL
;
2357 md_number_to_chars (where
, value
, 8);
2360 case BFD_RELOC_VTABLE_INHERIT
:
2361 case BFD_RELOC_VTABLE_ENTRY
:
2365 case BFD_RELOC_390_TLS_LOAD
:
2366 case BFD_RELOC_390_TLS_GDCALL
:
2367 case BFD_RELOC_390_TLS_LDCALL
:
2368 case BFD_RELOC_390_TLS_GD32
:
2369 case BFD_RELOC_390_TLS_GD64
:
2370 case BFD_RELOC_390_TLS_GOTIE12
:
2371 case BFD_RELOC_390_TLS_GOTIE20
:
2372 case BFD_RELOC_390_TLS_GOTIE32
:
2373 case BFD_RELOC_390_TLS_GOTIE64
:
2374 case BFD_RELOC_390_TLS_LDM32
:
2375 case BFD_RELOC_390_TLS_LDM64
:
2376 case BFD_RELOC_390_TLS_IE32
:
2377 case BFD_RELOC_390_TLS_IE64
:
2378 case BFD_RELOC_390_TLS_LE32
:
2379 case BFD_RELOC_390_TLS_LE64
:
2380 case BFD_RELOC_390_TLS_LDO32
:
2381 case BFD_RELOC_390_TLS_LDO64
:
2382 case BFD_RELOC_390_TLS_DTPMOD
:
2383 case BFD_RELOC_390_TLS_DTPOFF
:
2384 case BFD_RELOC_390_TLS_TPOFF
:
2385 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
2386 /* Fully resolved at link time. */
2388 case BFD_RELOC_390_TLS_IEENT
:
2389 /* Fully resolved at link time. */
2390 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
2396 const char *reloc_name
= bfd_get_reloc_code_name (fixP
->fx_r_type
);
2398 if (reloc_name
!= NULL
)
2399 as_fatal (_("Gas failure, reloc type %s\n"), reloc_name
);
2401 as_fatal (_("Gas failure, reloc type #%i\n"), fixP
->fx_r_type
);
2405 fixP
->fx_offset
= value
;
2409 /* Generate a reloc for a fixup. */
2412 tc_gen_reloc (asection
*seg ATTRIBUTE_UNUSED
, fixS
*fixp
)
2414 bfd_reloc_code_real_type code
;
2417 code
= fixp
->fx_r_type
;
2418 if (GOT_symbol
&& fixp
->fx_addsy
== GOT_symbol
)
2420 if ( (s390_arch_size
== 32 && code
== BFD_RELOC_32_PCREL
)
2421 || (s390_arch_size
== 64 && code
== BFD_RELOC_64_PCREL
))
2422 code
= BFD_RELOC_390_GOTPC
;
2423 if (code
== BFD_RELOC_390_PC32DBL
)
2424 code
= BFD_RELOC_390_GOTPCDBL
;
2427 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
2428 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2429 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2430 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2431 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2432 if (reloc
->howto
== NULL
)
2434 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2435 _("cannot represent relocation type %s"),
2436 bfd_get_reloc_code_name (code
));
2437 /* Set howto to a garbage value so that we can keep going. */
2438 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_32
);
2439 gas_assert (reloc
->howto
!= NULL
);
2441 reloc
->addend
= fixp
->fx_offset
;
2447 s390_cfi_frame_initial_instructions (void)
2449 cfi_add_CFA_def_cfa (15, s390_arch_size
== 64 ? 160 : 96);
2453 tc_s390_regname_to_dw2regnum (char *regname
)
2457 if (regname
[0] != 'c' && regname
[0] != 'a')
2459 regnum
= reg_name_search (pre_defined_registers
, REG_NAME_CNT
, regname
);
2460 if (regname
[0] == 'f' && regnum
!= -1)
2463 else if (strcmp (regname
, "ap") == 0)
2465 else if (strcmp (regname
, "cc") == 0)
2471 s390_elf_final_processing (void)
2474 elf_elfheader (stdoutput
)->e_flags
|= EF_S390_HIGH_GPRS
;