1 /* tc-z8k.c -- Assemble code for the Zilog Z800n
2 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001, 2002
3 Free Software Foundation, Inc.
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
22 /* Written By Steve Chamberlain <sac@cygnus.com>. */
29 #include "safe-ctype.h"
30 #include "opcodes/z8k-opc.h"
32 const char comment_chars
[] = "!";
33 const char line_comment_chars
[] = "#";
34 const char line_separator_chars
[] = ";";
37 extern int coff_flags
;
39 const int md_reloc_size
;
47 machine
= bfd_mach_z8001
;
55 machine
= bfd_mach_z8002
;
63 record_alignment (now_seg
, 1);
66 void obj_coff_section ();
83 if (*input_line_pointer
== '\'')
87 c
= *input_line_pointer
++;
92 c
= (tohex (input_line_pointer
[0]) << 4)
93 | tohex (input_line_pointer
[1]);
94 input_line_pointer
+= 2;
96 FRAG_APPEND_1_CHAR (c
);
97 c
= *input_line_pointer
++;
99 demand_empty_rest_of_line ();
103 /* This table describes all the machine specific pseudo-ops the assembler
104 has to support. The fields are:
105 pseudo-op name without dot
106 function to call to execute this pseudo-op
107 Integer arg to pass to the function
110 const pseudo_typeS md_pseudo_table
[] = {
112 {"data.b" , cons
, 1},
113 {"data.w" , cons
, 2},
114 {"data.l" , cons
, 4},
115 {"form" , listing_psize
, 0},
116 {"heading", listing_title
, 0},
117 {"import" , s_ignore
, 0},
118 {"page" , listing_eject
, 0},
119 {"program", s_ignore
, 0},
120 {"z8001" , s_segm
, 0},
121 {"z8002" , s_unseg
, 0},
123 {"segm" , s_segm
, 0},
124 {"unsegm" , s_unseg
, 0},
125 {"unseg" , s_unseg
, 0},
126 {"name" , s_app_file
, 0},
127 {"global" , s_globl
, 0},
132 {"rsect" , obj_coff_section
, 0},
133 {"sect" , obj_coff_section
, 0},
134 {"block" , s_space
, 0},
139 const char EXP_CHARS
[] = "eE";
141 /* Chars that mean this number is a floating point constant.
144 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
146 /* Opcode mnemonics. */
147 static struct hash_control
*opcode_hash_control
;
152 opcode_entry_type
*opcode
;
153 char *prev_name
= "";
156 opcode_hash_control
= hash_new ();
158 for (opcode
= z8k_table
; opcode
->name
; opcode
++)
160 /* Only enter unique codes into the table. */
161 if (strcmp (opcode
->name
, prev_name
))
163 hash_insert (opcode_hash_control
, opcode
->name
, (char *) opcode
);
167 prev_name
= opcode
->name
;
170 /* Default to z8002. */
173 /* Insert the pseudo ops, too. */
174 for (idx
= 0; md_pseudo_table
[idx
].poc_name
; idx
++)
176 opcode_entry_type
*fake_opcode
;
177 fake_opcode
= (opcode_entry_type
*) malloc (sizeof (opcode_entry_type
));
178 fake_opcode
->name
= md_pseudo_table
[idx
].poc_name
;
179 fake_opcode
->func
= (void *) (md_pseudo_table
+ idx
);
180 fake_opcode
->opcode
= 250;
181 hash_insert (opcode_hash_control
, fake_opcode
->name
, fake_opcode
);
193 typedef struct z8k_op
{
194 /* 'b','w','r','q'. */
202 /* Any other register associated with the mode. */
205 /* Any expression. */
209 static expressionS
*da_operand
;
210 static expressionS
*imm_operand
;
223 if (ISDIGIT (src
[1]))
225 *reg
= (src
[0] - '0') * 10 + src
[1] - '0';
230 *reg
= (src
[0] - '0');
241 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
249 /* Try to parse a reg name. Return a pointer to the first character
250 in SRC after the reg name. */
253 parse_reg (src
, mode
, reg
)
261 if (src
[0] == 's' && src
[1] == 'p' && (src
[2] == 0 || src
[2] == ','))
265 *mode
= CLASS_REG_LONG
;
270 *mode
= CLASS_REG_WORD
;
279 if (src
[2] < '0' || src
[2] > '9')
280 return res
; /* Assume no register name but a label starting with 'rr'. */
281 *mode
= CLASS_REG_LONG
;
282 res
= whatreg (reg
, src
+ 2);
285 as_warn (_("register rr%d, out of range."), regno
);
287 else if (src
[1] == 'h')
289 if (src
[2] < '0' || src
[2] > '9')
290 return res
; /* Assume no register name but a label starting with 'rh'. */
291 *mode
= CLASS_REG_BYTE
;
292 res
= whatreg (reg
, src
+ 2);
295 as_warn (_("register rh%d, out of range."), regno
);
297 else if (src
[1] == 'l')
299 if (src
[2] < '0' || src
[2] > '9')
300 return res
; /* Assume no register name but a label starting with 'rl'. */
301 *mode
= CLASS_REG_BYTE
;
302 res
= whatreg (reg
, src
+ 2);
305 as_warn (_("register rl%d, out of range."), regno
);
308 else if (src
[1] == 'q')
310 if (src
[2] < '0' || src
[2] > '9')
311 return res
; /* Assume no register name but a label starting with 'rq'. */
312 *mode
= CLASS_REG_QUAD
;
313 res
= whatreg (reg
, src
+ 2);
316 as_warn (_("register rq%d, out of range."), regno
);
320 if (src
[1] < '0' || src
[1] > '9')
321 return res
; /* Assume no register name but a label starting with 'r'. */
322 *mode
= CLASS_REG_WORD
;
323 res
= whatreg (reg
, src
+ 1);
326 as_warn (_("register r%d, out of range."), regno
);
337 char *save
= input_line_pointer
;
340 input_line_pointer
= s
;
342 if (op
->X_op
== O_absent
)
343 as_bad (_("missing operand"));
344 new = input_line_pointer
;
345 input_line_pointer
= save
;
349 /* The many forms of operand:
371 as_bad (_("expected %c"), what
);
376 /* Make sure the mode supplied is the size of a word. */
379 regword (mode
, string
)
388 as_bad (_("register is wrong size for a word %s"), string
);
392 /* Make sure the mode supplied is the size of an address. */
395 regaddr (mode
, string
)
401 ok
= segmented_mode
? CLASS_REG_LONG
: CLASS_REG_WORD
;
404 as_bad (_("register is wrong size for address %s"), string
);
413 struct ctrl_names ctrl_table
[] = {
426 get_ctrl_operand (ptr
, mode
, dst
)
429 unsigned int dst ATTRIBUTE_UNUSED
;
437 mode
->mode
= CLASS_CTRL
;
438 for (i
= 0; ctrl_table
[i
].name
; i
++)
442 for (j
= 0; ctrl_table
[i
].name
[j
]; j
++)
444 if (ctrl_table
[i
].name
[j
] != src
[j
])
447 the_ctrl
= ctrl_table
[i
].value
;
463 struct flag_names flag_table
[] = {
474 get_flags_operand (ptr
, mode
, dst
)
477 unsigned int dst ATTRIBUTE_UNUSED
;
486 mode
->mode
= CLASS_FLAGS
;
488 for (j
= 0; j
<= 9; j
++)
492 for (i
= 0; flag_table
[i
].name
; i
++)
494 if (flag_table
[i
].name
[0] == src
[j
])
496 the_flags
= the_flags
| flag_table
[i
].value
;
509 struct interrupt_names
{
515 struct interrupt_names intr_table
[] = {
524 get_interrupt_operand (ptr
, mode
, dst
)
527 unsigned int dst ATTRIBUTE_UNUSED
;
535 mode
->mode
= CLASS_IMM
;
536 for (i
= 0; intr_table
[i
].name
; i
++)
540 for (j
= 0; intr_table
[i
].name
[j
]; j
++)
542 if (intr_table
[i
].name
[j
] != src
[j
])
545 the_interrupt
= intr_table
[i
].value
;
561 struct cc_names table
[] = {
588 get_cc_operand (ptr
, mode
, dst
)
591 unsigned int dst ATTRIBUTE_UNUSED
;
599 mode
->mode
= CLASS_CC
;
600 for (i
= 0; table
[i
].name
; i
++)
604 for (j
= 0; table
[i
].name
[j
]; j
++)
606 if (table
[i
].name
[j
] != src
[j
])
609 the_cc
= table
[i
].value
;
619 get_operand (ptr
, mode
, dst
)
622 unsigned int dst ATTRIBUTE_UNUSED
;
633 mode
->mode
= CLASS_IMM
;
634 imm_operand
= &(mode
->exp
);
635 src
= parse_exp (src
+ 1, &(mode
->exp
));
637 else if (*src
== '@')
641 mode
->mode
= CLASS_IR
;
642 src
= parse_reg (src
+ 1, &d
, &mode
->reg
);
648 end
= parse_reg (src
, &mode
->mode
, ®n
);
658 end
= parse_reg (src
, &nw
, &nr
);
665 as_bad (_("Missing ) in ra(rb)"));
669 regaddr (mode
->mode
, "ra(rb) ra");
671 regword (mode
->mode
, "ra(rb) rb");
673 mode
->mode
= CLASS_BX
;
683 src
= parse_exp (src
, &(mode
->exp
));
684 src
= checkfor (src
, ')');
685 mode
->mode
= CLASS_BA
;
688 imm_operand
= &(mode
->exp
);
699 /* No initial reg. */
700 src
= parse_exp (src
, &(mode
->exp
));
704 end
= parse_reg (src
, &(mode
->mode
), ®n
);
705 regword (mode
->mode
, "addr(Ra) ra");
706 mode
->mode
= CLASS_X
;
709 da_operand
= &(mode
->exp
);
710 src
= checkfor (end
, ')');
714 /* Just an address. */
715 mode
->mode
= CLASS_DA
;
718 da_operand
= &(mode
->exp
);
726 get_operands (opcode
, op_end
, operand
)
727 opcode_entry_type
*opcode
;
735 switch (opcode
->noperands
)
743 if (opcode
->arg_info
[0] == CLASS_CC
)
744 get_cc_operand (&ptr
, operand
+ 0, 0);
746 else if (opcode
->arg_info
[0] == CLASS_FLAGS
)
747 get_flags_operand (&ptr
, operand
+ 0, 0);
749 else if (opcode
->arg_info
[0] == (CLASS_IMM
+ (ARG_IMM2
)))
750 get_interrupt_operand (&ptr
, operand
+ 0, 0);
753 get_operand (&ptr
, operand
+ 0, 0);
760 if (opcode
->arg_info
[0] == CLASS_CC
)
761 get_cc_operand (&ptr
, operand
+ 0, 0);
763 else if (opcode
->arg_info
[0] == CLASS_CTRL
)
765 get_ctrl_operand (&ptr
, operand
+ 0, 0);
770 get_operand (&ptr
, operand
+ 0, 0);
776 get_ctrl_operand (&ptr
, operand
+ 1, 1);
781 get_operand (&ptr
, operand
+ 0, 0);
787 get_operand (&ptr
, operand
+ 1, 1);
791 get_operand (&ptr
, operand
+ 0, 0);
794 get_operand (&ptr
, operand
+ 1, 1);
797 get_operand (&ptr
, operand
+ 2, 2);
801 get_operand (&ptr
, operand
+ 0, 0);
804 get_operand (&ptr
, operand
+ 1, 1);
807 get_operand (&ptr
, operand
+ 2, 2);
810 get_cc_operand (&ptr
, operand
+ 3, 3);
820 /* Passed a pointer to a list of opcodes which use different
821 addressing modes. Return the opcode which matches the opcodes
824 static opcode_entry_type
*
825 get_specific (opcode
, operands
)
826 opcode_entry_type
*opcode
;
830 opcode_entry_type
*this_try
= opcode
;
832 unsigned int noperands
= opcode
->noperands
;
834 int this_index
= opcode
->idx
;
836 while (this_index
== opcode
->idx
&& !found
)
841 for (i
= 0; i
< noperands
; i
++)
843 unsigned int mode
= operands
[i
].mode
;
845 if ((mode
& CLASS_MASK
) != (this_try
->arg_info
[i
] & CLASS_MASK
))
847 /* It could be an pc rel operand, if this is a da mode
848 and we like disps, then insert it. */
850 if (mode
== CLASS_DA
&& this_try
->arg_info
[i
] == CLASS_DISP
)
852 /* This is the case. */
853 operands
[i
].mode
= CLASS_DISP
;
855 else if (mode
== CLASS_BA
&& this_try
->arg_info
[i
])
857 /* Can't think of a way to turn what we've been
858 given into something that's OK. */
861 else if (this_try
->arg_info
[i
] & CLASS_PR
)
863 if (mode
== CLASS_REG_LONG
&& segmented_mode
)
867 else if (mode
== CLASS_REG_WORD
&& !segmented_mode
)
877 switch (mode
& CLASS_MASK
)
892 reg
[this_try
->arg_info
[i
] & ARG_MASK
] = operands
[i
].reg
;
907 #if 0 /* Not used. */
909 check_operand (operand
, width
, string
)
910 struct z8k_op
*operand
;
914 if (operand
->exp
.X_add_symbol
== 0
915 && operand
->exp
.X_op_symbol
== 0)
918 /* No symbol involved, let's look at offset, it's dangerous if
919 any of the high bits are not 0 or ff's, find out by oring or
920 anding with the width and seeing if the answer is 0 or all
922 if ((operand
->exp
.X_add_number
& ~width
) != 0 &&
923 (operand
->exp
.X_add_number
| width
) != (~0))
925 as_warn (_("operand %s0x%x out of range."),
926 string
, operand
->exp
.X_add_number
);
933 static char buffer
[20];
936 newfix (ptr
, type
, operand
)
939 expressionS
*operand
;
941 if (operand
->X_add_symbol
942 || operand
->X_op_symbol
943 || operand
->X_add_number
)
945 fix_new_exp (frag_now
,
955 apply_fix (ptr
, type
, operand
, size
)
958 expressionS
*operand
;
961 int n
= operand
->X_add_number
;
963 newfix ((ptr
- buffer
) / 2, type
, operand
);
966 case 8: /* 8 nibbles == 32 bits. */
971 case 4: /* 4 nibbles == 16 bits. */
983 /* Now we know what sort of opcodes it is. Let's build the bytes. */
985 #define INSERT(x,y) *x++ = y>>24; *x++ = y>> 16; *x++=y>>8; *x++ =y;
988 build_bytes (this_try
, operand
)
989 opcode_entry_type
*this_try
;
990 struct z8k_op
*operand ATTRIBUTE_UNUSED
;
992 char *output_ptr
= buffer
;
996 unsigned int *class_ptr
;
998 frag_wane (frag_now
);
1001 memset (buffer
, 0, sizeof (buffer
));
1002 class_ptr
= this_try
->byte_info
;
1004 for (nibble
= 0; (c
= *class_ptr
++); nibble
++)
1007 switch (c
& CLASS_MASK
)
1013 /* Direct address, we don't cope with the SS mode right now. */
1016 /* da_operand->X_add_number |= 0x80000000; -- Now set at relocation time. */
1017 output_ptr
= apply_fix (output_ptr
, R_IMM32
, da_operand
, 8);
1021 output_ptr
= apply_fix (output_ptr
, R_IMM16
, da_operand
, 4);
1027 output_ptr
= apply_fix (output_ptr
, R_JR
, da_operand
, 2);
1034 output_ptr
= apply_fix (output_ptr
, R_DISP7
, da_operand
, 2);
1041 output_ptr
= apply_fix (output_ptr
, R_DISP7
, da_operand
, 2);
1042 output_ptr
[-2] = 0x8;
1046 case CLASS_BIT_1OR2
:
1047 *output_ptr
= c
& 0xf;
1050 if (imm_operand
->X_add_number
== 2)
1052 else if (imm_operand
->X_add_number
!= 1)
1053 as_bad (_("immediate must be 1 or 2"));
1056 as_bad (_("immediate 1 or 2 expected"));
1060 *output_ptr
++ = the_cc
;
1063 *output_ptr
++ = the_ctrl
;
1066 *output_ptr
++ = the_ctrl
| 0x8;
1069 *output_ptr
++ = (~the_interrupt
& 0x3);
1072 *output_ptr
++ = (~the_interrupt
& 0x3) | 0x4;
1075 *output_ptr
++ = the_flags
;
1079 *output_ptr
++ = c
& 0xf;
1082 if (reg
[c
& 0xf] == 0)
1083 as_bad (_("can't use R0 here"));
1086 case CLASS_REG_BYTE
:
1087 case CLASS_REG_WORD
:
1088 case CLASS_REG_LONG
:
1089 case CLASS_REG_QUAD
:
1090 /* Insert bit mattern of right reg. */
1091 *output_ptr
++ = reg
[c
& 0xf];
1094 switch (c
& ARG_MASK
)
1097 output_ptr
= apply_fix (output_ptr
, R_CALLR
, da_operand
, 4);
1100 output_ptr
= apply_fix (output_ptr
, R_REL16
, da_operand
, 4);
1103 output_ptr
= apply_fix (output_ptr
, R_IMM16
, da_operand
, 4);
1111 switch (c
& ARG_MASK
)
1114 imm_operand
->X_add_number
= -imm_operand
->X_add_number
;
1117 output_ptr
= apply_fix (output_ptr
, R_IMM4L
, imm_operand
, 1);
1120 imm_operand
->X_add_number
--;
1121 output_ptr
= apply_fix (output_ptr
, R_IMM4L
, imm_operand
, 1);
1123 case ARG_IMMNMINUS1
:
1124 imm_operand
->X_add_number
--;
1125 output_ptr
= apply_fix (output_ptr
, R_IMM4L
, imm_operand
, 1);
1128 imm_operand
->X_add_number
= -imm_operand
->X_add_number
;
1130 output_ptr
= apply_fix (output_ptr
, R_IMM8
, imm_operand
, 2);
1133 output_ptr
= apply_fix (output_ptr
, R_IMM16
, imm_operand
, 4);
1137 output_ptr
= apply_fix (output_ptr
, R_IMM32
, imm_operand
, 8);
1147 /* Copy from the nibble buffer into the frag. */
1149 int length
= (output_ptr
- buffer
) / 2;
1151 char *fragp
= frag_more (length
);
1153 while (src
< output_ptr
)
1155 *fragp
= (src
[0] << 4) | src
[1];
1162 /* This is the guts of the machine-dependent assembler. STR points to a
1163 machine dependent instruction. This function is supposed to emit
1164 the frags/bytes it assembles to. */
1173 struct z8k_op operand
[3];
1174 opcode_entry_type
*opcode
;
1175 opcode_entry_type
*prev_opcode
;
1177 /* Drop leading whitespace. */
1181 /* Find the op code end. */
1182 for (op_start
= op_end
= str
;
1183 *op_end
!= 0 && *op_end
!= ' ';
1187 if (op_end
== op_start
)
1189 as_bad (_("can't find opcode "));
1195 opcode
= (opcode_entry_type
*) hash_find (opcode_hash_control
, op_start
);
1199 as_bad (_("unknown opcode"));
1203 if (opcode
->opcode
== 250)
1207 char *old
= input_line_pointer
;
1210 /* Was really a pseudo op. */
1212 input_line_pointer
= op_end
;
1216 while (*input_line_pointer
== ' ')
1217 input_line_pointer
++;
1218 p
= (pseudo_typeS
*) (opcode
->func
);
1220 (p
->poc_handler
) (p
->poc_val
);
1221 input_line_pointer
= old
;
1226 char *new_input_line_pointer
;
1228 new_input_line_pointer
= get_operands (opcode
, op_end
, operand
);
1229 if (new_input_line_pointer
)
1230 input_line_pointer
= new_input_line_pointer
;
1231 prev_opcode
= opcode
;
1233 opcode
= get_specific (opcode
, operand
);
1237 /* Couldn't find an opcode which matched the operands. */
1238 char *where
= frag_more (2);
1243 as_bad (_("Can't find opcode to match operands"));
1247 build_bytes (opcode
, operand
);
1252 tc_crawl_symbol_chain (headers
)
1253 object_headers
*headers ATTRIBUTE_UNUSED
;
1255 printf (_("call to tc_crawl_symbol_chain \n"));
1259 md_undefined_symbol (name
)
1260 char *name ATTRIBUTE_UNUSED
;
1266 tc_headers_hook (headers
)
1267 object_headers
*headers ATTRIBUTE_UNUSED
;
1269 printf (_("call to tc_headers_hook \n"));
1272 /* Various routines to kill one day. */
1273 /* Equal to MAX_PRECISION in atof-ieee.c. */
1274 #define MAX_LITTLENUMS 6
1276 /* Turn a string in input_line_pointer into a floating point constant
1277 of type TYPE, and store the appropriate bytes in *LITP. The number
1278 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1279 returned, or NULL on OK. */
1282 md_atof (type
, litP
, sizeP
)
1288 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1289 LITTLENUM_TYPE
*wordP
;
1321 return _("Bad call to MD_ATOF()");
1323 t
= atof_ieee (input_line_pointer
, type
, words
);
1325 input_line_pointer
= t
;
1327 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1328 for (wordP
= words
; prec
--;)
1330 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
1331 litP
+= sizeof (LITTLENUM_TYPE
);
1336 const char *md_shortopts
= "z:";
1338 struct option md_longopts
[] =
1340 {NULL
, no_argument
, NULL
, 0}
1343 size_t md_longopts_size
= sizeof (md_longopts
);
1346 md_parse_option (c
, arg
)
1353 if (!strcmp (arg
, "8001"))
1355 else if (!strcmp (arg
, "8002"))
1359 as_bad (_("invalid architecture -z%s"), arg
);
1372 md_show_usage (stream
)
1375 fprintf (stream
, _("\
1377 -z8001 generate segmented code\n\
1378 -z8002 generate unsegmented code\n"));
1382 tc_aout_fix_to_chars ()
1384 printf (_("call to tc_aout_fix_to_chars \n"));
1389 md_convert_frag (headers
, seg
, fragP
)
1390 object_headers
*headers ATTRIBUTE_UNUSED
;
1391 segT seg ATTRIBUTE_UNUSED
;
1392 fragS
*fragP ATTRIBUTE_UNUSED
;
1394 printf (_("call to md_convert_frag \n"));
1399 md_section_align (seg
, size
)
1403 return ((size
+ (1 << section_alignment
[(int) seg
]) - 1)
1404 & (-1 << section_alignment
[(int) seg
]));
1408 md_apply_fix3 (fixP
, valP
, segment
)
1411 segT segment ATTRIBUTE_UNUSED
;
1413 long val
= * (long *) valP
;
1414 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
1416 switch (fixP
->fx_r_type
)
1419 buf
[0] = (buf
[0] & 0xf0) | ((buf
[0] + val
) & 0xf);
1444 *buf
++ = (val
>> 8);
1448 *buf
++ = (val
>> 24);
1449 *buf
++ = (val
>> 16);
1450 *buf
++ = (val
>> 8);
1455 *buf
++ = (val
>> 16);
1457 *buf
++ = (val
>> 8);
1463 md_number_to_chars (buf
, val
, fixP
->fx_size
);
1470 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
1475 md_estimate_size_before_relax (fragP
, segment_type
)
1476 register fragS
*fragP ATTRIBUTE_UNUSED
;
1477 register segT segment_type ATTRIBUTE_UNUSED
;
1479 printf (_("call tomd_estimate_size_before_relax\n"));
1483 /* Put number into target byte order. */
1486 md_number_to_chars (ptr
, use
, nbytes
)
1491 number_to_chars_bigendian (ptr
, use
, nbytes
);
1495 md_pcrel_from (fixP
)
1496 fixS
*fixP ATTRIBUTE_UNUSED
;
1502 tc_coff_symbol_emit_hook (s
)
1503 symbolS
*s ATTRIBUTE_UNUSED
;
1508 tc_reloc_mangle (fix_ptr
, intr
, base
)
1510 struct internal_reloc
*intr
;
1514 symbolS
*symbol_ptr
;
1516 if (fix_ptr
->fx_addsy
1517 && fix_ptr
->fx_subsy
)
1519 symbolS
*add
= fix_ptr
->fx_addsy
;
1520 symbolS
*sub
= fix_ptr
->fx_subsy
;
1522 if (S_GET_SEGMENT (add
) != S_GET_SEGMENT (sub
))
1523 as_bad (_("Can't subtract symbols in different sections %s %s"),
1524 S_GET_NAME (add
), S_GET_NAME (sub
));
1527 int diff
= S_GET_VALUE (add
) - S_GET_VALUE (sub
);
1529 fix_ptr
->fx_addsy
= 0;
1530 fix_ptr
->fx_subsy
= 0;
1531 fix_ptr
->fx_offset
+= diff
;
1534 symbol_ptr
= fix_ptr
->fx_addsy
;
1536 /* If this relocation is attached to a symbol then it's ok
1538 if (fix_ptr
->fx_r_type
== 0)
1540 /* cons likes to create reloc32's whatever the size of the reloc. */
1541 switch (fix_ptr
->fx_size
)
1544 intr
->r_type
= R_IMM16
;
1547 intr
->r_type
= R_IMM8
;
1550 intr
->r_type
= R_IMM32
;
1557 intr
->r_type
= fix_ptr
->fx_r_type
;
1559 intr
->r_vaddr
= fix_ptr
->fx_frag
->fr_address
+ fix_ptr
->fx_where
+ base
;
1560 intr
->r_offset
= fix_ptr
->fx_offset
;
1563 intr
->r_symndx
= symbol_ptr
->sy_number
;
1565 intr
->r_symndx
= -1;