1 /* tc-h8300.c -- Assemble code for the Hitachi H8/300
2 Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 2000
3 Free Software Foundation.
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
23 Written By Steve Chamberlain
32 #define h8_opcodes ops
33 #include "opcode/h8300.h"
36 const char comment_chars[] = ";";
37 const char line_comment_chars[] = "#";
38 const char line_separator_chars[] = "";
40 /* This table describes all the machine specific pseudo-ops the assembler
41 has to support. The fields are:
42 pseudo-op name without dot
43 function to call to execute this pseudo-op
44 Integer arg to pass to the function
51 #define PSIZE (Hmode ? L_32 : L_16)
53 #define DSYMMODE (Hmode ? L_24 : L_16)
54 int bsize = L_8; /* default branch displacement */
83 const pseudo_typeS md_pseudo_table[] =
85 {"h8300h", h8300hmode, 0},
86 {"h8300s", h8300smode, 0},
87 {"sbranch", sbranch, L_8},
88 {"lbranch", sbranch, L_16},
94 {"form", listing_psize, 0},
95 {"heading", listing_title, 0},
96 {"import", s_ignore, 0},
97 {"page", listing_eject, 0},
98 {"program", s_ignore, 0},
102 const int md_reloc_size;
104 const char EXP_CHARS[] = "eE";
106 /* Chars that mean this number is a floating point constant */
109 const char FLT_CHARS[] = "rRsSfFdDxXpP";
111 static struct hash_control *opcode_hash_control; /* Opcode mnemonics */
113 /* This function is called once, at assembler startup time. This
114 should set up all the tables, etc. that the MD part of the assembler
119 struct h8_opcode *opcode;
120 char prev_buffer[100];
123 opcode_hash_control = hash_new ();
126 for (opcode = h8_opcodes; opcode->name; opcode++)
128 /* Strip off any . part when inserting the opcode and only enter
129 unique codes into the hash table. */
130 char *src = opcode->name;
131 unsigned int len = strlen (src);
132 char *dst = malloc (len + 1);
147 if (strcmp (buffer, prev_buffer))
149 hash_insert (opcode_hash_control, buffer, (char *) opcode);
150 strcpy (prev_buffer, buffer);
155 /* Find the number of operands. */
156 opcode->noperands = 0;
157 while (opcode->args.nib[opcode->noperands] != E)
160 /* Find the length of the opcode in bytes. */
162 while (opcode->data.nib[opcode->length * 2] != E)
177 int opsize; /* Set when a register size is seen */
188 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
197 /* Try and parse a reg name, returns number of chars consumed. */
199 parse_reg (src, mode, reg, direction)
209 /* Cribbed from get_symbol_end. */
210 if (!is_name_beginner (*src) || *src == '\001')
213 while (is_part_of_name (*end) || *end == '\001')
217 if (len == 2 && src[0] == 's' && src[1] == 'p')
219 *mode = PSIZE | REG | direction;
223 if (len == 3 && src[0] == 'c' && src[1] == 'c' && src[2] == 'r')
229 if (len == 3 && src[0] == 'e' && src[1] == 'x' && src[2] == 'r')
235 if (len == 2 && src[0] == 'f' && src[1] == 'p')
237 *mode = PSIZE | REG | direction;
241 if (len == 3 && src[0] == 'e' && src[1] == 'r'
242 && src[2] >= '0' && src[2] <= '7')
244 *mode = L_32 | REG | direction;
247 as_warn (_("Reg not valid for H8/300"));
250 if (len == 2 && src[0] == 'e' && src[1] >= '0' && src[1] <= '7')
252 *mode = L_16 | REG | direction;
253 *reg = src[1] - '0' + 8;
255 as_warn (_("Reg not valid for H8/300"));
261 if (src[1] >= '0' && src[1] <= '7')
263 if (len == 3 && src[2] == 'l')
265 *mode = L_8 | REG | direction;
266 *reg = (src[1] - '0') + 8;
269 if (len == 3 && src[2] == 'h')
271 *mode = L_8 | REG | direction;
272 *reg = (src[1] - '0');
277 *mode = L_16 | REG | direction;
278 *reg = (src[1] - '0');
292 char *save = input_line_pointer;
295 input_line_pointer = s;
297 if (op->X_op == O_absent)
298 as_bad (_("missing operand"));
299 new = input_line_pointer;
300 input_line_pointer = save;
305 skip_colonthing (ptr, exp, mode)
307 expressionS *exp ATTRIBUTE_UNUSED;
317 /* ff fill any 8 bit quantity */
318 /* exp->X_add_number -= 0x100; */
327 else if (*ptr == '3')
331 else if (*ptr == '1')
335 while (isdigit (*ptr))
342 /* The many forms of operand:
345 @Rn Register indirect
346 @(exp[:16], Rn) Register indirect with displacement
350 @aa:16 absolute 16 bit
353 #xx[:size] immediate data
354 @(exp:[8], pc) pc rel
355 @@aa[:8] memory indirect
366 src = skip_colonthing (src, &op->exp, &mode);
370 /* Choose a default mode. */
371 if (op->exp.X_add_number < -32768
372 || op->exp.X_add_number > 32767)
379 else if (op->exp.X_add_symbol
380 || op->exp.X_op_symbol)
391 get_operand (ptr, op, dst, direction)
394 unsigned int dst ATTRIBUTE_UNUSED;
404 /* Gross. Gross. ldm and stm have a format not easily handled
405 by get_operand. We deal with it explicitly here. */
406 if (src[0] == 'e' && src[1] == 'r' && isdigit (src[2])
407 && src[3] == '-' && src[4] == 'e' && src[5] == 'r' && isdigit (src[6]))
415 as_bad (_("Invalid register list for ldm/stm\n"));
418 as_bad (_("Invalid register list for ldm/stm\n"));
421 as_bad (_("Invalid register list for ldm/stm\n"));
425 as_bad (_("Invalid register list for ldm/stm\n"));
427 /* Even sicker. We encode two registers into op->reg. One
428 for the low register to save, the other for the high
429 register to save; we also set the high bit in op->reg
430 so we know this is "very special". */
431 op->reg = 0x80000000 | (high << 8) | low;
437 len = parse_reg (src, &op->mode, &op->reg, direction);
450 src = parse_exp (src, &op->exp);
452 src = skip_colonthing (src, &op->exp, &op->mode);
463 len = parse_reg (src, &mode, &num, direction);
466 /* Oops, not a reg after all, must be ordinary exp. */
468 /* Must be a symbol. */
469 op->mode = ABS | PSIZE | direction;
470 *ptr = skip_colonthing (parse_exp (src, &op->exp),
471 &op->exp, &op->mode);
476 if ((mode & SIZE) != PSIZE)
477 as_bad (_("Wrong size pointer register for architecture."));
488 /* Start off assuming a 16 bit offset. */
490 src = parse_exp (src, &op->exp);
492 src = colonmod24 (op, src);
497 op->mode |= ABS | direction;
504 as_bad (_("expected @(exp, reg16)"));
510 len = parse_reg (src, &mode, &op->reg, direction);
511 if (len == 0 || !(mode & REG))
513 as_bad (_("expected @(exp, reg16)"));
516 op->mode |= DISP | direction;
519 src = skip_colonthing (src, &op->exp, &op->mode);
521 if (*src != ')' && '(')
523 as_bad (_("expected @(exp, reg16)"));
530 len = parse_reg (src, &mode, &num, direction);
538 if ((mode & SIZE) != PSIZE)
539 as_bad (_("Wrong size pointer register for architecture."));
545 if ((mode & SIZE) != PSIZE)
546 as_bad (_("Wrong size pointer register for architecture."));
548 op->mode = direction | IND | PSIZE;
556 /* must be a symbol */
558 op->mode = ABS | direction;
559 src = parse_exp (src, &op->exp);
561 *ptr = colonmod24 (op, src);
571 src = parse_exp (src, &op->exp);
572 *ptr = skip_colonthing (src, &op->exp, &op->mode);
576 else if (strncmp (src, "mach", 4) == 0
577 || strncmp (src, "macl", 4) == 0)
579 op->reg = src[3] == 'l';
586 src = parse_exp (src, &op->exp);
587 /* Trailing ':' size ? */
590 if (src[1] == '1' && src[2] == '6')
592 op->mode = PCREL | L_16;
595 else if (src[1] == '8')
597 op->mode = PCREL | L_8;
602 as_bad (_("expect :8 or :16 here"));
607 op->mode = PCREL | bsize;
614 get_operands (noperands, op_end, operand)
615 unsigned int noperands;
617 struct h8_op *operand;
630 get_operand (&ptr, operand + 0, 0, SRC);
634 get_operand (&ptr, operand + 1, 1, DST);
644 get_operand (&ptr, operand + 0, 0, SRC);
647 get_operand (&ptr, operand + 1, 1, DST);
657 /* Passed a pointer to a list of opcodes which use different
658 addressing modes, return the opcode which matches the opcodes
660 static struct h8_opcode *
661 get_specific (opcode, operands, size)
662 struct h8_opcode *opcode;
663 struct h8_op *operands;
666 struct h8_opcode *this_try = opcode;
669 unsigned int this_index = opcode->idx;
671 /* There's only one ldm/stm and it's easier to just
672 get out quick for them. */
673 if (strcmp (opcode->name, "stm.l") == 0
674 || strcmp (opcode->name, "ldm.l") == 0)
677 while (this_index == opcode->idx && !found)
682 if (this_try->noperands == 0)
686 this_size = this_try->how & SN;
687 if (this_size != size && (this_size != SB || size != SN))
694 for (i = 0; i < this_try->noperands && found; i++)
696 op_type op = this_try->args.nib[i];
697 int x = operands[i].mode;
699 if ((op & (DISP | REG)) == (DISP | REG)
700 && ((x & (DISP | REG)) == (DISP | REG)))
702 dispreg = operands[i].reg;
710 x = (x & ~L_P) | (Hmode ? L_32 : L_16);
712 op = (op & ~L_P) | (Hmode ? L_32 : L_16);
716 /* The size of the reg is v important. */
717 if ((op & SIZE) != (x & SIZE))
720 else if ((op & ABSJMP) && (x & ABS))
722 operands[i].mode &= ~ABS;
723 operands[i].mode |= ABSJMP;
724 /* But it may not be 24 bits long. */
727 operands[i].mode &= ~SIZE;
728 operands[i].mode |= L_16;
731 else if ((op & (KBIT | DBIT)) && (x & IMM))
733 /* This is ok if the immediate value is sensible. */
737 /* The size of the displacement is important. */
738 if ((op & SIZE) != (x & SIZE))
741 else if ((op & (DISP | IMM | ABS))
742 && (op & (DISP | IMM | ABS)) == (x & (DISP | IMM | ABS)))
744 /* Promote a L_24 to L_32 if it makes us match. */
745 if ((x & L_24) && (op & L_32))
750 /* Promote an L8 to L_16 if it makes us match. */
751 if (op & ABS && op & L_8 && op & DISP)
756 else if ((x & SIZE) != 0
757 && ((op & SIZE) != (x & SIZE)))
760 else if ((op & MACREG) != (x & MACREG))
764 else if ((op & MODE) != (x & MODE))
778 check_operand (operand, width, string)
779 struct h8_op *operand;
783 if (operand->exp.X_add_symbol == 0
784 && operand->exp.X_op_symbol == 0)
786 /* No symbol involved, let's look at offset, it's dangerous if
787 any of the high bits are not 0 or ff's, find out by oring or
788 anding with the width and seeing if the answer is 0 or all
791 if ((operand->exp.X_add_number & ~width) != 0 &&
792 (operand->exp.X_add_number | width) != (~0))
795 && (operand->exp.X_add_number & 0xff00) == 0xff00)
797 /* Just ignore this one - which happens when trying to
798 fit a 16 bit address truncated into an 8 bit address
799 of something like bset. */
803 as_warn (_("operand %s0x%lx out of range."), string,
804 (unsigned long) operand->exp.X_add_number);
810 /* RELAXMODE has one of 3 values:
812 0 Output a "normal" reloc, no relaxing possible for this insn/reloc
814 1 Output a relaxable 24bit absolute mov.w address relocation
815 (may relax into a 16bit absolute address).
817 2 Output a relaxable 16/24 absolute mov.b address relocation
818 (may relax into an 8bit absolute address). */
821 do_a_fix_imm (offset, operand, relaxmode)
823 struct h8_op *operand;
830 char *t = operand->mode & IMM ? "#" : "@";
832 if (operand->exp.X_add_symbol == 0)
834 char *bytes = frag_now->fr_literal + offset;
835 switch (operand->mode & SIZE)
838 check_operand (operand, 0x3, t);
839 bytes[0] |= (operand->exp.X_add_number) << 4;
842 check_operand (operand, 0x7, t);
843 bytes[0] |= (operand->exp.X_add_number) << 4;
846 check_operand (operand, 0xff, t);
847 bytes[0] = operand->exp.X_add_number;
850 check_operand (operand, 0xffff, t);
851 bytes[0] = operand->exp.X_add_number >> 8;
852 bytes[1] = operand->exp.X_add_number >> 0;
855 check_operand (operand, 0xffffff, t);
856 bytes[0] = operand->exp.X_add_number >> 16;
857 bytes[1] = operand->exp.X_add_number >> 8;
858 bytes[2] = operand->exp.X_add_number >> 0;
862 /* This should be done with bfd. */
863 bytes[0] = operand->exp.X_add_number >> 24;
864 bytes[1] = operand->exp.X_add_number >> 16;
865 bytes[2] = operand->exp.X_add_number >> 8;
866 bytes[3] = operand->exp.X_add_number >> 0;
869 idx = (relaxmode == 2) ? R_MOV24B1 : R_MOVL1;
870 fix_new_exp (frag_now, offset, 4, &operand->exp, 0, idx);
877 switch (operand->mode & SIZE)
882 where = (operand->mode & SIZE) == L_24 ? -1 : 0;
885 else if (relaxmode == 1)
891 as_bad (_("Can't work out size of operand.\n"));
899 operand->exp.X_add_number =
900 ((operand->exp.X_add_number & 0xffff) ^ 0x8000) - 0x8000;
906 operand->exp.X_add_number =
907 ((operand->exp.X_add_number & 0xff) ^ 0x80) - 0x80;
910 fix_new_exp (frag_now,
919 /* Now we know what sort of opcodes it is, let's build the bytes. */
921 build_bytes (this_try, operand)
922 struct h8_opcode *this_try;
923 struct h8_op *operand;
927 char *output = frag_more (this_try->length);
928 op_type *nibble_ptr = this_try->data.nib;
930 unsigned int nibble_count = 0;
938 if (!(this_try->inbase || Hmode))
939 as_warn (_("Opcode `%s' with these operand types not available in H8/300 mode"),
942 while (*nibble_ptr != E)
947 d = (c & (DST | SRC_IN_DST)) != 0;
955 if (c & (REG | IND | INC | DEC))
957 nib = operand[d].reg;
959 else if ((c & DISPREG) == (DISPREG))
966 absat = nibble_count / 2;
969 else if (c & (IMM | PCREL | ABS | ABSJMP | DISP))
972 immat = nibble_count / 2;
981 switch (operand[0].exp.X_add_number)
990 as_bad (_("Need #1 or #2 here"));
995 switch (operand[0].exp.X_add_number)
1005 as_warn (_("#4 not valid on H8/300."));
1010 as_bad (_("Need #1 or #2 here"));
1013 /* Stop it making a fix. */
1014 operand[0].mode = 0;
1019 operand[d].mode |= MEMRELAX;
1029 nib = 2 + operand[d].reg;
1037 /* Disgusting. Why, oh why didn't someone ask us for advice
1038 on the assembler format. */
1039 if (strcmp (this_try->name, "stm.l") == 0
1040 || strcmp (this_try->name, "ldm.l") == 0)
1043 high = (operand[this_try->name[0] == 'l' ? 1 : 0].reg >> 8) & 0xf;
1044 low = operand[this_try->name[0] == 'l' ? 1 : 0].reg & 0xf;
1046 asnibbles[2] = high - low;
1047 asnibbles[7] = (this_try->name[0] == 'l') ? high : low;
1050 for (i = 0; i < this_try->length; i++)
1052 output[i] = (asnibbles[i * 2] << 4) | asnibbles[i * 2 + 1];
1055 /* Note if this is a movb instruction -- there's a special relaxation
1056 which only applies to them. */
1057 if (strcmp (this_try->name, "mov.b") == 0)
1060 /* Output any fixes. */
1061 for (i = 0; i < 2; i++)
1063 int x = operand[i].mode;
1065 if (x & (IMM | DISP))
1067 do_a_fix_imm (output - frag_now->fr_literal + immat,
1068 operand + i, x & MEMRELAX != 0);
1072 do_a_fix_imm (output - frag_now->fr_literal + absat,
1073 operand + i, x & MEMRELAX ? movb + 1 : 0);
1077 int size16 = x & L_16;
1078 int where = size16 ? 2 : 1;
1079 int size = size16 ? 2 : 1;
1080 int type = size16 ? R_PCRWORD : R_PCRBYTE;
1082 check_operand (operand + i, size16 ? 0x7fff : 0x7f, "@");
1084 if (operand[i].exp.X_add_number & 1)
1086 as_warn (_("branch operand has odd offset (%lx)\n"),
1087 (unsigned long) operand->exp.X_add_number);
1090 operand[i].exp.X_add_number -= 1;
1091 operand[i].exp.X_add_number =
1092 ((operand[i].exp.X_add_number & 0xff) ^ 0x80) - 0x80;
1094 fix_new_exp (frag_now,
1095 output - frag_now->fr_literal + where,
1101 else if (x & MEMIND)
1103 check_operand (operand + i, 0xff, "@@");
1104 fix_new_exp (frag_now,
1105 output - frag_now->fr_literal + 1,
1111 else if (x & ABSJMP)
1113 /* This jmp may be a jump or a branch. */
1115 check_operand (operand + i, Hmode ? 0xffffff : 0xffff, "@");
1116 if (operand[i].exp.X_add_number & 1)
1118 as_warn (_("branch operand has odd offset (%lx)\n"),
1119 (unsigned long) operand->exp.X_add_number);
1122 operand[i].exp.X_add_number =
1123 ((operand[i].exp.X_add_number & 0xffff) ^ 0x8000) - 0x8000;
1124 fix_new_exp (frag_now,
1125 output - frag_now->fr_literal,
1134 /* Try to give an intelligent error message for common and simple to
1137 clever_message (opcode, operand)
1138 struct h8_opcode *opcode;
1139 struct h8_op *operand;
1141 /* Find out if there was more than one possible opcode. */
1143 if ((opcode + 1)->idx != opcode->idx)
1147 /* Only one opcode of this flavour, try to guess which operand
1149 for (argn = 0; argn < opcode->noperands; argn++)
1151 switch (opcode->args.nib[argn])
1154 if (operand[argn].mode != RD16)
1156 as_bad (_("destination operand must be 16 bit register"));
1163 if (operand[argn].mode != RS8)
1165 as_bad (_("source operand must be 8 bit register"));
1171 if (operand[argn].mode != ABS16DST)
1173 as_bad (_("destination operand must be 16bit absolute address"));
1178 if (operand[argn].mode != RD8)
1180 as_bad (_("destination operand must be 8 bit register"));
1186 if (operand[argn].mode != ABS16SRC)
1188 as_bad (_("source operand must be 16bit absolute address"));
1196 as_bad (_("invalid operands"));
1199 /* This is the guts of the machine-dependent assembler. STR points to
1200 a machine dependent instruction. This function is supposed to emit
1201 the frags/bytes it assembles. */
1208 struct h8_op operand[2];
1209 struct h8_opcode *opcode;
1210 struct h8_opcode *prev_opcode;
1216 /* Drop leading whitespace. */
1220 /* Find the op code end. */
1221 for (op_start = op_end = str;
1222 *op_end != 0 && *op_end != ' ';
1234 if (op_end == op_start)
1236 as_bad (_("can't find opcode "));
1242 opcode = (struct h8_opcode *) hash_find (opcode_hash_control,
1247 as_bad (_("unknown opcode"));
1251 /* We used to set input_line_pointer to the result of get_operands,
1252 but that is wrong. Our caller assumes we don't change it. */
1254 (void) get_operands (opcode->noperands, op_end, operand);
1256 prev_opcode = opcode;
1276 opcode = get_specific (opcode, operand, size);
1280 /* Couldn't find an opcode which matched the operands. */
1281 char *where = frag_more (2);
1285 clever_message (prev_opcode, operand);
1289 if (opcode->size && dot)
1291 if (opcode->size != *dot)
1293 as_warn (_("mismatch between opcode size and operand size"));
1297 build_bytes (opcode, operand);
1301 tc_crawl_symbol_chain (headers)
1302 object_headers *headers ATTRIBUTE_UNUSED;
1304 printf (_("call to tc_crawl_symbol_chain \n"));
1308 md_undefined_symbol (name)
1309 char *name ATTRIBUTE_UNUSED;
1315 tc_headers_hook (headers)
1316 object_headers *headers ATTRIBUTE_UNUSED;
1318 printf (_("call to tc_headers_hook \n"));
1321 /* Various routines to kill one day */
1322 /* Equal to MAX_PRECISION in atof-ieee.c */
1323 #define MAX_LITTLENUMS 6
1325 /* Turn a string in input_line_pointer into a floating point constant
1326 of type TYPE, and store the appropriate bytes in *LITP. The number
1327 of LITTLENUMS emitted is stored in *SIZEP . An error message is
1328 returned, or NULL on OK. */
1330 md_atof (type, litP, sizeP)
1336 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1337 LITTLENUM_TYPE *wordP;
1369 return _("Bad call to MD_ATOF()");
1371 t = atof_ieee (input_line_pointer, type, words);
1373 input_line_pointer = t;
1375 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1376 for (wordP = words; prec--;)
1378 md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
1379 litP += sizeof (LITTLENUM_TYPE);
1384 CONST char *md_shortopts = "";
1385 struct option md_longopts[] = {
1386 {NULL, no_argument, NULL, 0}
1389 size_t md_longopts_size = sizeof (md_longopts);
1392 md_parse_option (c, arg)
1393 int c ATTRIBUTE_UNUSED;
1394 char *arg ATTRIBUTE_UNUSED;
1400 md_show_usage (stream)
1401 FILE *stream ATTRIBUTE_UNUSED;
1406 tc_aout_fix_to_chars ()
1408 printf (_("call to tc_aout_fix_to_chars \n"));
1413 md_convert_frag (headers, seg, fragP)
1414 object_headers *headers ATTRIBUTE_UNUSED;
1415 segT seg ATTRIBUTE_UNUSED;
1416 fragS *fragP ATTRIBUTE_UNUSED;
1418 printf (_("call to md_convert_frag \n"));
1423 md_section_align (seg, size)
1427 return ((size + (1 << section_alignment[(int) seg]) - 1)
1428 & (-1 << section_alignment[(int) seg]));
1432 md_apply_fix (fixP, val)
1436 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1438 switch (fixP->fx_size)
1444 *buf++ = (val >> 8);
1448 *buf++ = (val >> 24);
1449 *buf++ = (val >> 16);
1450 *buf++ = (val >> 8);
1459 md_estimate_size_before_relax (fragP, segment_type)
1460 register fragS *fragP ATTRIBUTE_UNUSED;
1461 register segT segment_type ATTRIBUTE_UNUSED;
1463 printf (_("call tomd_estimate_size_before_relax \n"));
1467 /* Put number into target byte order. */
1469 md_number_to_chars (ptr, use, nbytes)
1474 number_to_chars_bigendian (ptr, use, nbytes);
1478 md_pcrel_from (fixP)
1479 fixS *fixP ATTRIBUTE_UNUSED;
1485 tc_reloc_mangle (fix_ptr, intr, base)
1487 struct internal_reloc *intr;
1491 symbolS *symbol_ptr;
1493 symbol_ptr = fix_ptr->fx_addsy;
1495 /* If this relocation is attached to a symbol then it's ok
1497 if (fix_ptr->fx_r_type == TC_CONS_RELOC)
1499 /* cons likes to create reloc32's whatever the size of the reloc..
1501 switch (fix_ptr->fx_size)
1504 intr->r_type = R_RELLONG;
1507 intr->r_type = R_RELWORD;
1510 intr->r_type = R_RELBYTE;
1518 intr->r_type = fix_ptr->fx_r_type;
1521 intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base;
1522 intr->r_offset = fix_ptr->fx_offset;
1526 if (symbol_ptr->sy_number != -1)
1527 intr->r_symndx = symbol_ptr->sy_number;
1532 /* This case arises when a reference is made to `.'. */
1533 segsym = seg_info (S_GET_SEGMENT (symbol_ptr))->dot;
1535 intr->r_symndx = -1;
1538 intr->r_symndx = segsym->sy_number;
1539 intr->r_offset += S_GET_VALUE (symbol_ptr);
1544 intr->r_symndx = -1;