This commit was generated by cvs2svn to track changes on a CVS vendor
[platform/upstream/binutils.git] / gas / config / tc-or32.c
1 /* Assembly backend for the OpenRISC 1000.
2    Copyright (C) 2002 Free Software Foundation, Inc.
3    Contributed by Damjan Lampret <lampret@opencores.org>.
4    Modified bu Johan Rydberg, <johan.rydberg@netinsight.se>.
5    Based upon a29k port.
6
7    This file is part of GAS, the GNU Assembler.
8
9    GAS is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2, or (at your option)
12    any later version.
13
14    GAS is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with GAS; see the file COPYING.  If not, write to
21    the Free Software Foundation, 59 Temple Place - Suite 330,
22    Boston, MA 02111-1307, USA.  */
23
24 /* tc-a29k.c used as a template.  */
25
26 #include "safe-ctype.h"
27 #include "as.h"
28 #include "opcode/or32.h"
29
30 #ifdef BFD_ASSEMBLER
31 #include "elf/or32.h"
32 #endif
33
34 #define DEBUG 0
35
36 #ifndef REGISTER_PREFIX
37 #define REGISTER_PREFIX   '%'
38 #endif
39
40 /* Make it easier to clone this machine desc into another one.  */
41 #define machine_opcode  or32_opcode
42 #define machine_opcodes or32_opcodes
43 #define machine_ip      or32_ip
44 #define machine_it      or32_it
45
46 /* Handle of the OPCODE hash table.  */
47 static struct hash_control *op_hash = NULL;
48
49 struct machine_it
50   {
51     char *          error;
52     unsigned long   opcode;
53     struct nlist *  nlistp;
54     expressionS     exp;
55     int             pcrel;
56     int             reloc_offset;   /* Offset of reloc within insn.  */
57     int             reloc;
58   }
59 the_insn;
60
61 static void machine_ip PARAMS ((char *));
62
63 const pseudo_typeS md_pseudo_table[] =
64   {
65     {"align",   s_align_bytes,  4 },
66     {"space",   s_space,        0 },
67     {"cputype", s_ignore,       0 },
68     {"reg",     s_lsym,         0 },  /* Register equate, same as equ.  */
69     {"sect",    s_ignore,       0 },  /* Creation of coff sections.  */
70     {"proc",    s_ignore,       0 },  /* Start of a function.  */
71     {"endproc", s_ignore,       0 },  /* Function end.  */
72     {"word",    cons,           4 },
73     {NULL,      0,              0 },
74   };
75
76 int md_short_jump_size  = 4;
77 int md_long_jump_size   = 4;
78
79 #if defined(BFD_HEADERS)
80 #ifdef RELSZ
81 const int md_reloc_size = RELSZ;  /* Coff headers.  */
82 #else
83 const int md_reloc_size = 12;   /* Something else headers.  */
84 #endif
85 #else
86 const int md_reloc_size = 12;   /* Not bfdized.  */
87 #endif
88
89 /* This array holds the chars that always start a comment.
90    If the pre-processor is disabled, these aren't very useful.  */
91 const char comment_chars[] = "#";
92
93 /* This array holds the chars that only start a comment at the beginning of
94    a line.  If the line seems to have the form '# 123 filename'
95    .line and .file directives will appear in the pre-processed output.  */
96 /* Note that input_file.c hand checks for '#' at the beginning of the
97    first line of the input file.  This is because the compiler outputs
98    #NO_APP at the beginning of its output.  */
99 /* Also note that comments like this one will always work.  */
100 const char line_comment_chars[] = "#";
101
102 /* We needed an unused char for line separation to work around the
103    lack of macros, using sed and such.  */
104 const char line_separator_chars[] = ";";
105
106 /* Chars that can be used to separate mant from exp in floating point nums.  */
107 const char EXP_CHARS[] = "eE";
108
109 /* Chars that mean this number is a floating point constant.
110    As in 0f12.456
111    or    0d1.2345e12.  */
112 const char FLT_CHARS[] = "rRsSfFdDxXpP";
113
114 /* "l.jalr r9" precalculated opcode.  */
115 static unsigned long jalr_r9_opcode;
116
117
118 static int check_invalid_opcode PARAMS ((unsigned long));
119 static void encode PARAMS ((const struct machine_opcode *, unsigned long *, signed long, char));
120 #ifdef BFD_ASSEMBLER
121 static char * parse_operand PARAMS ((char *, expressionS *, int));
122 #endif
123
124 /* Set bits in machine opcode according to insn->encoding
125    description and passed operand.  */
126
127 static void
128 encode (insn, opcode, param_val, param_ch)
129      const struct machine_opcode *insn;
130      unsigned long *opcode;
131      signed long param_val;
132      char param_ch;
133 {
134   int opc_pos = 0;
135   int param_pos = 0;
136   char *enc;
137
138 #if DEBUG
139   printf ("    encode:  opcode=%.8lx  param_val=%.8lx abs=%.8lx param_ch=%c\n",
140           *opcode, param_val, abs (param_val), param_ch);
141 #endif
142   for (enc = insn->encoding; *enc != '\0'; enc++)
143     if (*enc == param_ch)
144       {
145         if (enc - 2 >= insn->encoding && (*(enc - 2) == '0') && (*(enc - 1) == 'x'))
146           continue;
147         else
148           param_pos ++;
149       }
150
151   opc_pos = 32;
152
153   for (enc = insn->encoding; *enc != '\0';)
154     {
155       if ((*enc == '0') && (*(enc + 1) == 'x'))
156         {
157           int tmp = strtol (enc, NULL, 16);
158
159           opc_pos -= 4;
160           *opcode |= tmp << opc_pos;
161           enc += 3;
162         }
163       else if ((*enc == '0') || (*enc == '-'))
164         {
165           opc_pos--;
166           enc++;
167         }
168       else if (*enc == '1')
169         {
170           opc_pos--;
171           *opcode |= 1 << opc_pos;
172           enc++;
173         }
174       else if (*enc == param_ch)
175         {
176           opc_pos--;
177           param_pos--;
178           *opcode |= ((param_val >> param_pos) & 0x1) << opc_pos;
179           enc++;
180         }
181       else if (ISALPHA (*enc))
182         {
183           opc_pos--;
184           enc++;
185         }
186       else
187         enc++;
188     }
189
190 #if DEBUG
191   printf ("    opcode=%.8lx\n", *opcode);
192 #endif
193 }
194
195 /* This function is called once, at assembler startup time.  It should
196    set up all the tables, etc., that the MD part of the assembler will
197    need.  */
198
199 void
200 md_begin ()
201 {
202   const char *retval = NULL;
203   int lose = 0;
204   int skipnext = 0;
205   unsigned int i;
206
207   /* Hash up all the opcodes for fast use later.  */
208   op_hash = hash_new ();
209
210   for (i = 0; i < or32_num_opcodes; i++)
211     {
212       const char *name = machine_opcodes[i].name;
213
214       if (skipnext)
215         {
216           skipnext = 0;
217           continue;
218         }
219
220       retval = hash_insert (op_hash, name, (PTR) &machine_opcodes[i]);
221       if (retval != NULL)
222         {
223           fprintf (stderr, "internal error: can't hash `%s': %s\n",
224                    machine_opcodes[i].name, retval);
225           lose = 1;
226         }
227     }
228
229   if (lose)
230     as_fatal (_("Broken assembler.  No assembly attempted."));
231
232   encode (&machine_opcodes[insn_index ("l.jalr")], &jalr_r9_opcode, 9, 'B');
233 }
234
235 /* Returs non zero if instruction is to be used.  */
236
237 static int
238 check_invalid_opcode (opcode)
239      unsigned long opcode;
240 {
241   return opcode == jalr_r9_opcode;
242 }
243
244 /* Assemble a single instruction.  Its label has already been handled
245    by the generic front end.  We just parse opcode and operands, and
246    produce the bytes of data and relocation.  */
247
248 void
249 md_assemble (str)
250      char *str;
251 {
252   char *toP;
253
254 #if DEBUG
255   printf ("NEW INSTRUCTION\n");
256 #endif
257
258   know (str);
259   machine_ip (str);
260   toP = frag_more (4);
261
262   /* Put out the opcode.  */
263   md_number_to_chars (toP, the_insn.opcode, 4);
264
265   /* Put out the symbol-dependent stuff.  */
266 #ifdef BFD_ASSEMBLER
267   if (the_insn.reloc != BFD_RELOC_NONE)
268 #else
269   if (the_insn.reloc != NO_RELOC)
270 #endif
271     {
272       fix_new_exp (frag_now,
273                    (toP - frag_now->fr_literal + the_insn.reloc_offset),
274                    4,   /* size */
275                    &the_insn.exp,
276                    the_insn.pcrel,
277                    the_insn.reloc);
278     }
279 }
280
281 /* This is true of the we have issued a "lo(" or "hi"(.  */
282 static int waiting_for_shift = 0;
283
284 static int mask_or_shift = 0;
285
286 #ifdef BFD_ASSEMBLER
287 static char *
288 parse_operand (s, operandp, opt)
289      char *s;
290      expressionS *operandp;
291      int opt;
292 {
293   char *save = input_line_pointer;
294   char *new;
295
296 #if DEBUG
297   printf ("  PROCESS NEW OPERAND(%s) == %c (%d)\n", s, opt ? opt : '!', opt);
298 #endif
299
300   input_line_pointer = s;
301
302   if (strncasecmp (s, "HI(", 3) == 0)
303     {
304       waiting_for_shift = 1;
305       mask_or_shift = BFD_RELOC_HI16;
306
307       input_line_pointer += 3;
308     }
309   else if (strncasecmp (s, "LO(", 3) == 0)
310     {
311       mask_or_shift = BFD_RELOC_LO16;
312
313       input_line_pointer += 3;
314     }
315   else
316     mask_or_shift = 0;
317
318   if ((*s == '(') && (*(s+1) == 'r'))
319     s++;
320
321   if ((*s == 'r') && ISDIGIT (*(s + 1)))
322     {
323       operandp->X_add_number = strtol (s + 1, NULL, 10);
324       operandp->X_op = O_register;
325       for (; (*s != ',') && (*s != '\0');)
326         s++;
327       input_line_pointer = save;
328       return s;
329     }
330
331   expression (operandp);
332
333   if (operandp->X_op == O_absent)
334     {
335       if (! opt)
336         as_bad (_("missing operand"));
337       else
338         {
339           operandp->X_add_number = 0;
340           operandp->X_op = O_constant;
341         }
342     }
343
344   new = input_line_pointer;
345   input_line_pointer = save;
346
347 #if DEBUG
348   printf ("  %s=parse_operand(%s): operandp->X_op = %u\n", new, s, operandp->X_op);
349 #endif
350
351   return new;
352 }
353 #else
354
355 char *
356 parse_operand (s, operandp, opt)
357      char *s;
358      expressionS *operandp;
359      int opt;
360 {
361   char *save = input_line_pointer;
362   char *new;
363
364 #if DEBUG
365   printf ("  PROCESS NEW OPERAND(%s) == %c (%d)\n", s, opt ? opt : '!', opt);
366 #endif
367
368   input_line_pointer = s;
369
370   if (strncasecmp (s, "HI(", 3) == 0)
371     {
372       waiting_for_shift = 1;
373       mask_or_shift = RELOC_CONSTH;
374
375       input_line_pointer += 3;
376     }
377   else if (strncasecmp (s, "LO(", 3) == 0)
378     {
379       mask_or_shift = RELOC_CONST;
380
381       input_line_pointer += 3;
382     }
383   else
384     mask_or_shift = 0;
385
386
387   expression (operandp);
388
389   if (operandp->X_op == O_absent)
390     {
391       if (! opt)
392         as_bad (_("missing operand"));
393       else
394         {
395           operandp->X_add_number = 0;
396           operandp->X_op = O_constant;
397         }
398     }
399
400   new = input_line_pointer;
401   input_line_pointer = save;
402
403   if ((operandp->X_op == O_symbol) && (*s != '_'))
404     {
405 #if DEBUG
406       printf ("symbol: '%s'\n", save);
407 #endif
408
409       for (save = s; s < new; s++)
410         if ((*s == REGISTER_PREFIX) && (*(s + 1) == 'r')) /* Register prefix.  */
411           s++;
412
413         if ((*s == 'r') && ISDIGIT (*(s + 1)))
414           {
415             operandp->X_add_number = strtol (s + 1, NULL, 10);
416             operandp->X_op = O_register;
417           }
418       s = save;
419     }
420
421 #if DEBUG
422   printf ("  %s=parse_operand(%s): operandp->X_op = %u\n", new, s, operandp->X_op);
423 #endif
424
425   return new;
426 }
427 #endif
428
429 /* Instruction parsing.  Takes a string containing the opcode.
430    Operands are at input_line_pointer.  Output is in the_insn.
431    Warnings or errors are generated.  */
432
433 #ifdef BFD_ASSEMBLER
434 static void
435 machine_ip (str)
436      char *str;
437 {
438   char *s;
439   const char *args;
440   const struct machine_opcode *insn;
441   char *argsStart;
442   unsigned long opcode;
443   expressionS the_operand;
444   expressionS *operand = &the_operand;
445   unsigned int regno;
446   int reloc = BFD_RELOC_NONE;
447
448 #if DEBUG
449   printf ("machine_ip(%s)\n", str);
450 #endif
451
452   s = str;
453   for (; ISALNUM (*s) || *s == '.'; ++s)
454     if (ISUPPER (*s))
455       *s = TOLOWER (*s);
456
457   switch (*s)
458     {
459     case '\0':
460       break;
461
462     case ' ':     /* FIXME-SOMEDAY more whitespace.  */
463       *s++ = '\0';
464       break;
465
466     default:
467       as_bad (_("unknown opcode1: `%s'"), str);
468       return;
469     }
470
471   if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL)
472     {
473       as_bad (_("unknown opcode2 `%s'."), str);
474       return;
475     }
476
477   argsStart = s;
478   opcode = 0;
479   memset (&the_insn, '\0', sizeof (the_insn));
480   the_insn.reloc = BFD_RELOC_NONE;
481
482   reloc = BFD_RELOC_NONE;
483
484   /* Build the opcode, checking as we go to make sure that the
485      operands match.
486
487      If an operand matches, we modify the_insn or opcode appropriately,
488      and do a "continue".  If an operand fails to match, we "break".  */
489   if (insn->args[0] != '\0')
490     {
491       /* Prime the pump.  */
492       s = parse_operand (s, operand, insn->args[0] == 'I');
493     }
494
495   for (args = insn->args;; ++args)
496     {
497 #if DEBUG
498       printf ("  args = %s\n", args);
499 #endif
500       switch (*args)
501         {
502         case '\0':    /* End of args.  */
503           /* We have have 0 args, do the bazoooka!  */
504           if (args == insn->args)
505             encode (insn, &opcode, 0, 0);
506
507           if (*s == '\0')
508             {
509               /* We are truly done.  */
510               the_insn.opcode = opcode;
511               if (check_invalid_opcode (opcode))
512                 as_bad (_("instruction not allowed: %s"), str);
513               return;
514             }
515           as_bad (_("too many operands: %s"), s);
516           break;
517
518         case ',':   /* Must match a comma.  */
519           if (*s++ == ',')
520             {
521               reloc = BFD_RELOC_NONE;
522
523               /* Parse next operand.  */
524               s = parse_operand (s, operand, args[1] == 'I');
525 #if DEBUG
526               printf ("    ',' case: operand->X_add_number = %d, *args = %s, *s = %s\n",
527                       operand->X_add_number, args, s);
528 #endif
529               continue;
530             }
531           break;
532
533         case '(':   /* Must match a (.  */
534           s = parse_operand (s, operand, args[1] == 'I');
535           continue;
536
537         case ')':   /* Must match a ).  */
538           continue;
539
540         case 'r':   /* A general register.  */
541           args++;
542
543           if (operand->X_op != O_register)
544             break;    /* Only registers.  */
545
546           know (operand->X_add_symbol == 0);
547           know (operand->X_op_symbol == 0);
548           regno = operand->X_add_number;
549           encode (insn, &opcode, regno, *args);
550 #if DEBUG
551           printf ("    r: operand->X_op = %d\n", operand->X_op);
552 #endif
553           continue;
554
555         default:
556           /* if (! ISALPHA (*args))
557                break;  */   /* Only immediate values.  */
558
559           if (mask_or_shift)
560             {
561 #if DEBUG
562               printf ("mask_or_shift = %d\n", mask_or_shift);
563 #endif
564               reloc = mask_or_shift;
565             }
566           mask_or_shift = 0;
567
568           if (strncasecmp (args, "LO(", 3) == 0)
569             {
570 #if DEBUG
571               printf ("reloc_const\n");
572 #endif
573               reloc = BFD_RELOC_LO16;
574             }
575           else if (strncasecmp (args, "HI(", 3) == 0)
576             {
577 #if DEBUG
578               printf ("reloc_consth\n");
579 #endif
580               reloc = BFD_RELOC_HI16;
581             }
582
583           if (*s == '(')
584             {
585               operand->X_op = O_constant;
586 #if 0
587               operand->X_add_number = 0; /* ??? if enabled load/store offsets
588                                             are zero.  */
589 #endif
590             }
591           else if (*s == ')')
592             s += 1;
593 #if DEBUG
594           printf ("    default case: operand->X_add_number = %d, *args = %s, *s = %s\n", operand->X_add_number, args, s);
595 #endif
596           if (operand->X_op == O_constant)
597             {
598               if (reloc == BFD_RELOC_NONE)
599                 {
600                   bfd_vma v, mask;
601
602                   mask = 0x3ffffff;
603                   v = abs (operand->X_add_number) & ~ mask;
604                   if (v)
605                     as_bad (_("call/jmp target out of range (1)"));
606                 }
607
608               if (reloc == BFD_RELOC_HI16)
609                 operand->X_add_number = ((operand->X_add_number >> 16) & 0xffff);
610
611               the_insn.pcrel = 0;
612               encode (insn, &opcode, operand->X_add_number, *args);
613  /*             the_insn.reloc = BFD_RELOC_NONE; */
614               continue;
615             }
616
617           if (reloc == BFD_RELOC_NONE)
618             the_insn.reloc = BFD_RELOC_32_GOT_PCREL;
619           else
620             the_insn.reloc = reloc;
621
622           /* the_insn.reloc = insn->reloc;  */
623 #if DEBUG
624           printf ("    reloc sym=%d\n", the_insn.reloc);
625           printf ("    BFD_RELOC_NONE=%d\n", BFD_RELOC_NONE);
626 #endif
627           the_insn.exp = *operand;
628
629           /*  the_insn.reloc_offset = 1;  */
630           the_insn.pcrel = 1; /* Assume PC-relative jump.  */
631
632           /* FIXME-SOON, Do we figure out whether abs later, after
633              know sym val?  */
634           if (reloc == BFD_RELOC_LO16 || reloc == BFD_RELOC_HI16)
635             the_insn.pcrel = 0;
636
637           encode (insn, &opcode, operand->X_add_number, *args);
638           continue;
639         }
640
641       /* Types or values of args don't match.  */
642       as_bad (_("invalid operands"));
643       return;
644     }
645 }
646
647 #else
648
649 static void
650 machine_ip (str)
651      char *str;
652 {
653   char *s;
654   const char *args;
655   const struct machine_opcode *insn;
656   char *argsStart;
657   unsigned long opcode;
658   expressionS the_operand;
659   expressionS *operand = &the_operand;
660   unsigned int regno;
661   int reloc = NO_RELOC;
662
663 #if DEBUG
664   printf ("machine_ip(%s)\n", str);
665 #endif
666
667   s = str;
668   for (; ISALNUM (*s) || *s == '.'; ++s)
669     if (ISUPPER (*s))
670       *s = TOLOWER (*s);
671
672   switch (*s)
673     {
674     case '\0':
675       break;
676
677     case ' ':     /* FIXME-SOMEDAY more whitespace.  */
678       *s++ = '\0';
679       break;
680
681     default:
682       as_bad (_("unknown opcode1: `%s'"), str);
683       return;
684     }
685
686   if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL)
687     {
688       as_bad (_("unknown opcode2 `%s'."), str);
689       return;
690     }
691
692   argsStart = s;
693   opcode = 0;
694   memset (&the_insn, '\0', sizeof (the_insn));
695   the_insn.reloc = NO_RELOC;
696
697   reloc = NO_RELOC;
698
699   /* Build the opcode, checking as we go to make sure that the
700      operands match.
701
702      If an operand matches, we modify the_insn or opcode appropriately,
703      and do a "continue".  If an operand fails to match, we "break".  */
704   if (insn->args[0] != '\0')
705     /* Prime the pump.  */
706     s = parse_operand (s, operand,
707                        insn->args[0] == 'I'
708                        || strcmp (insn->name, "l.nop") == 0);
709
710   for (args = insn->args;; ++args)
711     {
712 #if DEBUG
713       printf ("  args = %s\n", args);
714 #endif
715       switch (*args)
716         {
717         case '\0':    /* End of args.  */
718           /* We have have 0 args, do the bazoooka!  */
719           if (args == insn->args)
720             encode (insn, &opcode, 0, 0);
721
722           if (*s == '\0')
723             {
724               /* We are truly done.  */
725               the_insn.opcode = opcode;
726               if (check_invalid_opcode (opcode))
727                 as_bad (_("instruction not allowed: %s"), str);
728               return;
729             }
730           as_bad (_("too many operands: %s"), s);
731           break;
732
733         case ',':   /* Must match a comma.  */
734           if (*s++ == ',')
735             {
736               reloc = NO_RELOC;
737
738               /* Parse next operand.  */
739               s = parse_operand (s, operand, args[1] == 'I');
740 #if DEBUG
741               printf ("    ',' case: operand->X_add_number = %d, *args = %s, *s = %s\n",
742                       operand->X_add_number, args, s);
743 #endif
744               continue;
745             }
746           break;
747
748         case '(':   /* Must match a (.  */
749           s = parse_operand (s, operand, args[1] == 'I');
750           continue;
751
752         case ')':   /* Must match a ).  */
753           continue;
754
755         case 'r':   /* A general register.  */
756           args++;
757
758           if (operand->X_op != O_register)
759             break;    /* Only registers.  */
760
761           know (operand->X_add_symbol == 0);
762           know (operand->X_op_symbol == 0);
763           regno = operand->X_add_number;
764           encode (insn, &opcode, regno, *args);
765 #if DEBUG
766           printf ("    r: operand->X_op = %d\n", operand->X_op);
767 #endif
768           continue;
769
770         default:
771           /* if (! ISALPHA (*args))
772                break;  */   /* Only immediate values.  */
773
774           if (mask_or_shift)
775             {
776 #if DEBUG
777               printf ("mask_or_shift = %d\n", mask_or_shift);
778 #endif
779               reloc = mask_or_shift;
780             }
781           mask_or_shift = 0;
782
783           if (strncasecmp (args, "LO(", 3) == 0)
784             {
785 #if DEBUG
786               printf ("reloc_const\n");
787 #endif
788               reloc = RELOC_CONST;
789             }
790           else if (strncasecmp (args, "HI(", 3) == 0)
791             {
792 #if DEBUG
793               printf ("reloc_consth\n");
794 #endif
795               reloc = RELOC_CONSTH;
796             }
797
798           if (*s == '(')
799             {
800               operand->X_op = O_constant;
801 #if 0
802               operand->X_add_number = 0; /* ??? if enabled load/store offsets
803                                             are zero.  */
804 #endif
805             }
806           else if (*s == ')')
807             s += 1;
808 #if DEBUG
809           printf ("    default case: operand->X_add_number = %d, *args = %s, *s = %s\n",
810                   operand->X_add_number, args, s);
811 #endif
812           if (operand->X_op == O_constant)
813             {
814               if (reloc == NO_RELOC)
815                 {
816                   unsigned long v, mask;
817
818                   mask = 0x3ffffff;
819                   v = abs (operand->X_add_number) & ~ mask;
820                   if (v)
821                     as_bad (_("call/jmp target out of range (1)"));
822                 }
823
824               if (reloc == RELOC_CONSTH)
825                 operand->X_add_number = ((operand->X_add_number>>16) & 0xffff);
826
827               the_insn.pcrel = 0;
828               encode (insn, &opcode, operand->X_add_number, *args);
829               /* the_insn.reloc = NO_RELOC; */
830               continue;
831             }
832
833           if (reloc == NO_RELOC)
834             the_insn.reloc = RELOC_JUMPTARG;
835           else
836             the_insn.reloc = reloc;
837 #if DEBUG
838           printf ("    reloc sym=%d\n", the_insn.reloc);
839           printf ("    NO_RELOC=%d\n", NO_RELOC);
840 #endif
841           the_insn.exp = *operand;
842
843           /*  the_insn.reloc_offset = 1;  */
844           the_insn.pcrel = 1; /* Assume PC-relative jump.  */
845
846           /* FIXME-SOON, Do we figure out whether abs later, after
847              know sym val?  */
848           if (reloc == RELOC_CONST || reloc == RELOC_CONSTH)
849             the_insn.pcrel = 0;
850
851           encode (insn, &opcode, operand->X_add_number, *args);
852           continue;
853         }
854
855       /* Types or values of args don't match.  */
856       as_bad (_("invalid operands"));
857       return;
858     }
859 }
860 #endif
861
862 /* This is identical to the md_atof in m68k.c.  I think this is right,
863    but I'm not sure.
864
865    Turn a string in input_line_pointer into a floating point constant
866    of type type, and store the appropriate bytes in *litP.  The number
867    of LITTLENUMS emitted is stored in *sizeP .  An error message is
868    returned, or NULL on OK.  */
869
870 /* Equal to MAX_PRECISION in atof-ieee.c.  */
871 #define MAX_LITTLENUMS 6
872
873 char *
874 md_atof (type, litP, sizeP)
875      char   type;
876      char * litP;
877      int *  sizeP;
878 {
879   int prec;
880   LITTLENUM_TYPE words[MAX_LITTLENUMS];
881   LITTLENUM_TYPE *wordP;
882   char *t;
883
884   switch (type)
885     {
886     case 'f':
887     case 'F':
888     case 's':
889     case 'S':
890       prec = 2;
891       break;
892
893     case 'd':
894     case 'D':
895     case 'r':
896     case 'R':
897       prec = 4;
898       break;
899
900     case 'x':
901     case 'X':
902       prec = 6;
903       break;
904
905     case 'p':
906     case 'P':
907       prec = 6;
908       break;
909
910     default:
911       *sizeP = 0;
912       return _("Bad call to MD_ATOF()");
913     }
914
915   t = atof_ieee (input_line_pointer, type, words);
916   if (t)
917     input_line_pointer = t;
918
919   *sizeP = prec * sizeof (LITTLENUM_TYPE);
920
921   for (wordP = words; prec--;)
922     {
923       md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE));
924       litP += sizeof (LITTLENUM_TYPE);
925     }
926
927   return NULL;
928 }
929
930 /* Write out big-endian.  */
931
932 void
933 md_number_to_chars (buf, val, n)
934      char *buf;
935      valueT val;
936      int n;
937 {
938   number_to_chars_bigendian (buf, val, n);
939 }
940
941 #ifdef BFD_ASSEMBLER
942 void
943 md_apply_fix3 (fixP, val, seg)
944      fixS *   fixP;
945      valueT * val;
946      segT     seg ATTRIBUTE_UNUSED;
947 {
948   char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
949   long t_val;
950
951   t_val = (long) *val;
952
953 #if DEBUG
954   printf ("md_apply_fix val:%x\n", t_val);
955 #endif
956
957   fixP->fx_addnumber = t_val; /* Remember value for emit_reloc.  */
958
959   know (fixP->fx_size == 4);
960   know (fixP->fx_r_type < BFD_RELOC_NONE);
961
962   switch (fixP->fx_r_type)
963     {
964     case BFD_RELOC_32:      /* XXXXXXXX pattern in a word.  */
965 #if DEBUG
966       printf ("reloc_const: val=%x\n", t_val);
967 #endif
968       buf[0] = t_val >> 24;
969       buf[1] = t_val >> 16;
970       buf[2] = t_val >> 8;
971       buf[3] = t_val;
972       break;
973
974     case BFD_RELOC_16:      /* XXXX0000 pattern in a word.  */
975 #if DEBUG
976       printf ("reloc_const: val=%x\n", t_val);
977 #endif
978       buf[0] = t_val >> 8;
979       buf[1] = t_val;
980       break;
981
982     case BFD_RELOC_8:      /* XX000000 pattern in a word.  */
983 #if DEBUG
984       printf ("reloc_const: val=%x\n", t_val);
985 #endif
986       buf[0] = t_val;
987       break;
988
989     case BFD_RELOC_LO16:      /* 0000XXXX pattern in a word.  */
990 #if DEBUG
991       printf ("reloc_const: val=%x\n", t_val);
992 #endif
993       buf[2] = t_val >> 8;  /* Holds bits 0000XXXX.  */
994       buf[3] = t_val;
995       break;
996
997     case BFD_RELOC_HI16:    /* 0000XXXX pattern in a word.  */
998 #if DEBUG
999       printf ("reloc_consth: val=%x\n", t_val);
1000 #endif
1001       buf[2] = t_val >> 24; /* Holds bits XXXX0000.  */
1002       buf[3] = t_val >> 16;
1003       break;
1004
1005     case BFD_RELOC_32_GOT_PCREL:  /* 0000XXXX pattern in a word.  */
1006       if (!fixP->fx_done)
1007         {
1008           /* The linker tries to support both AMD and old GNU style
1009              R_IREL relocs.  That means that if the addend is exactly
1010              the negative of the address within the section, the
1011              linker will not handle it correctly.  */
1012 #if 0
1013           if (fixP->fx_pcrel
1014               && t_val != 0
1015               && t_val == - (fixP->fx_frag->fr_address + fixP->fx_where))
1016             as_bad_where
1017               (fixP->fx_file, fixP->fx_line,
1018                _("the linker will not handle this relocation correctly (1)"));
1019 #endif
1020         }
1021       else if (fixP->fx_pcrel)
1022         {
1023           long v = t_val >> 28;
1024
1025           if (v != 0 && v != -1)
1026             as_bad_where (fixP->fx_file, fixP->fx_line,
1027                           _("call/jmp target out of range (2)"));
1028         }
1029       else
1030         /* This case was supposed to be handled in machine_ip.  */
1031         abort ();
1032
1033       buf[0] |= (t_val >> 26) & 0x03; /* Holds bits 0FFFFFFC of address.  */
1034       buf[1] = t_val >> 18;
1035       buf[2] = t_val >> 10;
1036       buf[3] = t_val >> 2;
1037       break;
1038
1039     case BFD_RELOC_VTABLE_INHERIT:
1040     case BFD_RELOC_VTABLE_ENTRY:
1041       fixP->fx_done = 0;
1042       break;
1043
1044     case BFD_RELOC_NONE:
1045     default:
1046       as_bad (_("bad relocation type: 0x%02x"), fixP->fx_r_type);
1047       break;
1048     }
1049
1050   if (fixP->fx_addsy == (symbolS *) NULL)
1051     fixP->fx_done = 1;
1052 }
1053 #else
1054 void
1055 md_apply_fix3 (fixP, valP, seg)
1056      fixS *fixP;
1057      valueT *valP;
1058      segT seg ATTRIBUTE_UNUSED;
1059 {
1060   long val = *(long*)valP;
1061   char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1062
1063 #if DEBUG
1064   printf ("md_apply_fix val:%x\n", val);
1065 #endif
1066
1067   fixP->fx_addnumber = val; /* Remember value for emit_reloc.  */
1068
1069   know (fixP->fx_size == 4);
1070   know (fixP->fx_r_type < NO_RELOC);
1071
1072   /* This is a hack.  There should be a better way to handle this.  */
1073   if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy)
1074     val += fixP->fx_where + fixP->fx_frag->fr_address;
1075
1076   switch (fixP->fx_r_type)
1077     {
1078     case RELOC_32:
1079       buf[0] = val >> 24;
1080       buf[1] = val >> 16;
1081       buf[2] = val >> 8;
1082       buf[3] = val;
1083       break;
1084
1085     case RELOC_8:
1086       buf[0] = val;
1087       break;
1088
1089     case RELOC_WDISP30:
1090       val = (val >>= 2) + 1;
1091       buf[0] |= (val >> 24) & 0x3f;
1092       buf[1] = (val >> 16);
1093       buf[2] = val >> 8;
1094       buf[3] = val;
1095       break;
1096
1097     case RELOC_HI22:
1098       buf[1] |= (val >> 26) & 0x3f;
1099       buf[2] = val >> 18;
1100       buf[3] = val >> 10;
1101       break;
1102
1103     case RELOC_LO10:
1104       buf[2] |= (val >> 8) & 0x03;
1105       buf[3] = val;
1106       break;
1107
1108     case RELOC_BASE13:
1109       buf[2] |= (val >> 8) & 0x1f;
1110       buf[3] = val;
1111       break;
1112
1113     case RELOC_WDISP22:
1114       val = (val >>= 2) + 1;
1115       /* FALLTHROUGH */
1116     case RELOC_BASE22:
1117       buf[1] |= (val >> 16) & 0x3f;
1118       buf[2] = val >> 8;
1119       buf[3] = val;
1120       break;
1121
1122     case RELOC_JUMPTARG:  /* 0000XXXX pattern in a word.  */
1123       if (!fixP->fx_done)
1124         {
1125           /* The linker tries to support both AMD and old GNU style
1126              R_IREL relocs.  That means that if the addend is exactly
1127              the negative of the address within the section, the
1128              linker will not handle it correctly.  */
1129 #if 0
1130           if (fixP->fx_pcrel
1131               && val != 0
1132               && val == - (fixP->fx_frag->fr_address + fixP->fx_where))
1133             as_bad_where
1134               (fixP->fx_file, fixP->fx_line,
1135                _("the linker will not handle this relocation correctly (1)"));
1136 #endif
1137         }
1138       else if (fixP->fx_pcrel)
1139         {
1140           long v = val >> 28;
1141 #if 1
1142           if (v != 0 && v != -1)
1143             as_bad_where (fixP->fx_file, fixP->fx_line,
1144                           _("call/jmp target out of range (2)"));
1145 #endif
1146         }
1147       else
1148         /* This case was supposed to be handled in machine_ip.  */
1149         abort ();
1150
1151       buf[0] |= (val >> 26) & 0x03; /* Holds bits 0FFFFFFC of address.  */
1152       buf[1] = val >> 18;
1153       buf[2] = val >> 10;
1154       buf[3] = val >> 2;
1155       break;
1156
1157     case RELOC_CONST:     /* 0000XXXX pattern in a word.  */
1158 #if DEBUG
1159       printf ("reloc_const: val=%x\n", val);
1160 #endif
1161       buf[2] = val >> 8;  /* Holds bits 0000XXXX.  */
1162       buf[3] = val;
1163       break;
1164
1165     case RELOC_CONSTH:    /* 0000XXXX pattern in a word.  */
1166 #if DEBUG
1167       printf ("reloc_consth: val=%x\n", val);
1168 #endif
1169       buf[2] = val >> 24; /* Holds bits XXXX0000.  */
1170       buf[3] = val >> 16;
1171       break;
1172
1173     case BFD_RELOC_VTABLE_INHERIT:
1174     case BFD_RELOC_VTABLE_ENTRY:
1175       fixP->fx_done = 0;
1176       break;
1177
1178     case NO_RELOC:
1179     default:
1180       as_bad (_("bad relocation type: 0x%02x"), fixP->fx_r_type);
1181       break;
1182     }
1183
1184   if (fixP->fx_addsy == (symbolS *) NULL)
1185     fixP->fx_done = 1;
1186 }
1187 #endif
1188
1189 #ifdef OBJ_COFF
1190 short
1191 tc_coff_fix2rtype (fixP)
1192      fixS *fixP;
1193 {
1194 #if DEBUG
1195   printf ("tc_coff_fix2rtype\n");
1196 #endif
1197
1198   switch (fixP->fx_r_type)
1199     {
1200     case RELOC_32:
1201       return (R_WORD);
1202     case RELOC_8:
1203       return (R_BYTE);
1204     case RELOC_CONST:
1205       return (R_ILOHALF);
1206     case RELOC_CONSTH:
1207       return (R_IHIHALF);
1208     case RELOC_JUMPTARG:
1209       return (R_IREL);
1210     default:
1211       printf ("need %d\n", fixP->fx_r_type);
1212       abort ();
1213     }
1214
1215   return 0;
1216 }
1217
1218 #endif /* OBJ_COFF */
1219
1220 /* Should never be called for or32.  */
1221
1222 void
1223 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
1224      char *    ptr       ATTRIBUTE_UNUSED;
1225      addressT  from_addr ATTRIBUTE_UNUSED;
1226      addressT  to_addr   ATTRIBUTE_UNUSED;
1227      fragS *   frag      ATTRIBUTE_UNUSED;
1228      symbolS * to_symbol ATTRIBUTE_UNUSED;
1229 {
1230   as_fatal ("or32_create_short_jmp\n");
1231 }
1232
1233 /* Should never be called for or32.  */
1234
1235 #ifndef BFD_ASSEMBLER
1236 void
1237 md_convert_frag (headers, seg, fragP)
1238      object_headers * headers ATTRIBUTE_UNUSED;
1239      segT             seg     ATTRIBUTE_UNUSED;
1240      register fragS * fragP   ATTRIBUTE_UNUSED;
1241 {
1242   as_fatal ("or32_convert_frag\n");
1243 }
1244
1245 #else
1246 void
1247 md_convert_frag (headers, seg, fragP)
1248      bfd *   headers ATTRIBUTE_UNUSED;
1249      segT    seg     ATTRIBUTE_UNUSED;
1250      fragS * fragP   ATTRIBUTE_UNUSED;
1251 {
1252   as_fatal ("or32_convert_frag\n");
1253 }
1254 #endif
1255
1256 /* Should never be called for or32.  */
1257
1258 void
1259 md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
1260      char *    ptr       ATTRIBUTE_UNUSED;
1261      addressT  from_addr ATTRIBUTE_UNUSED;
1262      addressT  to_addr   ATTRIBUTE_UNUSED;
1263      fragS *   frag      ATTRIBUTE_UNUSED;
1264      symbolS * to_symbol ATTRIBUTE_UNUSED;
1265 {
1266   as_fatal ("or32_create_long_jump\n");
1267 }
1268
1269 /* Should never be called for or32.  */
1270
1271 int
1272 md_estimate_size_before_relax (fragP, segtype)
1273      fragS * fragP   ATTRIBUTE_UNUSED;
1274      segT    segtype ATTRIBUTE_UNUSED;
1275 {
1276   as_fatal ("or32_estimate_size_before_relax\n");
1277   return 0;
1278 }
1279
1280 /* Translate internal representation of relocation info to target format.
1281
1282    On sparc/29k: first 4 bytes are normal unsigned long address, next three
1283    bytes are index, most sig. byte first.  Byte 7 is broken up with
1284    bit 7 as external, bits 6 & 5 unused, and the lower
1285    five bits as relocation type.  Next 4 bytes are long addend.  */
1286 /* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com.  */
1287
1288 #ifdef OBJ_AOUT
1289 void
1290 tc_aout_fix_to_chars (where, fixP, segment_address_in_file)
1291      char *where;
1292      fixS *fixP;
1293      relax_addressT segment_address_in_file;
1294 {
1295   long r_symbolnum;
1296
1297 #if DEBUG
1298   printf ("tc_aout_fix_to_chars\n");
1299 #endif
1300
1301   know (fixP->fx_r_type < BFD_RELOC_NONE);
1302   know (fixP->fx_addsy != NULL);
1303
1304   md_number_to_chars
1305     (where,
1306      fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
1307      4);
1308
1309   r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy)
1310      ? S_GET_TYPE (fixP->fx_addsy)
1311      : fixP->fx_addsy->sy_number);
1312
1313   where[4] = (r_symbolnum >> 16) & 0x0ff;
1314   where[5] = (r_symbolnum >> 8) & 0x0ff;
1315   where[6] = r_symbolnum & 0x0ff;
1316   where[7] = (((!S_IS_DEFINED (fixP->fx_addsy)) << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F);
1317
1318   /* Also easy.  */
1319   md_number_to_chars (&where[8], fixP->fx_addnumber, 4);
1320 }
1321
1322 #endif /* OBJ_AOUT */
1323 \f
1324 const char *md_shortopts = "";
1325
1326 struct option md_longopts[] =
1327   {
1328     { NULL, no_argument, NULL, 0 }
1329   };
1330 size_t md_longopts_size = sizeof (md_longopts);
1331
1332 int
1333 md_parse_option (c, arg)
1334      int    c   ATTRIBUTE_UNUSED;
1335      char * arg ATTRIBUTE_UNUSED;
1336 {
1337   return 0;
1338 }
1339
1340 void
1341 md_show_usage (stream)
1342      FILE * stream ATTRIBUTE_UNUSED;
1343 {
1344 }
1345 \f
1346 /* This is called when a line is unrecognized.  This is used to handle
1347    definitions of or32 style local labels.  */
1348
1349 int
1350 or32_unrecognized_line (c)
1351      int c;
1352 {
1353   int lab;
1354   char *s;
1355
1356   if (c != '$'
1357       || ! ISDIGIT ((unsigned char) input_line_pointer[0]))
1358     return 0;
1359
1360   s = input_line_pointer;
1361
1362   lab = 0;
1363   while (ISDIGIT ((unsigned char) *s))
1364     {
1365       lab = lab * 10 + *s - '0';
1366       ++s;
1367     }
1368
1369   if (*s != ':')
1370     /* Not a label definition.  */
1371     return 0;
1372
1373   if (dollar_label_defined (lab))
1374     {
1375       as_bad (_("label \"$%d\" redefined"), lab);
1376       return 0;
1377     }
1378
1379   define_dollar_label (lab);
1380   colon (dollar_label_name (lab, 0));
1381   input_line_pointer = s + 1;
1382
1383   return 1;
1384 }
1385
1386 #ifndef BFD_ASSEMBLER
1387 /* Record a fixup for a cons expression.  */
1388 /*
1389   void
1390 or32_cons_fix_new (frag, where, nbytes, exp)
1391      fragS *frag;
1392      int where;
1393      int nbytes;
1394      expressionS *exp;
1395 {
1396   fix_new_exp (frag, where, nbytes, exp, 0,
1397                    nbytes == 5 ? RELOC_32
1398                    : nbytes == 2 ? RELOC_16
1399                    : RELOC_8);
1400 }
1401 void
1402 tc_aout_pre_write_hook ()
1403 {
1404 #if DEBUG
1405   printf ("In tc_aout_pre_write_hook()\n");
1406 #endif
1407 }
1408 */
1409 #endif
1410
1411 /* Default the values of symbols known that should be "predefined".  We
1412    don't bother to predefine them unless you actually use one, since there
1413    are a lot of them.  */
1414
1415 symbolS *
1416 md_undefined_symbol (name)
1417      char *name ATTRIBUTE_UNUSED;
1418 {
1419 #ifndef BFD_ASSEMBLER
1420   long regnum;
1421   char testbuf[5 + /*SLOP*/ 5];
1422
1423 #if DEBUG
1424   printf ("md_undefined_symbol(%s)\n", name);
1425 #endif
1426
1427   /* Register name.  */
1428   if (name[0] == 'r' || name[0] == 'R' || name[0] == 'a' || name[0] == 'b')
1429     {
1430       long maxreg;
1431
1432       /* Parse the number, make sure it has no extra zeroes or
1433          trailing chars.  */
1434       regnum = atol (& name[1]);
1435
1436       if (regnum > 31)
1437         as_fatal (_("register out of range"));
1438
1439       sprintf (testbuf, "%ld", regnum);
1440
1441       if (strcmp (testbuf, &name[1]) != 0)
1442         return NULL;  /* gr007 or lr7foo or whatever.  */
1443
1444       /* We have a wiener!  Define and return a new symbol for it.  */
1445       return (symbol_new (name, SEG_REGISTER, (valueT) regnum,
1446                           &zero_address_frag));
1447     }
1448 #endif
1449   return NULL;
1450 }
1451
1452 /* Parse an operand that is machine-specific.  */
1453
1454 void
1455 md_operand (expressionP)
1456      expressionS *expressionP;
1457 {
1458 #if DEBUG
1459   printf ("  md_operand(input_line_pointer = %s)\n", input_line_pointer);
1460 #endif
1461
1462   if (input_line_pointer[0] == REGISTER_PREFIX && input_line_pointer[1] == 'r')
1463     {
1464       /* We have a numeric register expression.  No biggy.  */
1465       input_line_pointer += 2;  /* Skip %r */
1466       (void) expression (expressionP);
1467
1468       if (expressionP->X_op != O_constant
1469           || expressionP->X_add_number > 255)
1470         as_bad (_("Invalid expression after %%%%\n"));
1471       expressionP->X_op = O_register;
1472     }
1473   else if (input_line_pointer[0] == '&')
1474     {
1475       /* We are taking the 'address' of a register...this one is not
1476          in the manual, but it *is* in traps/fpsymbol.h!  What they
1477          seem to want is the register number, as an absolute number.  */
1478       input_line_pointer++; /* Skip & */
1479       (void) expression (expressionP);
1480
1481       if (expressionP->X_op != O_register)
1482         as_bad (_("invalid register in & expression"));
1483       else
1484         expressionP->X_op = O_constant;
1485     }
1486   else if (input_line_pointer[0] == '$'
1487            && ISDIGIT ((unsigned char) input_line_pointer[1]))
1488     {
1489       long lab;
1490       char *name;
1491       symbolS *sym;
1492
1493       /* This is a local label.  */
1494       ++input_line_pointer;
1495       lab = (long) get_absolute_expression ();
1496
1497       if (dollar_label_defined (lab))
1498         {
1499           name = dollar_label_name (lab, 0);
1500           sym = symbol_find (name);
1501         }
1502       else
1503         {
1504           name = dollar_label_name (lab, 1);
1505           sym = symbol_find_or_make (name);
1506         }
1507
1508       expressionP->X_op = O_symbol;
1509       expressionP->X_add_symbol = sym;
1510       expressionP->X_add_number = 0;
1511     }
1512   else if (input_line_pointer[0] == '$')
1513     {
1514       char *s;
1515       char type;
1516       int fieldnum, fieldlimit;
1517       LITTLENUM_TYPE floatbuf[8];
1518
1519       /* $float(), $doubleN(), or $extendN() convert floating values
1520          to integers.  */
1521       s = input_line_pointer;
1522
1523       ++s;
1524
1525       fieldnum = 0;
1526       if (strncmp (s, "double", sizeof "double" - 1) == 0)
1527         {
1528           s += sizeof "double" - 1;
1529           type = 'd';
1530           fieldlimit = 2;
1531         }
1532       else if (strncmp (s, "float", sizeof "float" - 1) == 0)
1533         {
1534           s += sizeof "float" - 1;
1535           type = 'f';
1536           fieldlimit = 1;
1537         }
1538       else if (strncmp (s, "extend", sizeof "extend" - 1) == 0)
1539         {
1540           s += sizeof "extend" - 1;
1541           type = 'x';
1542           fieldlimit = 4;
1543         }
1544       else
1545         return;
1546
1547       if (ISDIGIT (*s))
1548         {
1549           fieldnum = *s - '0';
1550           ++s;
1551         }
1552       if (fieldnum >= fieldlimit)
1553         return;
1554
1555       SKIP_WHITESPACE ();
1556       if (*s != '(')
1557         return;
1558       ++s;
1559       SKIP_WHITESPACE ();
1560
1561       s = atof_ieee (s, type, floatbuf);
1562       if (s == NULL)
1563         return;
1564       s = s;
1565
1566       SKIP_WHITESPACE ();
1567       if (*s != ')')
1568         return;
1569       ++s;
1570       SKIP_WHITESPACE ();
1571
1572       input_line_pointer = s;
1573       expressionP->X_op = O_constant;
1574       expressionP->X_unsigned = 1;
1575       expressionP->X_add_number = ((floatbuf[fieldnum * 2]
1576                                     << LITTLENUM_NUMBER_OF_BITS)
1577                                    + floatbuf[fieldnum * 2 + 1]);
1578     }
1579 }
1580
1581 /* Round up a section size to the appropriate boundary.  */
1582
1583 valueT
1584 md_section_align (segment, size)
1585      segT segment ATTRIBUTE_UNUSED;
1586      valueT size ATTRIBUTE_UNUSED;
1587 {
1588   return size;      /* Byte alignment is fine.  */
1589 }
1590
1591 /* Exactly what point is a PC-relative offset relative TO?
1592    On the 29000, they're relative to the address of the instruction,
1593    which we have set up as the address of the fixup too.  */
1594
1595 long
1596 md_pcrel_from (fixP)
1597      fixS *fixP;
1598 {
1599   return fixP->fx_where + fixP->fx_frag->fr_address;
1600 }
1601
1602 /* Generate a reloc for a fixup.  */
1603
1604 #ifdef BFD_ASSEMBLER
1605 arelent *
1606 tc_gen_reloc (seg, fixp)
1607      asection *seg ATTRIBUTE_UNUSED;
1608      fixS *fixp;
1609 {
1610   arelent *reloc;
1611
1612   reloc = (arelent *) xmalloc (sizeof (arelent));
1613   reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
1614   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
1615   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
1616   /*  reloc->address = fixp->fx_frag->fr_address + fixp->fx_where + fixp->fx_addnumber;*/
1617   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
1618
1619   if (reloc->howto == (reloc_howto_type *) NULL)
1620     {
1621       as_bad_where (fixp->fx_file, fixp->fx_line,
1622                     _("reloc %d not supported by object file format"),
1623                     (int) fixp->fx_r_type);
1624       return NULL;
1625     }
1626
1627   if (   fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY
1628       || fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT)
1629     reloc->addend = fixp->fx_offset;
1630   else
1631   reloc->addend = fixp->fx_addnumber;
1632
1633   return reloc;
1634 }
1635 #endif
1636