* elf32-ppc.c (LWZU_0_X_11): Delete.
[binutils.git] / gas / config / tc-w65.c
blobc666d56c65ef9f9c7443e6dc8c1874430cae0f0a
1 /* tc-w65.c -- Assemble code for the W65816
2 Copyright 1995, 1998, 2000, 2001, 2002, 2005
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)
10 any later version.
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, 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
22 /* Written By Steve Chamberlain <sac@cygnus.com>. */
24 #include <stdio.h>
25 #include "as.h"
26 #include "bfd.h"
27 #include "subsegs.h"
28 #define DEFINE_TABLE
29 #include "../opcodes/w65-opc.h"
31 const char comment_chars[] = "!";
32 const char line_separator_chars[] = ";";
33 const char line_comment_chars[] = "!#";
35 /* This table describes all the machine specific pseudo-ops the assembler
36 has to support. The fields are:
38 pseudo-op name without dot
39 function to call to execute this pseudo-op
40 Integer arg to pass to the function. */
42 #define OP_BCC 0x90
43 #define OP_BCS 0xB0
44 #define OP_BEQ 0xF0
45 #define OP_BMI 0x30
46 #define OP_BNE 0xD0
47 #define OP_BPL 0x10
48 #define OP_BRA 0x80
49 #define OP_BRL 0x82
50 #define OP_BVC 0x50
51 #define OP_BVS 0x70
53 static int M; /* M flag. */
54 static int X; /* X flag. */
56 /* This function is called once, at assembler startup time. This
57 should set up all the tables, etc that the MD part of the assembler
58 needs. */
60 static void
61 s_longa (int xmode)
63 int *p = xmode ? &X : &M;
65 while (*input_line_pointer == ' ')
66 input_line_pointer++;
67 if (strncmp (input_line_pointer, "on", 2) == 0)
69 input_line_pointer += 2;
70 *p = 0;
72 else if (strncmp (input_line_pointer, "off", 3) == 0)
74 *p = 1;
75 input_line_pointer += 3;
77 else
78 as_bad (_("need on or off."));
79 demand_empty_rest_of_line ();
82 const pseudo_typeS md_pseudo_table[] =
84 {"int", cons, 2},
85 {"word", cons, 2},
86 {"longa", s_longa, 0},
87 {"longi", s_longa, 1},
88 {0, 0, 0}
91 const char EXP_CHARS[] = "eE";
93 /* Chars that mean this number is a floating point constant. */
94 /* As in 0f12.456 */
95 /* or 0d1.2345e12 */
96 const char FLT_CHARS[] = "rRsSfFdDxXpP";
98 /* Opcode mnemonics */
99 static struct hash_control *opcode_hash_control;
101 #define C(a, b) ENCODE_RELAX(a,b)
102 #define ENCODE_RELAX(what, length) (((what) << 2) + (length))
104 #define GET_WHAT(x) (((x) >> 2))
106 #define BYTE_DISP 1
107 #define WORD_DISP 2
108 #define UNDEF_BYTE_DISP 0
109 #define UNDEF_WORD_DISP 3
110 #define COND_BRANCH 1
111 #define UNCOND_BRANCH 2
112 #define END 3
114 #define BYTE_F 127 /* How far we can branch forwards. */
115 #define BYTE_B -126 /* How far we can branch backwards. */
116 #define WORD_F 32767
117 #define WORD_B 32768
119 relax_typeS md_relax_table[C (END, 0)] =
121 { 0, 0, 0, 0 },
122 { 0, 0, 0, 0 },
123 { 0, 0, 0, 0 },
124 { 0, 0, 0, 0 },
126 /* COND_BRANCH */
127 { 0, 0, 0, 0 }, /* UNDEF_BYTE_DISP */
128 { BYTE_F, BYTE_B, 2, C (COND_BRANCH, WORD_DISP) }, /* BYTE_DISP */
129 { WORD_F, WORD_B, 5, 0 }, /* WORD_DISP */
130 { 0, 0, 5, 0 }, /* UNDEF_WORD_DISP */
132 /* UNCOND_BRANCH */
133 { 0, 0, 0, 0 }, /* UNDEF_BYTE_DISP */
134 { BYTE_F, BYTE_B, 2, C (UNCOND_BRANCH, WORD_DISP) }, /* BYTE_DISP */
135 { WORD_F, WORD_B, 3, 0 }, /* WORD_DISP */
136 { 0, 0, 3, 0 } /* UNDEF_WORD_DISP */
139 void
140 md_begin (void)
142 const struct opinfo *opcode;
143 char *prev_name = "";
145 opcode_hash_control = hash_new ();
147 /* Insert unique names into hash table. */
148 for (opcode = optable; opcode->name; opcode++)
150 if (strcmp (prev_name, opcode->name))
152 prev_name = opcode->name;
153 hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
157 flag_signed_overflow_ok = 1;
160 static expressionS immediate; /* Absolute expression. */
161 static expressionS immediate1; /* Absolute expression. */
162 int expr_size;
163 int expr_shift;
164 int tc_cons_reloc;
166 void
167 w65_expression (expressionS *dest)
169 expr_size = 0;
170 expr_shift = 0;
171 tc_cons_reloc = 0;
172 while (*input_line_pointer == ' ')
173 input_line_pointer++;
175 if (*input_line_pointer == '<')
177 expr_size = 1;
178 input_line_pointer++;
180 else if (*input_line_pointer == '>')
182 expr_shift = 1;
183 input_line_pointer++;
185 else if (*input_line_pointer == '^')
187 expr_shift = 2;
188 input_line_pointer++;
191 expr (0, dest);
194 int amode;
196 static char *
197 parse_exp (char *s)
199 char *save;
200 char *new;
202 save = input_line_pointer;
203 input_line_pointer = s;
204 w65_expression (&immediate);
205 if (immediate.X_op == O_absent)
206 as_bad (_("missing operand"));
207 new = input_line_pointer;
208 input_line_pointer = save;
209 return new;
212 static char *
213 get_operands (const struct opinfo *info, char *ptr)
215 int override_len = 0;
216 int bytes = 0;
218 while (*ptr == ' ')
219 ptr++;
221 if (ptr[0] == '#')
223 ptr++;
224 switch (info->amode)
226 case ADDR_IMMTOI:
227 bytes = X ? 1 : 2;
228 amode = ADDR_IMMTOI;
229 break;
230 case ADDR_IMMTOA:
231 bytes = M ? 1 : 2;
232 amode = ADDR_IMMTOA;
233 break;
234 case ADDR_IMMCOP:
235 bytes = 1;
236 amode = ADDR_IMMCOP;
237 break;
238 case ADDR_DIR:
239 bytes = 2;
240 amode = ADDR_ABS;
241 break;
242 default:
243 abort ();
244 break;
246 ptr = parse_exp (ptr);
248 else if (ptr[0] == '!')
250 ptr = parse_exp (ptr + 1);
251 if (ptr[0] == ',')
253 if (ptr[1] == 'y')
255 amode = ADDR_ABS_IDX_Y;
256 bytes = 2;
257 ptr += 2;
259 else if (ptr[1] == 'x')
261 amode = ADDR_ABS_IDX_X;
262 bytes = 2;
263 ptr += 2;
265 else
266 as_bad (_("syntax error after <exp"));
268 else
270 amode = ADDR_ABS;
271 bytes = 2;
274 else if (ptr[0] == '>')
276 ptr = parse_exp (ptr + 1);
277 if (ptr[0] == ',' && ptr[1] == 'x')
279 amode = ADDR_ABS_LONG_IDX_X;
280 bytes = 3;
281 ptr += 2;
283 else
285 amode = ADDR_ABS_LONG;
286 bytes = 3;
289 else if (ptr[0] == '<')
291 ptr = parse_exp (ptr + 1);
292 if (ptr[0] == ',')
294 if (ptr[1] == 'y')
296 amode = ADDR_DIR_IDX_Y;
297 ptr += 2;
298 bytes = 2;
300 else if (ptr[1] == 'x')
302 amode = ADDR_DIR_IDX_X;
303 ptr += 2;
304 bytes = 2;
306 else
307 as_bad (_("syntax error after <exp"));
309 else
311 amode = ADDR_DIR;
312 bytes = 1;
315 else if (ptr[0] == 'a')
316 amode = ADDR_ACC;
317 else if (ptr[0] == '(')
319 /* Look for (exp),y
320 (<exp),y
321 (exp,x)
322 (<exp,x)
323 (exp)
324 (!exp)
325 (exp)
326 (<exp)
327 (exp,x)
328 (!exp,x)
329 (exp,s)
330 (exp,s),y */
332 ptr++;
333 if (ptr[0] == '<')
335 override_len = 1;
336 ptr++;
338 else if (ptr[0] == '!')
340 override_len = 2;
341 ptr++;
343 else if (ptr[0] == '>')
345 override_len = 3;
346 ptr++;
348 else
349 override_len = 0;
351 ptr = parse_exp (ptr);
353 if (ptr[0] == ',')
355 ptr++;
356 if (ptr[0] == 'x' && ptr[1] == ')')
358 ptr += 2;
360 if (override_len == 1)
362 amode = ADDR_DIR_IDX_IND_X;
363 bytes = 2;
365 else
367 amode = ADDR_ABS_IND_IDX;
368 bytes = 2;
371 else if (ptr[0] == 's' && ptr[1] == ')'
372 && ptr[2] == ',' && ptr[3] == 'y')
374 amode = ADDR_STACK_REL_INDX_IDX;
375 bytes = 1;
376 ptr += 4;
379 else if (ptr[0] == ')')
381 if (ptr[1] == ',' && ptr[2] == 'y')
383 amode = ADDR_DIR_IND_IDX_Y;
384 ptr += 3;
385 bytes = 2;
387 else
389 if (override_len == 1)
391 amode = ADDR_DIR_IND;
392 bytes = 1;
394 else
396 amode = ADDR_ABS_IND;
397 bytes = 2;
399 ptr++;
403 else if (ptr[0] == '[')
405 ptr = parse_exp (ptr + 1);
407 if (ptr[0] == ']')
409 ptr++;
410 if (ptr[0] == ',' && ptr[1] == 'y')
412 bytes = 1;
413 amode = ADDR_DIR_IND_IDX_Y_LONG;
414 ptr += 2;
416 else
418 if (info->code == O_jmp)
420 bytes = 2;
421 amode = ADDR_ABS_IND_LONG;
423 else
425 bytes = 1;
426 amode = ADDR_DIR_IND_LONG;
431 else
433 ptr = parse_exp (ptr);
434 if (ptr[0] == ',')
436 if (ptr[1] == 'y')
438 if (override_len == 1)
440 bytes = 1;
441 amode = ADDR_DIR_IDX_Y;
443 else
445 amode = ADDR_ABS_IDX_Y;
446 bytes = 2;
448 ptr += 2;
450 else if (ptr[1] == 'x')
452 if (override_len == 1)
454 amode = ADDR_DIR_IDX_X;
455 bytes = 1;
457 else
459 amode = ADDR_ABS_IDX_X;
460 bytes = 2;
462 ptr += 2;
464 else if (ptr[1] == 's')
466 bytes = 1;
467 amode = ADDR_STACK_REL;
468 ptr += 2;
470 else
472 bytes = 1;
473 immediate1 = immediate;
474 ptr = parse_exp (ptr + 1);
475 amode = ADDR_BLOCK_MOVE;
478 else
480 switch (info->amode)
482 case ADDR_PC_REL:
483 amode = ADDR_PC_REL;
484 bytes = 1;
485 break;
486 case ADDR_PC_REL_LONG:
487 amode = ADDR_PC_REL_LONG;
488 bytes = 2;
489 break;
490 default:
491 if (override_len == 1)
493 amode = ADDR_DIR;
494 bytes = 1;
496 else if (override_len == 3)
498 bytes = 3;
499 amode = ADDR_ABS_LONG;
501 else
503 amode = ADDR_ABS;
504 bytes = 2;
510 switch (bytes)
512 case 1:
513 switch (expr_shift)
515 case 0:
516 if (amode == ADDR_DIR)
517 tc_cons_reloc = R_W65_DP;
518 else
519 tc_cons_reloc = R_W65_ABS8;
520 break;
521 case 1:
522 tc_cons_reloc = R_W65_ABS8S8;
523 break;
524 case 2:
525 tc_cons_reloc = R_W65_ABS8S16;
526 break;
528 break;
529 case 2:
530 switch (expr_shift)
532 case 0:
533 tc_cons_reloc = R_W65_ABS16;
534 break;
535 case 1:
536 tc_cons_reloc = R_W65_ABS16S8;
537 break;
538 case 2:
539 tc_cons_reloc = R_W65_ABS16S16;
540 break;
543 return ptr;
546 /* Passed a pointer to a list of opcodes which use different
547 addressing modes, return the opcode which matches the opcodes
548 provided. */
550 static const struct opinfo *
551 get_specific (const struct opinfo *opcode)
553 int ocode = opcode->code;
555 for (; opcode->code == ocode; opcode++)
556 if (opcode->amode == amode)
557 return opcode;
559 return 0;
562 /* Now we know what sort of opcodes it is, let's build the bytes. */
564 static void
565 build_Mytes (const struct opinfo *opcode)
567 int size;
568 int type;
569 int pcrel;
570 char *output;
572 if (opcode->amode == ADDR_IMPLIED)
573 output = frag_more (1);
575 else if (opcode->amode == ADDR_PC_REL)
577 int type;
579 /* This is a relaxable insn, so we do some special handling. */
580 type = opcode->val == OP_BRA ? UNCOND_BRANCH : COND_BRANCH;
581 output = frag_var (rs_machine_dependent,
582 md_relax_table[C (type, WORD_DISP)].rlx_length,
583 md_relax_table[C (type, BYTE_DISP)].rlx_length,
584 C (type, UNDEF_BYTE_DISP),
585 immediate.X_add_symbol,
586 immediate.X_add_number,
589 else
591 switch (opcode->amode)
593 GETINFO (size, type, pcrel);
594 default:
595 abort ();
598 /* If something special was done in the expression modify the
599 reloc type. */
600 if (tc_cons_reloc)
601 type = tc_cons_reloc;
603 /* 1 byte for the opcode + the bytes for the addrmode. */
604 output = frag_more (size + 1);
606 if (opcode->amode == ADDR_BLOCK_MOVE)
608 /* Two relocs for this one. */
609 fix_new_exp (frag_now,
610 output + 1 - frag_now->fr_literal,
612 &immediate,
614 R_W65_ABS8S16);
616 fix_new_exp (frag_now,
617 output + 2 - frag_now->fr_literal,
619 &immediate1,
621 R_W65_ABS8S16);
623 else if (type >= 0
624 && opcode->amode != ADDR_IMPLIED
625 && opcode->amode != ADDR_ACC
626 && opcode->amode != ADDR_STACK)
628 fix_new_exp (frag_now,
629 output + 1 - frag_now->fr_literal,
630 size,
631 &immediate,
632 pcrel,
633 type);
636 output[0] = opcode->val;
639 /* This is the guts of the machine-dependent assembler. STR points to
640 a machine dependent instruction. This function is supposed to emit
641 the frags/bytes it assembles to. */
643 void
644 md_assemble (char *str)
646 const struct opinfo *opcode;
647 char name[20];
649 /* Drop leading whitespace */
650 while (*str == ' ')
651 str++;
653 /* All opcodes are three letters. */
654 name[0] = str[0];
655 name[1] = str[1];
656 name[2] = str[2];
657 name[3] = 0;
659 tc_cons_reloc = 0;
660 str += 3;
661 opcode = (struct opinfo *) hash_find (opcode_hash_control, name);
663 if (opcode == NULL)
665 as_bad (_("unknown opcode"));
666 return;
669 if (opcode->amode != ADDR_IMPLIED
670 && opcode->amode != ADDR_STACK)
672 get_operands (opcode, str);
673 opcode = get_specific (opcode);
676 if (opcode == 0)
678 /* Couldn't find an opcode which matched the operands. */
680 char *where = frag_more (1);
682 where[0] = 0x0;
683 where[1] = 0x0;
684 as_bad (_("invalid operands for opcode"));
685 return;
688 build_Mytes (opcode);
691 symbolS *
692 md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
694 return 0;
697 /* Various routines to kill one day. */
698 /* Equal to MAX_PRECISION in atof-ieee.c. */
699 #define MAX_LITTLENUMS 6
701 /* Turn a string in input_line_pointer into a floating point constant
702 of type TYPE, and store the appropriate bytes in *LITP. The number
703 of LITTLENUMS emitted is stored in *SIZEP. An error message is
704 returned, or NULL on OK. */
706 char *
707 md_atof (int type, char *litP, int *sizeP)
709 int prec;
710 LITTLENUM_TYPE words[MAX_LITTLENUMS];
711 LITTLENUM_TYPE *wordP;
712 char *t;
714 switch (type)
716 case 'f':
717 case 'F':
718 case 's':
719 case 'S':
720 prec = 2;
721 break;
723 case 'd':
724 case 'D':
725 case 'r':
726 case 'R':
727 prec = 4;
728 break;
730 case 'x':
731 case 'X':
732 prec = 6;
733 break;
735 case 'p':
736 case 'P':
737 prec = 6;
738 break;
740 default:
741 *sizeP = 0;
742 return _("Bad call to MD_NTOF()");
744 t = atof_ieee (input_line_pointer, type, words);
745 if (t)
746 input_line_pointer = t;
748 *sizeP = prec * sizeof (LITTLENUM_TYPE);
749 for (wordP = words + prec - 1; prec--;)
751 md_number_to_chars (litP, (valueT) (*wordP--), sizeof (LITTLENUM_TYPE));
752 litP += sizeof (LITTLENUM_TYPE);
754 return 0;
758 md_parse_option (int c ATTRIBUTE_UNUSED, char *a ATTRIBUTE_UNUSED)
760 return 0;
763 /* Called after relaxing, change the frags so they know how big they
764 are. */
766 void
767 md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED,
768 segT seg ATTRIBUTE_UNUSED,
769 fragS *fragP)
771 int disp_size = 0;
772 int inst_size = 0;
773 unsigned char *buffer =
774 (unsigned char *) (fragP->fr_fix + fragP->fr_literal);
776 switch (fragP->fr_subtype)
778 case C (COND_BRANCH, BYTE_DISP):
779 case C (UNCOND_BRANCH, BYTE_DISP):
780 disp_size = 1;
781 inst_size = 1;
782 break;
784 /* Conditional branches to a known 16 bit displacement. */
785 case C (COND_BRANCH, WORD_DISP):
786 switch (buffer[0])
788 case OP_BCC:
789 case OP_BCS:
790 case OP_BEQ:
791 case OP_BMI:
792 case OP_BNE:
793 case OP_BPL:
794 case OP_BVS:
795 case OP_BVC:
796 /* Invert the sense of the test. */
797 buffer[0] ^= 0x20;
798 buffer[1] = 3; /* Jump over following brl. */
799 buffer[2] = OP_BRL;
800 buffer[3] = 0;
801 buffer[4] = 0;
802 disp_size = 2;
803 inst_size = 3;
804 break;
805 default:
806 abort ();
808 break;
809 case C (UNCOND_BRANCH, WORD_DISP):
810 /* Unconditional branches to a known 16 bit displacement. */
812 switch (buffer[0])
814 case OP_BRA:
815 buffer[0] = OP_BRL;
816 disp_size = 2;
817 inst_size = 1;
818 break;
819 default:
820 abort ();
822 break;
823 /* Got to create a branch over a reloc here. */
824 case C (COND_BRANCH, UNDEF_WORD_DISP):
825 buffer[0] ^= 0x20; /* Invert test. */
826 buffer[1] = 3;
827 buffer[2] = OP_BRL;
828 buffer[3] = 0;
829 buffer[4] = 0;
830 fix_new (fragP,
831 fragP->fr_fix + 3,
833 fragP->fr_symbol,
834 fragP->fr_offset,
836 R_W65_PCR16);
838 fragP->fr_fix += disp_size + inst_size;
839 fragP->fr_var = 0;
840 break;
841 case C (UNCOND_BRANCH, UNDEF_WORD_DISP):
842 buffer[0] = OP_BRL;
843 buffer[1] = 0;
844 buffer[2] = 0;
845 fix_new (fragP,
846 fragP->fr_fix + 1,
848 fragP->fr_symbol,
849 fragP->fr_offset,
851 R_W65_PCR16);
853 fragP->fr_fix += disp_size + inst_size;
854 fragP->fr_var = 0;
855 break;
856 default:
857 abort ();
859 if (inst_size)
861 /* Get the address of the end of the instruction. */
862 int next_inst = (fragP->fr_fix + fragP->fr_address
863 + disp_size + inst_size);
864 int targ_addr = (S_GET_VALUE (fragP->fr_symbol) +
865 fragP->fr_offset);
866 int disp = targ_addr - next_inst;
868 md_number_to_chars ((char *) buffer + inst_size, disp, disp_size);
869 fragP->fr_fix += disp_size + inst_size;
870 fragP->fr_var = 0;
874 valueT
875 md_section_align (segT seg, valueT size)
877 return ((size + (1 << section_alignment[(int) seg]) - 1)
878 & (-1 << section_alignment[(int) seg]));
881 void
882 md_apply_fix3 (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
884 long val = * (long *) valP;
885 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
886 int addr = fixP->fx_frag->fr_address + fixP->fx_where;
888 if (fixP->fx_r_type == 0)
890 if (fixP->fx_size == 1)
891 fixP->fx_r_type = R_W65_ABS8;
892 else
893 fixP->fx_r_type = R_W65_ABS16;
896 switch (fixP->fx_r_type)
898 case R_W65_ABS8S16:
899 val >>= 8;
900 case R_W65_ABS8S8:
901 val >>= 8;
902 case R_W65_ABS8:
903 *buf++ = val;
904 break;
905 case R_W65_ABS16S16:
906 val >>= 8;
907 case R_W65_ABS16S8:
908 val >>= 8;
909 case R_W65_ABS16:
910 *buf++ = val >> 0;
911 *buf++ = val >> 8;
912 break;
913 case R_W65_ABS24:
914 *buf++ = val >> 0;
915 *buf++ = val >> 8;
916 *buf++ = val >> 16;
917 break;
918 case R_W65_PCR8:
919 *buf++ = val - addr - 1;
920 break;
921 case R_W65_PCR16:
922 val = val - addr - 1;
923 *buf++ = val;
924 *buf++ = val >> 8;
925 break;
926 case R_W65_DP:
927 *buf++ = val;
928 break;
930 default:
931 abort ();
934 if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
935 fixP->fx_done = 1;
938 /* Put number into target byte order. */
940 void
941 md_number_to_chars (char *ptr, valueT use, int nbytes)
943 number_to_chars_littleendian (ptr, use, nbytes);
946 long
947 md_pcrel_from (fixS *fixP)
949 int gap = fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address - 1;
950 return gap;
953 void
954 tc_coff_symbol_emit_hook (symbolS *x ATTRIBUTE_UNUSED)
958 short
959 tc_coff_fix2rtype (fixS *fix_ptr)
961 return fix_ptr->fx_r_type;
964 void
965 tc_reloc_mangle (fixS *fix_ptr,
966 struct internal_reloc *intr,
967 bfd_vma base)
970 symbolS *symbol_ptr;
972 symbol_ptr = fix_ptr->fx_addsy;
974 /* If this relocation is attached to a symbol then it's ok
975 to output it */
976 if (fix_ptr->fx_r_type == RELOC_32)
978 /* Cons likes to create reloc32's whatever the size of the reloc. */
979 switch (fix_ptr->fx_size)
981 case 2:
982 intr->r_type = R_IMM16;
983 break;
984 case 1:
985 intr->r_type = R_IMM8;
986 break;
987 default:
988 abort ();
991 else
993 if (fix_ptr->fx_size == 4)
994 intr->r_type = R_W65_ABS24;
995 else
996 intr->r_type = fix_ptr->fx_r_type;
999 intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base;
1000 intr->r_offset = fix_ptr->fx_offset;
1002 /* Turn the segment of the symbol into an offset. */
1003 if (symbol_ptr)
1005 symbolS *dot;
1007 dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot;
1008 if (dot)
1010 intr->r_offset += S_GET_VALUE (symbol_ptr);
1011 intr->r_symndx = dot->sy_number;
1013 else
1014 intr->r_symndx = symbol_ptr->sy_number;
1016 else
1017 intr->r_symndx = -1;
1021 tc_coff_sizemachdep (fragS *frag)
1023 return md_relax_table[frag->fr_subtype].rlx_length;
1026 /* Called just before address relaxation, return the length by which a
1027 fragment must grow to reach it's destination. */
1030 md_estimate_size_before_relax (fragS *fragP, segT segment_type)
1032 int what;
1034 switch (fragP->fr_subtype)
1036 default:
1037 abort ();
1039 case C (COND_BRANCH, UNDEF_BYTE_DISP):
1040 case C (UNCOND_BRANCH, UNDEF_BYTE_DISP):
1041 what = GET_WHAT (fragP->fr_subtype);
1042 /* Used to be a branch to somewhere which was unknown. */
1043 if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
1044 /* Got a symbol and it's defined in this segment, become byte
1045 sized - maybe it will fix up. */
1046 fragP->fr_subtype = C (what, BYTE_DISP);
1047 else
1048 /* Its got a segment, but its not ours, so it will always be
1049 long. */
1050 fragP->fr_subtype = C (what, UNDEF_WORD_DISP);
1051 break;
1053 case C (COND_BRANCH, BYTE_DISP):
1054 case C (COND_BRANCH, WORD_DISP):
1055 case C (COND_BRANCH, UNDEF_WORD_DISP):
1056 case C (UNCOND_BRANCH, BYTE_DISP):
1057 case C (UNCOND_BRANCH, WORD_DISP):
1058 case C (UNCOND_BRANCH, UNDEF_WORD_DISP):
1059 /* When relaxing a section for the second time, we don't need to
1060 do anything besides return the current size. */
1061 break;
1064 fragP->fr_var = md_relax_table[fragP->fr_subtype].rlx_length;
1065 return fragP->fr_var;
1068 const char *md_shortopts = "";
1069 struct option md_longopts[] =
1071 #define OPTION_RELAX (OPTION_MD_BASE)
1072 {NULL, no_argument, NULL, 0}
1075 void
1076 md_show_usage (FILE *stream ATTRIBUTE_UNUSED)
1080 size_t md_longopts_size = sizeof (md_longopts);