* emulparams/elf64ppc.sh (GOT): Fix for shell brace matching.
[binutils.git] / gas / write.c
blob1419ab564eb9ca2c3898d9863ee5819f75dcd5bd
1 /* write.c - emit .o file
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001, 2002, 2003
4 Free Software Foundation, Inc.
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 02111-1307, USA. */
23 /* This thing should be set up to do byteordering correctly. But... */
25 #include "as.h"
26 #include "subsegs.h"
27 #include "obstack.h"
28 #include "output-file.h"
29 #include "dwarf2dbg.h"
31 #ifndef TC_ADJUST_RELOC_COUNT
32 #define TC_ADJUST_RELOC_COUNT(FIX, COUNT)
33 #endif
35 #ifndef TC_FORCE_RELOCATION
36 #define TC_FORCE_RELOCATION(FIX) \
37 (generic_force_reloc (FIX))
38 #endif
40 #ifndef TC_FORCE_RELOCATION_ABS
41 #define TC_FORCE_RELOCATION_ABS(FIX) \
42 (TC_FORCE_RELOCATION (FIX))
43 #endif
45 #ifndef TC_FORCE_RELOCATION_LOCAL
46 #define TC_FORCE_RELOCATION_LOCAL(FIX) \
47 (!(FIX)->fx_pcrel \
48 || (FIX)->fx_plt \
49 || TC_FORCE_RELOCATION (FIX))
50 #endif
52 #ifndef TC_FORCE_RELOCATION_SUB_SAME
53 #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
54 (! SEG_NORMAL (SEG))
55 #endif
57 #ifndef TC_FORCE_RELOCATION_SUB_ABS
58 #define TC_FORCE_RELOCATION_SUB_ABS(FIX) 0
59 #endif
61 #ifndef TC_FORCE_RELOCATION_SUB_LOCAL
62 #ifdef DIFF_EXPR_OK
63 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) 0
64 #else
65 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) 1
66 #endif
67 #endif
69 #ifndef TC_VALIDATE_FIX_SUB
70 #ifdef UNDEFINED_DIFFERENCE_OK
71 /* The PA needs this for PIC code generation. */
72 #define TC_VALIDATE_FIX_SUB(FIX) 1
73 #else
74 #ifdef BFD_ASSEMBLER
75 #define TC_VALIDATE_FIX_SUB(FIX) \
76 ((FIX)->fx_r_type == BFD_RELOC_GPREL32 \
77 || (FIX)->fx_r_type == BFD_RELOC_GPREL16)
78 #else
79 #define TC_VALIDATE_FIX_SUB(FIX) 0
80 #endif
81 #endif
82 #endif
84 #ifndef TC_LINKRELAX_FIXUP
85 #define TC_LINKRELAX_FIXUP(SEG) 1
86 #endif
88 #ifndef MD_APPLY_SYM_VALUE
89 #define MD_APPLY_SYM_VALUE(FIX) 1
90 #endif
92 #ifndef TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
93 #define TC_FINALIZE_SYMS_BEFORE_SIZE_SEG 1
94 #endif
96 #ifndef MD_PCREL_FROM_SECTION
97 #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from (FIX)
98 #endif
100 #ifndef WORKING_DOT_WORD
101 extern const int md_short_jump_size;
102 extern const int md_long_jump_size;
103 #endif
105 /* Used to control final evaluation of expressions. */
106 int finalize_syms = 0;
108 int symbol_table_frozen;
110 symbolS *abs_section_sym;
112 /* Remember the value of dot when parsing expressions. */
113 addressT dot_value;
115 void print_fixup PARAMS ((fixS *));
117 #ifdef BFD_ASSEMBLER
118 static void renumber_sections PARAMS ((bfd *, asection *, PTR));
120 /* We generally attach relocs to frag chains. However, after we have
121 chained these all together into a segment, any relocs we add after
122 that must be attached to a segment. This will include relocs added
123 in md_estimate_size_for_relax, for example. */
124 static int frags_chained = 0;
125 #endif
127 #ifndef BFD_ASSEMBLER
129 #ifndef MANY_SEGMENTS
130 struct frag *text_frag_root;
131 struct frag *data_frag_root;
132 struct frag *bss_frag_root;
134 struct frag *text_last_frag; /* Last frag in segment. */
135 struct frag *data_last_frag; /* Last frag in segment. */
136 static struct frag *bss_last_frag; /* Last frag in segment. */
137 #endif
139 #ifndef BFD
140 static object_headers headers;
141 #endif
143 long string_byte_count;
144 char *next_object_file_charP; /* Tracks object file bytes. */
146 #ifndef OBJ_VMS
147 int magic_number_for_object_file = DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE;
148 #endif
150 #endif /* BFD_ASSEMBLER */
152 static int n_fixups;
154 #ifdef BFD_ASSEMBLER
155 #define RELOC_ENUM enum bfd_reloc_code_real
156 #else
157 #define RELOC_ENUM int
158 #endif
160 static fixS *fix_new_internal PARAMS ((fragS *, int where, int size,
161 symbolS *add, symbolS *sub,
162 offsetT offset, int pcrel,
163 RELOC_ENUM r_type));
164 #if defined (BFD_ASSEMBLER) || (!defined (BFD) && !defined (OBJ_VMS))
165 static long fixup_segment PARAMS ((fixS *, segT));
166 #endif
167 static relax_addressT relax_align PARAMS ((relax_addressT addr, int align));
168 #if defined (BFD_ASSEMBLER) || ! defined (BFD)
169 static fragS *chain_frchains_together_1 PARAMS ((segT, struct frchain *));
170 #endif
171 #ifdef BFD_ASSEMBLER
172 static void chain_frchains_together PARAMS ((bfd *, segT, PTR));
173 static void cvt_frag_to_fill PARAMS ((segT, fragS *));
174 static void adjust_reloc_syms PARAMS ((bfd *, asection *, PTR));
175 static void fix_segment PARAMS ((bfd *, asection *, PTR));
176 static void write_relocs PARAMS ((bfd *, asection *, PTR));
177 static void write_contents PARAMS ((bfd *, asection *, PTR));
178 static void set_symtab PARAMS ((void));
179 #endif
180 #if defined (BFD_ASSEMBLER) || (! defined (BFD) && ! defined (OBJ_AOUT))
181 static void merge_data_into_text PARAMS ((void));
182 #endif
183 #if ! defined (BFD_ASSEMBLER) && ! defined (BFD)
184 static void cvt_frag_to_fill PARAMS ((object_headers *, segT, fragS *));
185 static void remove_subsegs PARAMS ((frchainS *, int, fragS **, fragS **));
186 static void relax_and_size_all_segments PARAMS ((void));
187 #endif
189 /* Create a fixS in obstack 'notes'. */
191 static fixS *
192 fix_new_internal (frag, where, size, add_symbol, sub_symbol, offset, pcrel,
193 r_type)
194 fragS *frag; /* Which frag? */
195 int where; /* Where in that frag? */
196 int size; /* 1, 2, or 4 usually. */
197 symbolS *add_symbol; /* X_add_symbol. */
198 symbolS *sub_symbol; /* X_op_symbol. */
199 offsetT offset; /* X_add_number. */
200 int pcrel; /* TRUE if PC-relative relocation. */
201 RELOC_ENUM r_type ATTRIBUTE_UNUSED; /* Relocation type. */
203 fixS *fixP;
205 n_fixups++;
207 fixP = (fixS *) obstack_alloc (&notes, sizeof (fixS));
209 fixP->fx_frag = frag;
210 fixP->fx_where = where;
211 fixP->fx_size = size;
212 /* We've made fx_size a narrow field; check that it's wide enough. */
213 if (fixP->fx_size != size)
215 as_bad (_("field fx_size too small to hold %d"), size);
216 abort ();
218 fixP->fx_addsy = add_symbol;
219 fixP->fx_subsy = sub_symbol;
220 fixP->fx_offset = offset;
221 fixP->fx_dot_value = dot_value;
222 fixP->fx_pcrel = pcrel;
223 fixP->fx_plt = 0;
224 #if defined(NEED_FX_R_TYPE) || defined (BFD_ASSEMBLER)
225 fixP->fx_r_type = r_type;
226 #endif
227 fixP->fx_im_disp = 0;
228 fixP->fx_pcrel_adjust = 0;
229 fixP->fx_bit_fixP = 0;
230 fixP->fx_addnumber = 0;
231 fixP->fx_tcbit = 0;
232 fixP->fx_done = 0;
233 fixP->fx_no_overflow = 0;
234 fixP->fx_signed = 0;
236 #ifdef USING_CGEN
237 fixP->fx_cgen.insn = NULL;
238 fixP->fx_cgen.opinfo = 0;
239 #endif
241 #ifdef TC_FIX_TYPE
242 TC_INIT_FIX_DATA (fixP);
243 #endif
245 as_where (&fixP->fx_file, &fixP->fx_line);
247 /* Usually, we want relocs sorted numerically, but while
248 comparing to older versions of gas that have relocs
249 reverse sorted, it is convenient to have this compile
250 time option. xoxorich. */
253 #ifdef BFD_ASSEMBLER
254 fixS **seg_fix_rootP = (frags_chained
255 ? &seg_info (now_seg)->fix_root
256 : &frchain_now->fix_root);
257 fixS **seg_fix_tailP = (frags_chained
258 ? &seg_info (now_seg)->fix_tail
259 : &frchain_now->fix_tail);
260 #endif
262 #ifdef REVERSE_SORT_RELOCS
264 fixP->fx_next = *seg_fix_rootP;
265 *seg_fix_rootP = fixP;
267 #else /* REVERSE_SORT_RELOCS */
269 fixP->fx_next = NULL;
271 if (*seg_fix_tailP)
272 (*seg_fix_tailP)->fx_next = fixP;
273 else
274 *seg_fix_rootP = fixP;
275 *seg_fix_tailP = fixP;
277 #endif /* REVERSE_SORT_RELOCS */
280 return fixP;
283 /* Create a fixup relative to a symbol (plus a constant). */
285 fixS *
286 fix_new (frag, where, size, add_symbol, offset, pcrel, r_type)
287 fragS *frag; /* Which frag? */
288 int where; /* Where in that frag? */
289 int size; /* 1, 2, or 4 usually. */
290 symbolS *add_symbol; /* X_add_symbol. */
291 offsetT offset; /* X_add_number. */
292 int pcrel; /* TRUE if PC-relative relocation. */
293 RELOC_ENUM r_type; /* Relocation type. */
295 return fix_new_internal (frag, where, size, add_symbol,
296 (symbolS *) NULL, offset, pcrel, r_type);
299 /* Create a fixup for an expression. Currently we only support fixups
300 for difference expressions. That is itself more than most object
301 file formats support anyhow. */
303 fixS *
304 fix_new_exp (frag, where, size, exp, pcrel, r_type)
305 fragS *frag; /* Which frag? */
306 int where; /* Where in that frag? */
307 int size; /* 1, 2, or 4 usually. */
308 expressionS *exp; /* Expression. */
309 int pcrel; /* TRUE if PC-relative relocation. */
310 RELOC_ENUM r_type; /* Relocation type. */
312 symbolS *add = NULL;
313 symbolS *sub = NULL;
314 offsetT off = 0;
316 switch (exp->X_op)
318 case O_absent:
319 break;
321 case O_register:
322 as_bad (_("register value used as expression"));
323 break;
325 case O_add:
326 /* This comes up when _GLOBAL_OFFSET_TABLE_+(.-L0) is read, if
327 the difference expression cannot immediately be reduced. */
329 symbolS *stmp = make_expr_symbol (exp);
331 exp->X_op = O_symbol;
332 exp->X_op_symbol = 0;
333 exp->X_add_symbol = stmp;
334 exp->X_add_number = 0;
336 return fix_new_exp (frag, where, size, exp, pcrel, r_type);
339 case O_symbol_rva:
340 add = exp->X_add_symbol;
341 off = exp->X_add_number;
343 #if defined(BFD_ASSEMBLER)
344 r_type = BFD_RELOC_RVA;
345 #else
346 #if defined(TC_RVA_RELOC)
347 r_type = TC_RVA_RELOC;
348 #else
349 as_fatal (_("rva not supported"));
350 #endif
351 #endif
352 break;
354 case O_uminus:
355 sub = exp->X_add_symbol;
356 off = exp->X_add_number;
357 break;
359 case O_subtract:
360 sub = exp->X_op_symbol;
361 /* Fall through. */
362 case O_symbol:
363 add = exp->X_add_symbol;
364 /* Fall through. */
365 case O_constant:
366 off = exp->X_add_number;
367 break;
369 default:
370 add = make_expr_symbol (exp);
371 break;
374 return fix_new_internal (frag, where, size, add, sub, off, pcrel, r_type);
377 /* Generic function to determine whether a fixup requires a relocation. */
379 generic_force_reloc (fix)
380 fixS *fix;
382 #ifdef BFD_ASSEMBLER
383 if (fix->fx_r_type == BFD_RELOC_VTABLE_INHERIT
384 || fix->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
385 return 1;
386 #endif
387 return S_FORCE_RELOC (fix->fx_addsy, fix->fx_subsy == NULL);
390 /* Append a string onto another string, bumping the pointer along. */
391 void
392 append (charPP, fromP, length)
393 char **charPP;
394 char *fromP;
395 unsigned long length;
397 /* Don't trust memcpy() of 0 chars. */
398 if (length == 0)
399 return;
401 memcpy (*charPP, fromP, length);
402 *charPP += length;
405 #ifndef BFD_ASSEMBLER
406 int section_alignment[SEG_MAXIMUM_ORDINAL];
407 #endif
409 /* This routine records the largest alignment seen for each segment.
410 If the beginning of the segment is aligned on the worst-case
411 boundary, all of the other alignments within it will work. At
412 least one object format really uses this info. */
414 void
415 record_alignment (seg, align)
416 /* Segment to which alignment pertains. */
417 segT seg;
418 /* Alignment, as a power of 2 (e.g., 1 => 2-byte boundary, 2 => 4-byte
419 boundary, etc.) */
420 int align;
422 if (seg == absolute_section)
423 return;
424 #ifdef BFD_ASSEMBLER
425 if ((unsigned int) align > bfd_get_section_alignment (stdoutput, seg))
426 bfd_set_section_alignment (stdoutput, seg, align);
427 #else
428 if (align > section_alignment[(int) seg])
429 section_alignment[(int) seg] = align;
430 #endif
434 get_recorded_alignment (seg)
435 segT seg;
437 if (seg == absolute_section)
438 return 0;
439 #ifdef BFD_ASSEMBLER
440 return bfd_get_section_alignment (stdoutput, seg);
441 #else
442 return section_alignment[(int) seg];
443 #endif
446 #ifdef BFD_ASSEMBLER
448 /* Reset the section indices after removing the gas created sections. */
450 static void
451 renumber_sections (abfd, sec, countparg)
452 bfd *abfd ATTRIBUTE_UNUSED;
453 asection *sec;
454 PTR countparg;
456 int *countp = (int *) countparg;
458 sec->index = *countp;
459 ++*countp;
462 #endif /* defined (BFD_ASSEMBLER) */
464 #if defined (BFD_ASSEMBLER) || ! defined (BFD)
466 static fragS *
467 chain_frchains_together_1 (section, frchp)
468 segT section;
469 struct frchain *frchp;
471 fragS dummy, *prev_frag = &dummy;
472 #ifdef BFD_ASSEMBLER
473 fixS fix_dummy, *prev_fix = &fix_dummy;
474 #endif
476 for (; frchp && frchp->frch_seg == section; frchp = frchp->frch_next)
478 prev_frag->fr_next = frchp->frch_root;
479 prev_frag = frchp->frch_last;
480 assert (prev_frag->fr_type != 0);
481 #ifdef BFD_ASSEMBLER
482 if (frchp->fix_root != (fixS *) NULL)
484 if (seg_info (section)->fix_root == (fixS *) NULL)
485 seg_info (section)->fix_root = frchp->fix_root;
486 prev_fix->fx_next = frchp->fix_root;
487 seg_info (section)->fix_tail = frchp->fix_tail;
488 prev_fix = frchp->fix_tail;
490 #endif
492 assert (prev_frag->fr_type != 0);
493 prev_frag->fr_next = 0;
494 return prev_frag;
497 #endif
499 #ifdef BFD_ASSEMBLER
501 static void
502 chain_frchains_together (abfd, section, xxx)
503 bfd *abfd ATTRIBUTE_UNUSED;
504 segT section;
505 PTR xxx ATTRIBUTE_UNUSED;
507 segment_info_type *info;
509 /* BFD may have introduced its own sections without using
510 subseg_new, so it is possible that seg_info is NULL. */
511 info = seg_info (section);
512 if (info != (segment_info_type *) NULL)
513 info->frchainP->frch_last
514 = chain_frchains_together_1 (section, info->frchainP);
516 /* Now that we've chained the frags together, we must add new fixups
517 to the segment, not to the frag chain. */
518 frags_chained = 1;
521 #endif
523 #if !defined (BFD) && !defined (BFD_ASSEMBLER)
525 static void
526 remove_subsegs (head, seg, root, last)
527 frchainS *head;
528 int seg;
529 fragS **root;
530 fragS **last;
532 *root = head->frch_root;
533 *last = chain_frchains_together_1 (seg, head);
536 #endif /* BFD */
538 #if defined (BFD_ASSEMBLER) || !defined (BFD)
540 #ifdef BFD_ASSEMBLER
541 static void
542 cvt_frag_to_fill (sec, fragP)
543 segT sec ATTRIBUTE_UNUSED;
544 fragS *fragP;
545 #else
546 static void
547 cvt_frag_to_fill (headersP, sec, fragP)
548 object_headers *headersP;
549 segT sec;
550 fragS *fragP;
551 #endif
553 switch (fragP->fr_type)
555 case rs_align:
556 case rs_align_code:
557 case rs_align_test:
558 case rs_org:
559 case rs_space:
560 #ifdef HANDLE_ALIGN
561 HANDLE_ALIGN (fragP);
562 #endif
563 know (fragP->fr_next != NULL);
564 fragP->fr_offset = (fragP->fr_next->fr_address
565 - fragP->fr_address
566 - fragP->fr_fix) / fragP->fr_var;
567 if (fragP->fr_offset < 0)
569 as_bad_where (fragP->fr_file, fragP->fr_line,
570 _("attempt to .org/.space backwards? (%ld)"),
571 (long) fragP->fr_offset);
572 fragP->fr_offset = 0;
574 fragP->fr_type = rs_fill;
575 break;
577 case rs_fill:
578 break;
580 case rs_leb128:
582 valueT value = S_GET_VALUE (fragP->fr_symbol);
583 int size;
585 size = output_leb128 (fragP->fr_literal + fragP->fr_fix, value,
586 fragP->fr_subtype);
588 fragP->fr_fix += size;
589 fragP->fr_type = rs_fill;
590 fragP->fr_var = 0;
591 fragP->fr_offset = 0;
592 fragP->fr_symbol = NULL;
594 break;
596 case rs_cfa:
597 eh_frame_convert_frag (fragP);
598 break;
600 case rs_dwarf2dbg:
601 dwarf2dbg_convert_frag (fragP);
602 break;
604 case rs_machine_dependent:
605 #ifdef BFD_ASSEMBLER
606 md_convert_frag (stdoutput, sec, fragP);
607 #else
608 md_convert_frag (headersP, sec, fragP);
609 #endif
611 assert (fragP->fr_next == NULL
612 || ((offsetT) (fragP->fr_next->fr_address - fragP->fr_address)
613 == fragP->fr_fix));
615 /* After md_convert_frag, we make the frag into a ".space 0".
616 md_convert_frag() should set up any fixSs and constants
617 required. */
618 frag_wane (fragP);
619 break;
621 #ifndef WORKING_DOT_WORD
622 case rs_broken_word:
624 struct broken_word *lie;
626 if (fragP->fr_subtype)
628 fragP->fr_fix += md_short_jump_size;
629 for (lie = (struct broken_word *) (fragP->fr_symbol);
630 lie && lie->dispfrag == fragP;
631 lie = lie->next_broken_word)
632 if (lie->added == 1)
633 fragP->fr_fix += md_long_jump_size;
635 frag_wane (fragP);
637 break;
638 #endif
640 default:
641 BAD_CASE (fragP->fr_type);
642 break;
646 #endif /* defined (BFD_ASSEMBLER) || !defined (BFD) */
648 #ifdef BFD_ASSEMBLER
649 static void relax_seg PARAMS ((bfd *, asection *, PTR));
650 static void
651 relax_seg (abfd, sec, xxx)
652 bfd *abfd ATTRIBUTE_UNUSED;
653 asection *sec;
654 PTR xxx;
656 segment_info_type *seginfo = seg_info (sec);
658 if (seginfo && seginfo->frchainP
659 && relax_segment (seginfo->frchainP->frch_root, sec))
661 int *result = (int *) xxx;
662 *result = 1;
666 static void size_seg PARAMS ((bfd *, asection *, PTR));
667 static void
668 size_seg (abfd, sec, xxx)
669 bfd *abfd;
670 asection *sec;
671 PTR xxx ATTRIBUTE_UNUSED;
673 flagword flags;
674 fragS *fragp;
675 segment_info_type *seginfo;
676 int x;
677 valueT size, newsize;
679 subseg_change (sec, 0);
681 seginfo = seg_info (sec);
682 if (seginfo && seginfo->frchainP)
684 for (fragp = seginfo->frchainP->frch_root; fragp; fragp = fragp->fr_next)
685 cvt_frag_to_fill (sec, fragp);
686 for (fragp = seginfo->frchainP->frch_root;
687 fragp->fr_next;
688 fragp = fragp->fr_next)
689 /* Walk to last elt. */
691 size = fragp->fr_address + fragp->fr_fix;
693 else
694 size = 0;
696 flags = bfd_get_section_flags (abfd, sec);
698 if (size > 0 && ! seginfo->bss)
699 flags |= SEC_HAS_CONTENTS;
701 /* @@ This is just an approximation. */
702 if (seginfo && seginfo->fix_root)
703 flags |= SEC_RELOC;
704 else
705 flags &= ~SEC_RELOC;
706 x = bfd_set_section_flags (abfd, sec, flags);
707 assert (x);
709 newsize = md_section_align (sec, size);
710 x = bfd_set_section_size (abfd, sec, newsize);
711 assert (x);
713 /* If the size had to be rounded up, add some padding in the last
714 non-empty frag. */
715 assert (newsize >= size);
716 if (size != newsize)
718 fragS *last = seginfo->frchainP->frch_last;
719 fragp = seginfo->frchainP->frch_root;
720 while (fragp->fr_next != last)
721 fragp = fragp->fr_next;
722 last->fr_address = size;
723 if ((newsize - size) % fragp->fr_var == 0)
724 fragp->fr_offset += (newsize - size) / fragp->fr_var;
725 else
726 /* If we hit this abort, it's likely due to subsegs_finish not
727 providing sufficient alignment on the last frag, and the
728 machine dependent code using alignment frags with fr_var
729 greater than 1. */
730 abort ();
733 #ifdef tc_frob_section
734 tc_frob_section (sec);
735 #endif
736 #ifdef obj_frob_section
737 obj_frob_section (sec);
738 #endif
741 #ifdef DEBUG2
742 static void
743 dump_section_relocs (abfd, sec, stream_)
744 bfd *abfd ATTRIBUTE_UNUSED;
745 asection *sec;
746 char *stream_;
748 FILE *stream = (FILE *) stream_;
749 segment_info_type *seginfo = seg_info (sec);
750 fixS *fixp = seginfo->fix_root;
752 if (!fixp)
753 return;
755 fprintf (stream, "sec %s relocs:\n", sec->name);
756 while (fixp)
758 symbolS *s = fixp->fx_addsy;
760 fprintf (stream, " %08lx: type %d ", (unsigned long) fixp,
761 (int) fixp->fx_r_type);
762 if (s == NULL)
763 fprintf (stream, "no sym\n");
764 else
766 print_symbol_value_1 (stream, s);
767 fprintf (stream, "\n");
769 fixp = fixp->fx_next;
772 #else
773 #define dump_section_relocs(ABFD,SEC,STREAM) ((void) 0)
774 #endif
776 #ifndef EMIT_SECTION_SYMBOLS
777 #define EMIT_SECTION_SYMBOLS 1
778 #endif
780 /* This pass over fixups decides whether symbols can be replaced with
781 section symbols. */
783 static void
784 adjust_reloc_syms (abfd, sec, xxx)
785 bfd *abfd ATTRIBUTE_UNUSED;
786 asection *sec;
787 PTR xxx ATTRIBUTE_UNUSED;
789 segment_info_type *seginfo = seg_info (sec);
790 fixS *fixp;
792 if (seginfo == NULL)
793 return;
795 dump_section_relocs (abfd, sec, stderr);
797 for (fixp = seginfo->fix_root; fixp; fixp = fixp->fx_next)
798 if (fixp->fx_done)
799 /* Ignore it. */
801 else if (fixp->fx_addsy)
803 symbolS *sym;
804 asection *symsec;
806 #ifdef DEBUG5
807 fprintf (stderr, "\n\nadjusting fixup:\n");
808 print_fixup (fixp);
809 #endif
811 sym = fixp->fx_addsy;
813 /* All symbols should have already been resolved at this
814 point. It is possible to see unresolved expression
815 symbols, though, since they are not in the regular symbol
816 table. */
817 resolve_symbol_value (sym);
819 if (fixp->fx_subsy != NULL)
820 resolve_symbol_value (fixp->fx_subsy);
822 /* If this symbol is equated to an undefined symbol, convert
823 the fixup to being against that symbol. */
824 if (symbol_equated_reloc_p (sym))
826 fixp->fx_offset += symbol_get_value_expression (sym)->X_add_number;
827 sym = symbol_get_value_expression (sym)->X_add_symbol;
828 fixp->fx_addsy = sym;
831 if (symbol_mri_common_p (sym))
833 /* These symbols are handled specially in fixup_segment. */
834 continue;
837 /* If the symbol is undefined, common, weak, or global (ELF
838 shared libs), we can't replace it with the section symbol. */
839 if (S_FORCE_RELOC (fixp->fx_addsy, 1))
840 continue;
842 /* Is there some other (target cpu dependent) reason we can't adjust
843 this one? (E.g. relocations involving function addresses on
844 the PA. */
845 #ifdef tc_fix_adjustable
846 if (! tc_fix_adjustable (fixp))
847 continue;
848 #endif
850 /* Since we're reducing to section symbols, don't attempt to reduce
851 anything that's already using one. */
852 if (symbol_section_p (sym))
853 continue;
855 symsec = S_GET_SEGMENT (sym);
856 if (symsec == NULL)
857 abort ();
859 if (bfd_is_abs_section (symsec))
861 /* The fixup_segment routine normally will not use this
862 symbol in a relocation. */
863 continue;
866 /* Don't try to reduce relocs which refer to non-local symbols
867 in .linkonce sections. It can lead to confusion when a
868 debugging section refers to a .linkonce section. I hope
869 this will always be correct. */
870 if (symsec != sec && ! S_IS_LOCAL (sym))
872 if ((symsec->flags & SEC_LINK_ONCE) != 0
873 || (IS_ELF
874 /* The GNU toolchain uses an extension for ELF: a
875 section beginning with the magic string
876 .gnu.linkonce is a linkonce section. */
877 && strncmp (segment_name (symsec), ".gnu.linkonce",
878 sizeof ".gnu.linkonce" - 1) == 0))
879 continue;
882 /* Never adjust a reloc against local symbol in a merge section
883 with non-zero addend. */
884 if ((symsec->flags & SEC_MERGE) != 0
885 && (fixp->fx_offset != 0 || fixp->fx_subsy != NULL))
886 continue;
888 /* Never adjust a reloc against TLS local symbol. */
889 if ((symsec->flags & SEC_THREAD_LOCAL) != 0)
890 continue;
892 /* We refetch the segment when calling section_symbol, rather
893 than using symsec, because S_GET_VALUE may wind up changing
894 the section when it calls resolve_symbol_value. */
895 fixp->fx_offset += S_GET_VALUE (sym);
896 fixp->fx_addsy = section_symbol (S_GET_SEGMENT (sym));
897 #ifdef DEBUG5
898 fprintf (stderr, "\nadjusted fixup:\n");
899 print_fixup (fixp);
900 #endif
903 dump_section_relocs (abfd, sec, stderr);
906 static void
907 fix_segment (abfd, sec, xxx)
908 bfd *abfd ATTRIBUTE_UNUSED;
909 asection *sec;
910 PTR xxx ATTRIBUTE_UNUSED;
912 segment_info_type *seginfo = seg_info (sec);
914 fixup_segment (seginfo->fix_root, sec);
917 static void
918 write_relocs (abfd, sec, xxx)
919 bfd *abfd;
920 asection *sec;
921 PTR xxx ATTRIBUTE_UNUSED;
923 segment_info_type *seginfo = seg_info (sec);
924 unsigned int i;
925 unsigned int n;
926 arelent **relocs;
927 fixS *fixp;
928 char *err;
930 /* If seginfo is NULL, we did not create this section; don't do
931 anything with it. */
932 if (seginfo == NULL)
933 return;
935 n = 0;
936 for (fixp = seginfo->fix_root; fixp; fixp = fixp->fx_next)
937 n++;
939 #ifndef RELOC_EXPANSION_POSSIBLE
940 /* Set up reloc information as well. */
941 relocs = (arelent **) xcalloc (n, sizeof (arelent *));
943 i = 0;
944 for (fixp = seginfo->fix_root; fixp != (fixS *) NULL; fixp = fixp->fx_next)
946 arelent *reloc;
947 bfd_reloc_status_type s;
948 symbolS *sym;
950 if (fixp->fx_done)
952 n--;
953 continue;
956 /* If this is an undefined symbol which was equated to another
957 symbol, then generate the reloc against the latter symbol
958 rather than the former. */
959 sym = fixp->fx_addsy;
960 while (symbol_equated_reloc_p (sym))
962 symbolS *n;
964 /* We must avoid looping, as that can occur with a badly
965 written program. */
966 n = symbol_get_value_expression (sym)->X_add_symbol;
967 if (n == sym)
968 break;
969 fixp->fx_offset += symbol_get_value_expression (sym)->X_add_number;
970 sym = n;
972 fixp->fx_addsy = sym;
974 reloc = tc_gen_reloc (sec, fixp);
975 if (!reloc)
977 n--;
978 continue;
981 #if 0
982 /* This test is triggered inappropriately for the SH. */
983 if (fixp->fx_where + fixp->fx_size
984 > fixp->fx_frag->fr_fix + fixp->fx_frag->fr_offset)
985 abort ();
986 #endif
988 s = bfd_install_relocation (stdoutput, reloc,
989 fixp->fx_frag->fr_literal,
990 fixp->fx_frag->fr_address,
991 sec, &err);
992 switch (s)
994 case bfd_reloc_ok:
995 break;
996 case bfd_reloc_overflow:
997 as_bad_where (fixp->fx_file, fixp->fx_line,
998 _("relocation overflow"));
999 break;
1000 case bfd_reloc_outofrange:
1001 as_bad_where (fixp->fx_file, fixp->fx_line,
1002 _("relocation out of range"));
1003 break;
1004 default:
1005 as_fatal (_("%s:%u: bad return from bfd_install_relocation: %x"),
1006 fixp->fx_file, fixp->fx_line, s);
1008 relocs[i++] = reloc;
1010 #else
1011 n = n * MAX_RELOC_EXPANSION;
1012 /* Set up reloc information as well. */
1013 relocs = (arelent **) xcalloc (n, sizeof (arelent *));
1015 i = 0;
1016 for (fixp = seginfo->fix_root; fixp != (fixS *) NULL; fixp = fixp->fx_next)
1018 arelent **reloc;
1019 bfd_reloc_status_type s;
1020 symbolS *sym;
1021 int j;
1023 if (fixp->fx_done)
1025 n--;
1026 continue;
1029 /* If this is an undefined symbol which was equated to another
1030 symbol, then generate the reloc against the latter symbol
1031 rather than the former. */
1032 sym = fixp->fx_addsy;
1033 while (symbol_equated_reloc_p (sym))
1035 symbolS *n;
1037 /* We must avoid looping, as that can occur with a badly
1038 written program. */
1039 n = symbol_get_value_expression (sym)->X_add_symbol;
1040 if (n == sym)
1041 break;
1042 fixp->fx_offset += symbol_get_value_expression (sym)->X_add_number;
1043 sym = n;
1045 fixp->fx_addsy = sym;
1047 reloc = tc_gen_reloc (sec, fixp);
1049 for (j = 0; reloc[j]; j++)
1051 relocs[i++] = reloc[j];
1052 assert (i <= n);
1054 if (fixp->fx_where + fixp->fx_size
1055 > fixp->fx_frag->fr_fix + fixp->fx_frag->fr_offset)
1056 as_bad_where (fixp->fx_file, fixp->fx_line,
1057 _("internal error: fixup not contained within frag"));
1058 for (j = 0; reloc[j]; j++)
1060 s = bfd_install_relocation (stdoutput, reloc[j],
1061 fixp->fx_frag->fr_literal,
1062 fixp->fx_frag->fr_address,
1063 sec, &err);
1064 switch (s)
1066 case bfd_reloc_ok:
1067 break;
1068 case bfd_reloc_overflow:
1069 as_bad_where (fixp->fx_file, fixp->fx_line,
1070 _("relocation overflow"));
1071 break;
1072 case bfd_reloc_outofrange:
1073 as_bad_where (fixp->fx_file, fixp->fx_line,
1074 _("relocation out of range"));
1075 break;
1076 default:
1077 as_fatal (_("%s:%u: bad return from bfd_install_relocation: %x"),
1078 fixp->fx_file, fixp->fx_line, s);
1082 n = i;
1083 #endif
1085 #ifdef DEBUG4
1087 int i, j, nsyms;
1088 asymbol **sympp;
1089 sympp = bfd_get_outsymbols (stdoutput);
1090 nsyms = bfd_get_symcount (stdoutput);
1091 for (i = 0; i < n; i++)
1092 if (((*relocs[i]->sym_ptr_ptr)->flags & BSF_SECTION_SYM) == 0)
1094 for (j = 0; j < nsyms; j++)
1095 if (sympp[j] == *relocs[i]->sym_ptr_ptr)
1096 break;
1097 if (j == nsyms)
1098 abort ();
1101 #endif
1103 if (n)
1104 bfd_set_reloc (stdoutput, sec, relocs, n);
1105 else
1106 bfd_set_section_flags (abfd, sec,
1107 (bfd_get_section_flags (abfd, sec)
1108 & (flagword) ~SEC_RELOC));
1110 #ifdef SET_SECTION_RELOCS
1111 SET_SECTION_RELOCS (sec, relocs, n);
1112 #endif
1114 #ifdef DEBUG3
1116 int i;
1117 arelent *r;
1118 asymbol *s;
1119 fprintf (stderr, "relocs for sec %s\n", sec->name);
1120 for (i = 0; i < n; i++)
1122 r = relocs[i];
1123 s = *r->sym_ptr_ptr;
1124 fprintf (stderr, " reloc %2d @%08x off %4x : sym %-10s addend %x\n",
1125 i, r, r->address, s->name, r->addend);
1128 #endif
1131 static void
1132 write_contents (abfd, sec, xxx)
1133 bfd *abfd ATTRIBUTE_UNUSED;
1134 asection *sec;
1135 PTR xxx ATTRIBUTE_UNUSED;
1137 segment_info_type *seginfo = seg_info (sec);
1138 addressT offset = 0;
1139 fragS *f;
1141 /* Write out the frags. */
1142 if (seginfo == NULL
1143 || !(bfd_get_section_flags (abfd, sec) & SEC_HAS_CONTENTS))
1144 return;
1146 for (f = seginfo->frchainP->frch_root;
1148 f = f->fr_next)
1150 int x;
1151 addressT fill_size;
1152 char *fill_literal;
1153 offsetT count;
1155 assert (f->fr_type == rs_fill);
1156 if (f->fr_fix)
1158 x = bfd_set_section_contents (stdoutput, sec,
1159 f->fr_literal, (file_ptr) offset,
1160 (bfd_size_type) f->fr_fix);
1161 if (!x)
1163 bfd_perror (stdoutput->filename);
1164 as_perror (_("FATAL: Can't write %s"), stdoutput->filename);
1165 exit (EXIT_FAILURE);
1167 offset += f->fr_fix;
1169 fill_literal = f->fr_literal + f->fr_fix;
1170 fill_size = f->fr_var;
1171 count = f->fr_offset;
1172 assert (count >= 0);
1173 if (fill_size && count)
1175 char buf[256];
1176 if (fill_size > sizeof (buf))
1178 /* Do it the old way. Can this ever happen? */
1179 while (count--)
1181 x = bfd_set_section_contents (stdoutput, sec,
1182 fill_literal,
1183 (file_ptr) offset,
1184 (bfd_size_type) fill_size);
1185 if (!x)
1187 bfd_perror (stdoutput->filename);
1188 as_perror (_("FATAL: Can't write %s"),
1189 stdoutput->filename);
1190 exit (EXIT_FAILURE);
1192 offset += fill_size;
1195 else
1197 /* Build a buffer full of fill objects and output it as
1198 often as necessary. This saves on the overhead of
1199 potentially lots of bfd_set_section_contents calls. */
1200 int n_per_buf, i;
1201 if (fill_size == 1)
1203 n_per_buf = sizeof (buf);
1204 memset (buf, *fill_literal, n_per_buf);
1206 else
1208 char *bufp;
1209 n_per_buf = sizeof (buf) / fill_size;
1210 for (i = n_per_buf, bufp = buf; i; i--, bufp += fill_size)
1211 memcpy (bufp, fill_literal, fill_size);
1213 for (; count > 0; count -= n_per_buf)
1215 n_per_buf = n_per_buf > count ? count : n_per_buf;
1216 x = bfd_set_section_contents
1217 (stdoutput, sec, buf, (file_ptr) offset,
1218 (bfd_size_type) n_per_buf * fill_size);
1219 if (!x)
1220 as_fatal (_("cannot write to output file"));
1221 offset += n_per_buf * fill_size;
1227 #endif
1229 #if defined(BFD_ASSEMBLER) || (!defined (BFD) && !defined(OBJ_AOUT))
1230 static void
1231 merge_data_into_text ()
1233 #if defined(BFD_ASSEMBLER) || defined(MANY_SEGMENTS)
1234 seg_info (text_section)->frchainP->frch_last->fr_next =
1235 seg_info (data_section)->frchainP->frch_root;
1236 seg_info (text_section)->frchainP->frch_last =
1237 seg_info (data_section)->frchainP->frch_last;
1238 seg_info (data_section)->frchainP = 0;
1239 #else
1240 fixS *tmp;
1242 text_last_frag->fr_next = data_frag_root;
1243 text_last_frag = data_last_frag;
1244 data_last_frag = NULL;
1245 data_frag_root = NULL;
1246 if (text_fix_root)
1248 for (tmp = text_fix_root; tmp->fx_next; tmp = tmp->fx_next);;
1249 tmp->fx_next = data_fix_root;
1250 text_fix_tail = data_fix_tail;
1252 else
1253 text_fix_root = data_fix_root;
1254 data_fix_root = NULL;
1255 #endif
1257 #endif /* BFD_ASSEMBLER || (! BFD && ! OBJ_AOUT) */
1259 #if !defined (BFD_ASSEMBLER) && !defined (BFD)
1260 static void
1261 relax_and_size_all_segments ()
1263 fragS *fragP;
1265 relax_segment (text_frag_root, SEG_TEXT);
1266 relax_segment (data_frag_root, SEG_DATA);
1267 relax_segment (bss_frag_root, SEG_BSS);
1269 /* Now the addresses of frags are correct within the segment. */
1270 know (text_last_frag->fr_type == rs_fill && text_last_frag->fr_offset == 0);
1271 H_SET_TEXT_SIZE (&headers, text_last_frag->fr_address);
1272 text_last_frag->fr_address = H_GET_TEXT_SIZE (&headers);
1274 /* Join the 2 segments into 1 huge segment.
1275 To do this, re-compute every rn_address in the SEG_DATA frags.
1276 Then join the data frags after the text frags.
1278 Determine a_data [length of data segment]. */
1279 if (data_frag_root)
1281 register relax_addressT slide;
1283 know ((text_last_frag->fr_type == rs_fill)
1284 && (text_last_frag->fr_offset == 0));
1286 H_SET_DATA_SIZE (&headers, data_last_frag->fr_address);
1287 data_last_frag->fr_address = H_GET_DATA_SIZE (&headers);
1288 slide = H_GET_TEXT_SIZE (&headers); /* & in file of the data segment. */
1289 #ifdef OBJ_BOUT
1290 #define RoundUp(N,S) (((N)+(S)-1)&-(S))
1291 /* For b.out: If the data section has a strict alignment
1292 requirement, its load address in the .o file will be
1293 rounded up from the size of the text section. These
1294 two values are *not* the same! Similarly for the bss
1295 section.... */
1296 slide = RoundUp (slide, 1 << section_alignment[SEG_DATA]);
1297 #endif
1299 for (fragP = data_frag_root; fragP; fragP = fragP->fr_next)
1300 fragP->fr_address += slide;
1302 know (text_last_frag != 0);
1303 text_last_frag->fr_next = data_frag_root;
1305 else
1307 H_SET_DATA_SIZE (&headers, 0);
1310 #ifdef OBJ_BOUT
1311 /* See above comments on b.out data section address. */
1313 addressT bss_vma;
1314 if (data_last_frag == 0)
1315 bss_vma = H_GET_TEXT_SIZE (&headers);
1316 else
1317 bss_vma = data_last_frag->fr_address;
1318 bss_vma = RoundUp (bss_vma, 1 << section_alignment[SEG_BSS]);
1319 bss_address_frag.fr_address = bss_vma;
1321 #else /* ! OBJ_BOUT */
1322 bss_address_frag.fr_address = (H_GET_TEXT_SIZE (&headers) +
1323 H_GET_DATA_SIZE (&headers));
1325 #endif /* ! OBJ_BOUT */
1327 /* Slide all the frags. */
1328 if (bss_frag_root)
1330 relax_addressT slide = bss_address_frag.fr_address;
1332 for (fragP = bss_frag_root; fragP; fragP = fragP->fr_next)
1333 fragP->fr_address += slide;
1336 if (bss_last_frag)
1337 H_SET_BSS_SIZE (&headers,
1338 bss_last_frag->fr_address - bss_frag_root->fr_address);
1339 else
1340 H_SET_BSS_SIZE (&headers, 0);
1342 #endif /* ! BFD_ASSEMBLER && ! BFD */
1344 #if defined (BFD_ASSEMBLER) || !defined (BFD)
1346 #ifdef BFD_ASSEMBLER
1347 static void
1348 set_symtab ()
1350 int nsyms;
1351 asymbol **asympp;
1352 symbolS *symp;
1353 bfd_boolean result;
1354 extern PTR bfd_alloc PARAMS ((bfd *, bfd_size_type));
1356 /* Count symbols. We can't rely on a count made by the loop in
1357 write_object_file, because *_frob_file may add a new symbol or
1358 two. */
1359 nsyms = 0;
1360 for (symp = symbol_rootP; symp; symp = symbol_next (symp))
1361 nsyms++;
1363 if (nsyms)
1365 int i;
1366 bfd_size_type amt = (bfd_size_type) nsyms * sizeof (asymbol *);
1368 asympp = (asymbol **) bfd_alloc (stdoutput, amt);
1369 symp = symbol_rootP;
1370 for (i = 0; i < nsyms; i++, symp = symbol_next (symp))
1372 asympp[i] = symbol_get_bfdsym (symp);
1373 symbol_mark_written (symp);
1376 else
1377 asympp = 0;
1378 result = bfd_set_symtab (stdoutput, asympp, nsyms);
1379 assert (result);
1380 symbol_table_frozen = 1;
1382 #endif
1384 /* Finish the subsegments. After every sub-segment, we fake an
1385 ".align ...". This conforms to BSD4.2 brane-damage. We then fake
1386 ".fill 0" because that is the kind of frag that requires least
1387 thought. ".align" frags like to have a following frag since that
1388 makes calculating their intended length trivial. */
1390 #ifndef SUB_SEGMENT_ALIGN
1391 #ifdef HANDLE_ALIGN
1392 /* The last subsegment gets an aligment corresponding to the alignment
1393 of the section. This allows proper nop-filling at the end of
1394 code-bearing sections. */
1395 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \
1396 (!(FRCHAIN)->frch_next || (FRCHAIN)->frch_next->frch_seg != (SEG) \
1397 ? get_recorded_alignment (SEG) : 0)
1398 #else
1399 #ifdef BFD_ASSEMBLER
1400 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
1401 #else
1402 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 2
1403 #endif
1404 #endif
1405 #endif
1407 void
1408 subsegs_finish ()
1410 struct frchain *frchainP;
1412 for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next)
1414 int alignment = 0;
1416 subseg_set (frchainP->frch_seg, frchainP->frch_subseg);
1418 /* This now gets called even if we had errors. In that case,
1419 any alignment is meaningless, and, moreover, will look weird
1420 if we are generating a listing. */
1421 if (!had_errors ())
1423 alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
1424 #ifdef BFD_ASSEMBLER
1425 if ((bfd_get_section_flags (now_seg->owner, now_seg) & SEC_MERGE)
1426 && now_seg->entsize)
1428 unsigned int entsize = now_seg->entsize;
1429 int entalign = 0;
1431 while ((entsize & 1) == 0)
1433 ++entalign;
1434 entsize >>= 1;
1436 if (entalign > alignment)
1437 alignment = entalign;
1439 #endif
1442 if (subseg_text_p (now_seg))
1443 frag_align_code (alignment, 0);
1444 else
1445 frag_align (alignment, 0, 0);
1447 /* frag_align will have left a new frag.
1448 Use this last frag for an empty ".fill".
1450 For this segment ...
1451 Create a last frag. Do not leave a "being filled in frag". */
1452 frag_wane (frag_now);
1453 frag_now->fr_fix = 0;
1454 know (frag_now->fr_next == NULL);
1458 /* Write the object file. */
1460 void
1461 write_object_file ()
1463 #if ! defined (BFD_ASSEMBLER) || ! defined (WORKING_DOT_WORD)
1464 fragS *fragP; /* Track along all frags. */
1465 #endif
1467 /* Do we really want to write it? */
1469 int n_warns, n_errs;
1470 n_warns = had_warnings ();
1471 n_errs = had_errors ();
1472 /* The -Z flag indicates that an object file should be generated,
1473 regardless of warnings and errors. */
1474 if (flag_always_generate_output)
1476 if (n_warns || n_errs)
1477 as_warn (_("%d error%s, %d warning%s, generating bad object file"),
1478 n_errs, n_errs == 1 ? "" : "s",
1479 n_warns, n_warns == 1 ? "" : "s");
1481 else
1483 if (n_errs)
1484 as_fatal (_("%d error%s, %d warning%s, no object file generated"),
1485 n_errs, n_errs == 1 ? "" : "s",
1486 n_warns, n_warns == 1 ? "" : "s");
1490 #ifdef OBJ_VMS
1491 /* Under VMS we try to be compatible with VAX-11 "C". Thus, we call
1492 a routine to check for the definition of the procedure "_main",
1493 and if so -- fix it up so that it can be program entry point. */
1494 vms_check_for_main ();
1495 #endif /* OBJ_VMS */
1497 /* From now on, we don't care about sub-segments. Build one frag chain
1498 for each segment. Linked thru fr_next. */
1500 #ifdef BFD_ASSEMBLER
1501 /* Remove the sections created by gas for its own purposes. */
1503 asection **seclist;
1504 int i;
1506 seclist = &stdoutput->sections;
1507 while (*seclist)
1509 if (*seclist == reg_section || *seclist == expr_section)
1511 bfd_section_list_remove (stdoutput, seclist);
1512 stdoutput->section_count--;
1514 else
1515 seclist = &(*seclist)->next;
1517 i = 0;
1518 bfd_map_over_sections (stdoutput, renumber_sections, &i);
1521 bfd_map_over_sections (stdoutput, chain_frchains_together, (char *) 0);
1522 #else
1523 remove_subsegs (frchain_root, SEG_TEXT, &text_frag_root, &text_last_frag);
1524 remove_subsegs (data0_frchainP, SEG_DATA, &data_frag_root, &data_last_frag);
1525 remove_subsegs (bss0_frchainP, SEG_BSS, &bss_frag_root, &bss_last_frag);
1526 #endif
1528 /* We have two segments. If user gave -R flag, then we must put the
1529 data frags into the text segment. Do this before relaxing so
1530 we know to take advantage of -R and make shorter addresses. */
1531 #if !defined (OBJ_AOUT) || defined (BFD_ASSEMBLER)
1532 if (flag_readonly_data_in_text)
1534 merge_data_into_text ();
1536 #endif
1538 #ifdef BFD_ASSEMBLER
1539 while (1)
1541 int changed;
1543 #ifndef WORKING_DOT_WORD
1544 /* We need to reset the markers in the broken word list and
1545 associated frags between calls to relax_segment (via
1546 relax_seg). Since the broken word list is global, we do it
1547 once per round, rather than locally in relax_segment for each
1548 segment. */
1549 struct broken_word *brokp;
1551 for (brokp = broken_words;
1552 brokp != (struct broken_word *) NULL;
1553 brokp = brokp->next_broken_word)
1555 brokp->added = 0;
1557 if (brokp->dispfrag != (fragS *) NULL
1558 && brokp->dispfrag->fr_type == rs_broken_word)
1559 brokp->dispfrag->fr_subtype = 0;
1561 #endif
1563 changed = 0;
1564 bfd_map_over_sections (stdoutput, relax_seg, &changed);
1565 if (!changed)
1566 break;
1569 /* Note - Most ports will use the default value of
1570 TC_FINALIZE_SYMS_BEFORE_SIZE_SEG, which 1. This will force
1571 local symbols to be resolved, removing their frag information.
1572 Some ports however, will not have finished relaxing all of
1573 their frags and will still need the local symbol frag
1574 information. These ports can set
1575 TC_FINALIZE_SYMS_BEFORE_SIZE_SEG to 0. */
1576 finalize_syms = TC_FINALIZE_SYMS_BEFORE_SIZE_SEG;
1578 bfd_map_over_sections (stdoutput, size_seg, (char *) 0);
1579 #else
1580 relax_and_size_all_segments ();
1581 #endif /* BFD_ASSEMBLER */
1583 /* Relaxation has completed. Freeze all syms. */
1584 finalize_syms = 1;
1586 #ifdef md_post_relax_hook
1587 md_post_relax_hook;
1588 #endif
1590 #ifndef BFD_ASSEMBLER
1591 /* Crawl the symbol chain.
1593 For each symbol whose value depends on a frag, take the address of
1594 that frag and subsume it into the value of the symbol.
1595 After this, there is just one way to lookup a symbol value.
1596 Values are left in their final state for object file emission.
1597 We adjust the values of 'L' local symbols, even if we do
1598 not intend to emit them to the object file, because their values
1599 are needed for fix-ups.
1601 Unless we saw a -L flag, remove all symbols that begin with 'L'
1602 from the symbol chain. (They are still pointed to by the fixes.)
1604 Count the remaining symbols.
1605 Assign a symbol number to each symbol.
1606 Count the number of string-table chars we will emit.
1607 Put this info into the headers as appropriate. */
1608 know (zero_address_frag.fr_address == 0);
1609 string_byte_count = sizeof (string_byte_count);
1611 obj_crawl_symbol_chain (&headers);
1613 if (string_byte_count == sizeof (string_byte_count))
1614 string_byte_count = 0;
1616 H_SET_STRING_SIZE (&headers, string_byte_count);
1618 /* Addresses of frags now reflect addresses we use in the object file.
1619 Symbol values are correct.
1620 Scan the frags, converting any ".org"s and ".align"s to ".fill"s.
1621 Also converting any machine-dependent frags using md_convert_frag(); */
1622 subseg_change (SEG_TEXT, 0);
1624 for (fragP = text_frag_root; fragP; fragP = fragP->fr_next)
1626 /* At this point we have linked all the frags into a single
1627 chain. However, cvt_frag_to_fill may call md_convert_frag
1628 which may call fix_new. We need to ensure that fix_new adds
1629 the fixup to the right section. */
1630 if (fragP == data_frag_root)
1631 subseg_change (SEG_DATA, 0);
1633 cvt_frag_to_fill (&headers, SEG_TEXT, fragP);
1635 /* Some assert macros don't work with # directives mixed in. */
1636 #ifndef NDEBUG
1637 if (!(fragP->fr_next == NULL
1638 #ifdef OBJ_BOUT
1639 || fragP->fr_next == data_frag_root
1640 #endif
1641 || ((offsetT) (fragP->fr_next->fr_address - fragP->fr_address)
1642 == (fragP->fr_fix + fragP->fr_offset * fragP->fr_var))))
1643 abort ();
1644 #endif
1646 #endif /* ! BFD_ASSEMBLER */
1648 #ifndef WORKING_DOT_WORD
1650 struct broken_word *lie;
1651 struct broken_word **prevP;
1653 prevP = &broken_words;
1654 for (lie = broken_words; lie; lie = lie->next_broken_word)
1655 if (!lie->added)
1657 expressionS exp;
1659 subseg_change (lie->seg, lie->subseg);
1660 exp.X_op = O_subtract;
1661 exp.X_add_symbol = lie->add;
1662 exp.X_op_symbol = lie->sub;
1663 exp.X_add_number = lie->addnum;
1664 #ifdef BFD_ASSEMBLER
1665 #ifdef TC_CONS_FIX_NEW
1666 TC_CONS_FIX_NEW (lie->frag,
1667 lie->word_goes_here - lie->frag->fr_literal,
1668 2, &exp);
1669 #else
1670 fix_new_exp (lie->frag,
1671 lie->word_goes_here - lie->frag->fr_literal,
1672 2, &exp, 0, BFD_RELOC_16);
1673 #endif
1674 #else
1675 #if defined(TC_SPARC) || defined(TC_A29K) || defined(NEED_FX_R_TYPE)
1676 fix_new_exp (lie->frag,
1677 lie->word_goes_here - lie->frag->fr_literal,
1678 2, &exp, 0, NO_RELOC);
1679 #else
1680 #ifdef TC_NS32K
1681 fix_new_ns32k_exp (lie->frag,
1682 lie->word_goes_here - lie->frag->fr_literal,
1683 2, &exp, 0, 0, 2, 0, 0);
1684 #else
1685 fix_new_exp (lie->frag,
1686 lie->word_goes_here - lie->frag->fr_literal,
1687 2, &exp, 0, 0);
1688 #endif /* TC_NS32K */
1689 #endif /* TC_SPARC|TC_A29K|NEED_FX_R_TYPE */
1690 #endif /* BFD_ASSEMBLER */
1691 *prevP = lie->next_broken_word;
1693 else
1694 prevP = &(lie->next_broken_word);
1696 for (lie = broken_words; lie;)
1698 struct broken_word *untruth;
1699 char *table_ptr;
1700 addressT table_addr;
1701 addressT from_addr, to_addr;
1702 int n, m;
1704 subseg_change (lie->seg, lie->subseg);
1705 fragP = lie->dispfrag;
1707 /* Find out how many broken_words go here. */
1708 n = 0;
1709 for (untruth = lie;
1710 untruth && untruth->dispfrag == fragP;
1711 untruth = untruth->next_broken_word)
1712 if (untruth->added == 1)
1713 n++;
1715 table_ptr = lie->dispfrag->fr_opcode;
1716 table_addr = (lie->dispfrag->fr_address
1717 + (table_ptr - lie->dispfrag->fr_literal));
1718 /* Create the jump around the long jumps. This is a short
1719 jump from table_ptr+0 to table_ptr+n*long_jump_size. */
1720 from_addr = table_addr;
1721 to_addr = table_addr + md_short_jump_size + n * md_long_jump_size;
1722 md_create_short_jump (table_ptr, from_addr, to_addr, lie->dispfrag,
1723 lie->add);
1724 table_ptr += md_short_jump_size;
1725 table_addr += md_short_jump_size;
1727 for (m = 0;
1728 lie && lie->dispfrag == fragP;
1729 m++, lie = lie->next_broken_word)
1731 if (lie->added == 2)
1732 continue;
1733 /* Patch the jump table. */
1734 /* This is the offset from ??? to table_ptr+0. */
1735 to_addr = table_addr - S_GET_VALUE (lie->sub);
1736 #ifdef TC_CHECK_ADJUSTED_BROKEN_DOT_WORD
1737 TC_CHECK_ADJUSTED_BROKEN_DOT_WORD (to_addr, lie);
1738 #endif
1739 md_number_to_chars (lie->word_goes_here, to_addr, 2);
1740 for (untruth = lie->next_broken_word;
1741 untruth && untruth->dispfrag == fragP;
1742 untruth = untruth->next_broken_word)
1744 if (untruth->use_jump == lie)
1745 md_number_to_chars (untruth->word_goes_here, to_addr, 2);
1748 /* Install the long jump. */
1749 /* This is a long jump from table_ptr+0 to the final target. */
1750 from_addr = table_addr;
1751 to_addr = S_GET_VALUE (lie->add) + lie->addnum;
1752 md_create_long_jump (table_ptr, from_addr, to_addr, lie->dispfrag,
1753 lie->add);
1754 table_ptr += md_long_jump_size;
1755 table_addr += md_long_jump_size;
1759 #endif /* not WORKING_DOT_WORD */
1761 #ifndef BFD_ASSEMBLER
1762 #ifndef OBJ_VMS
1763 { /* not vms */
1764 char *the_object_file;
1765 long object_file_size;
1766 /* Scan every FixS performing fixups. We had to wait until now to
1767 do this because md_convert_frag() may have made some fixSs. */
1768 int trsize, drsize;
1770 subseg_change (SEG_TEXT, 0);
1771 trsize = md_reloc_size * fixup_segment (text_fix_root, SEG_TEXT);
1772 subseg_change (SEG_DATA, 0);
1773 drsize = md_reloc_size * fixup_segment (data_fix_root, SEG_DATA);
1774 H_SET_RELOCATION_SIZE (&headers, trsize, drsize);
1776 /* FIXME: Move this stuff into the pre-write-hook. */
1777 H_SET_MAGIC_NUMBER (&headers, magic_number_for_object_file);
1778 H_SET_ENTRY_POINT (&headers, 0);
1780 obj_pre_write_hook (&headers); /* Extra coff stuff. */
1782 object_file_size = H_GET_FILE_SIZE (&headers);
1783 next_object_file_charP = the_object_file = xmalloc (object_file_size);
1785 output_file_create (out_file_name);
1787 obj_header_append (&next_object_file_charP, &headers);
1789 know ((next_object_file_charP - the_object_file)
1790 == H_GET_HEADER_SIZE (&headers));
1792 /* Emit code. */
1793 for (fragP = text_frag_root; fragP; fragP = fragP->fr_next)
1795 register long count;
1796 register char *fill_literal;
1797 register long fill_size;
1799 PROGRESS (1);
1800 know (fragP->fr_type == rs_fill);
1801 append (&next_object_file_charP, fragP->fr_literal,
1802 (unsigned long) fragP->fr_fix);
1803 fill_literal = fragP->fr_literal + fragP->fr_fix;
1804 fill_size = fragP->fr_var;
1805 know (fragP->fr_offset >= 0);
1807 for (count = fragP->fr_offset; count; count--)
1808 append (&next_object_file_charP, fill_literal,
1809 (unsigned long) fill_size);
1812 know ((next_object_file_charP - the_object_file)
1813 == (H_GET_HEADER_SIZE (&headers)
1814 + H_GET_TEXT_SIZE (&headers)
1815 + H_GET_DATA_SIZE (&headers)));
1817 /* Emit relocations. */
1818 obj_emit_relocations (&next_object_file_charP, text_fix_root,
1819 (relax_addressT) 0);
1820 know ((next_object_file_charP - the_object_file)
1821 == (H_GET_HEADER_SIZE (&headers)
1822 + H_GET_TEXT_SIZE (&headers)
1823 + H_GET_DATA_SIZE (&headers)
1824 + H_GET_TEXT_RELOCATION_SIZE (&headers)));
1825 #ifdef TC_I960
1826 /* Make addresses in data relocation directives relative to beginning of
1827 first data fragment, not end of last text fragment: alignment of the
1828 start of the data segment may place a gap between the segments. */
1829 obj_emit_relocations (&next_object_file_charP, data_fix_root,
1830 data0_frchainP->frch_root->fr_address);
1831 #else /* TC_I960 */
1832 obj_emit_relocations (&next_object_file_charP, data_fix_root,
1833 text_last_frag->fr_address);
1834 #endif /* TC_I960 */
1836 know ((next_object_file_charP - the_object_file)
1837 == (H_GET_HEADER_SIZE (&headers)
1838 + H_GET_TEXT_SIZE (&headers)
1839 + H_GET_DATA_SIZE (&headers)
1840 + H_GET_TEXT_RELOCATION_SIZE (&headers)
1841 + H_GET_DATA_RELOCATION_SIZE (&headers)));
1843 /* Emit line number entries. */
1844 OBJ_EMIT_LINENO (&next_object_file_charP, lineno_rootP, the_object_file);
1845 know ((next_object_file_charP - the_object_file)
1846 == (H_GET_HEADER_SIZE (&headers)
1847 + H_GET_TEXT_SIZE (&headers)
1848 + H_GET_DATA_SIZE (&headers)
1849 + H_GET_TEXT_RELOCATION_SIZE (&headers)
1850 + H_GET_DATA_RELOCATION_SIZE (&headers)
1851 + H_GET_LINENO_SIZE (&headers)));
1853 /* Emit symbols. */
1854 obj_emit_symbols (&next_object_file_charP, symbol_rootP);
1855 know ((next_object_file_charP - the_object_file)
1856 == (H_GET_HEADER_SIZE (&headers)
1857 + H_GET_TEXT_SIZE (&headers)
1858 + H_GET_DATA_SIZE (&headers)
1859 + H_GET_TEXT_RELOCATION_SIZE (&headers)
1860 + H_GET_DATA_RELOCATION_SIZE (&headers)
1861 + H_GET_LINENO_SIZE (&headers)
1862 + H_GET_SYMBOL_TABLE_SIZE (&headers)));
1864 /* Emit strings. */
1865 if (string_byte_count > 0)
1866 obj_emit_strings (&next_object_file_charP);
1868 #ifdef BFD_HEADERS
1869 bfd_seek (stdoutput, (file_ptr) 0, 0);
1870 bfd_bwrite (the_object_file, (bfd_size_type) object_file_size, stdoutput);
1871 #else
1873 /* Write the data to the file. */
1874 output_file_append (the_object_file, object_file_size, out_file_name);
1875 free (the_object_file);
1876 #endif
1878 #else /* OBJ_VMS */
1879 /* Now do the VMS-dependent part of writing the object file. */
1880 vms_write_object_file (H_GET_TEXT_SIZE (&headers),
1881 H_GET_DATA_SIZE (&headers),
1882 H_GET_BSS_SIZE (&headers),
1883 text_frag_root, data_frag_root);
1884 #endif /* OBJ_VMS */
1885 #else /* BFD_ASSEMBLER */
1887 /* Resolve symbol values. This needs to be done before processing
1888 the relocations. */
1889 if (symbol_rootP)
1891 symbolS *symp;
1893 for (symp = symbol_rootP; symp; symp = symbol_next (symp))
1894 resolve_symbol_value (symp);
1896 resolve_local_symbol_values ();
1898 PROGRESS (1);
1900 #ifdef tc_frob_file_before_adjust
1901 tc_frob_file_before_adjust ();
1902 #endif
1903 #ifdef obj_frob_file_before_adjust
1904 obj_frob_file_before_adjust ();
1905 #endif
1907 bfd_map_over_sections (stdoutput, adjust_reloc_syms, (char *) 0);
1909 #ifdef tc_frob_file_before_fix
1910 tc_frob_file_before_fix ();
1911 #endif
1912 #ifdef obj_frob_file_before_fix
1913 obj_frob_file_before_fix ();
1914 #endif
1916 bfd_map_over_sections (stdoutput, fix_segment, (char *) 0);
1918 /* Set up symbol table, and write it out. */
1919 if (symbol_rootP)
1921 symbolS *symp;
1923 for (symp = symbol_rootP; symp; symp = symbol_next (symp))
1925 int punt = 0;
1926 const char *name;
1928 if (symbol_mri_common_p (symp))
1930 if (S_IS_EXTERNAL (symp))
1931 as_bad (_("%s: global symbols not supported in common sections"),
1932 S_GET_NAME (symp));
1933 symbol_remove (symp, &symbol_rootP, &symbol_lastP);
1934 continue;
1937 name = S_GET_NAME (symp);
1938 if (name)
1940 const char *name2 =
1941 decode_local_label_name ((char *) S_GET_NAME (symp));
1942 /* They only differ if `name' is a fb or dollar local
1943 label name. */
1944 if (name2 != name && ! S_IS_DEFINED (symp))
1945 as_bad (_("local label `%s' is not defined"), name2);
1948 /* Do it again, because adjust_reloc_syms might introduce
1949 more symbols. They'll probably only be section symbols,
1950 but they'll still need to have the values computed. */
1951 resolve_symbol_value (symp);
1953 /* Skip symbols which were equated to undefined or common
1954 symbols. */
1955 if (symbol_equated_reloc_p (symp))
1957 symbol_remove (symp, &symbol_rootP, &symbol_lastP);
1958 continue;
1961 /* So far, common symbols have been treated like undefined symbols.
1962 Put them in the common section now. */
1963 if (S_IS_DEFINED (symp) == 0
1964 && S_GET_VALUE (symp) != 0)
1965 S_SET_SEGMENT (symp, bfd_com_section_ptr);
1966 #if 0
1967 printf ("symbol `%s'\n\t@%x: value=%d flags=%x seg=%s\n",
1968 S_GET_NAME (symp), symp,
1969 S_GET_VALUE (symp),
1970 symbol_get_bfdsym (symp)->flags,
1971 segment_name (S_GET_SEGMENT (symp)));
1972 #endif
1974 #ifdef obj_frob_symbol
1975 obj_frob_symbol (symp, punt);
1976 #endif
1977 #ifdef tc_frob_symbol
1978 if (! punt || symbol_used_in_reloc_p (symp))
1979 tc_frob_symbol (symp, punt);
1980 #endif
1982 /* If we don't want to keep this symbol, splice it out of
1983 the chain now. If EMIT_SECTION_SYMBOLS is 0, we never
1984 want section symbols. Otherwise, we skip local symbols
1985 and symbols that the frob_symbol macros told us to punt,
1986 but we keep such symbols if they are used in relocs. */
1987 if (symp == abs_section_sym
1988 || (! EMIT_SECTION_SYMBOLS
1989 && symbol_section_p (symp))
1990 /* Note that S_IS_EXTERN and S_IS_LOCAL are not always
1991 opposites. Sometimes the former checks flags and the
1992 latter examines the name... */
1993 || (!S_IS_EXTERN (symp)
1994 && (punt || S_IS_LOCAL (symp))
1995 && ! symbol_used_in_reloc_p (symp)))
1997 symbol_remove (symp, &symbol_rootP, &symbol_lastP);
1999 /* After symbol_remove, symbol_next(symp) still returns
2000 the one that came after it in the chain. So we don't
2001 need to do any extra cleanup work here. */
2002 continue;
2005 /* Make sure we really got a value for the symbol. */
2006 if (! symbol_resolved_p (symp))
2008 as_bad (_("can't resolve value for symbol `%s'"),
2009 S_GET_NAME (symp));
2010 symbol_mark_resolved (symp);
2013 /* Set the value into the BFD symbol. Up til now the value
2014 has only been kept in the gas symbolS struct. */
2015 symbol_get_bfdsym (symp)->value = S_GET_VALUE (symp);
2019 PROGRESS (1);
2021 /* Now do any format-specific adjustments to the symbol table, such
2022 as adding file symbols. */
2023 #ifdef tc_adjust_symtab
2024 tc_adjust_symtab ();
2025 #endif
2026 #ifdef obj_adjust_symtab
2027 obj_adjust_symtab ();
2028 #endif
2030 /* Now that all the sizes are known, and contents correct, we can
2031 start writing to the file. */
2032 set_symtab ();
2034 /* If *_frob_file changes the symbol value at this point, it is
2035 responsible for moving the changed value into symp->bsym->value
2036 as well. Hopefully all symbol value changing can be done in
2037 *_frob_symbol. */
2038 #ifdef tc_frob_file
2039 tc_frob_file ();
2040 #endif
2041 #ifdef obj_frob_file
2042 obj_frob_file ();
2043 #endif
2045 bfd_map_over_sections (stdoutput, write_relocs, (char *) 0);
2047 #ifdef tc_frob_file_after_relocs
2048 tc_frob_file_after_relocs ();
2049 #endif
2050 #ifdef obj_frob_file_after_relocs
2051 obj_frob_file_after_relocs ();
2052 #endif
2054 bfd_map_over_sections (stdoutput, write_contents, (char *) 0);
2055 #endif /* BFD_ASSEMBLER */
2057 #endif /* ! BFD */
2059 #ifdef TC_GENERIC_RELAX_TABLE
2061 /* Relax a fragment by scanning TC_GENERIC_RELAX_TABLE. */
2063 long
2064 relax_frag (segment, fragP, stretch)
2065 segT segment;
2066 fragS *fragP;
2067 long stretch;
2069 const relax_typeS *this_type;
2070 const relax_typeS *start_type;
2071 relax_substateT next_state;
2072 relax_substateT this_state;
2073 offsetT growth;
2074 offsetT aim;
2075 addressT target;
2076 addressT address;
2077 symbolS *symbolP;
2078 const relax_typeS *table;
2080 target = fragP->fr_offset;
2081 address = fragP->fr_address;
2082 table = TC_GENERIC_RELAX_TABLE;
2083 this_state = fragP->fr_subtype;
2084 start_type = this_type = table + this_state;
2085 symbolP = fragP->fr_symbol;
2087 if (symbolP)
2089 fragS *sym_frag;
2091 sym_frag = symbol_get_frag (symbolP);
2093 #ifndef DIFF_EXPR_OK
2094 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
2095 know ((S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE)
2096 || (S_GET_SEGMENT (symbolP) == SEG_DATA)
2097 || (S_GET_SEGMENT (symbolP) == SEG_BSS)
2098 || (S_GET_SEGMENT (symbolP) == SEG_TEXT));
2099 #endif
2100 know (sym_frag != NULL);
2101 #endif
2102 know (S_GET_SEGMENT (symbolP) != absolute_section
2103 || sym_frag == &zero_address_frag);
2104 target += S_GET_VALUE (symbolP);
2106 /* If frag has yet to be reached on this pass,
2107 assume it will move by STRETCH just as we did.
2108 If this is not so, it will be because some frag
2109 between grows, and that will force another pass. */
2111 if (stretch != 0
2112 && sym_frag->relax_marker != fragP->relax_marker
2113 && S_GET_SEGMENT (symbolP) == segment)
2115 target += stretch;
2119 aim = target - address - fragP->fr_fix;
2120 #ifdef TC_PCREL_ADJUST
2121 /* Currently only the ns32k family needs this. */
2122 aim += TC_PCREL_ADJUST (fragP);
2123 /* #else */
2124 /* This machine doesn't want to use pcrel_adjust.
2125 In that case, pcrel_adjust should be zero. */
2126 #if 0
2127 assert (fragP->fr_targ.ns32k.pcrel_adjust == 0);
2128 #endif
2129 #endif
2130 #ifdef md_prepare_relax_scan /* formerly called M68K_AIM_KLUDGE */
2131 md_prepare_relax_scan (fragP, address, aim, this_state, this_type);
2132 #endif
2134 if (aim < 0)
2136 /* Look backwards. */
2137 for (next_state = this_type->rlx_more; next_state;)
2138 if (aim >= this_type->rlx_backward)
2139 next_state = 0;
2140 else
2142 /* Grow to next state. */
2143 this_state = next_state;
2144 this_type = table + this_state;
2145 next_state = this_type->rlx_more;
2148 else
2150 /* Look forwards. */
2151 for (next_state = this_type->rlx_more; next_state;)
2152 if (aim <= this_type->rlx_forward)
2153 next_state = 0;
2154 else
2156 /* Grow to next state. */
2157 this_state = next_state;
2158 this_type = table + this_state;
2159 next_state = this_type->rlx_more;
2163 growth = this_type->rlx_length - start_type->rlx_length;
2164 if (growth != 0)
2165 fragP->fr_subtype = this_state;
2166 return growth;
2169 #endif /* defined (TC_GENERIC_RELAX_TABLE) */
2171 /* Relax_align. Advance location counter to next address that has 'alignment'
2172 lowest order bits all 0s, return size of adjustment made. */
2173 static relax_addressT
2174 relax_align (address, alignment)
2175 register relax_addressT address; /* Address now. */
2176 register int alignment; /* Alignment (binary). */
2178 relax_addressT mask;
2179 relax_addressT new_address;
2181 mask = ~((~0) << alignment);
2182 new_address = (address + mask) & (~mask);
2183 #ifdef LINKER_RELAXING_SHRINKS_ONLY
2184 if (linkrelax)
2185 /* We must provide lots of padding, so the linker can discard it
2186 when needed. The linker will not add extra space, ever. */
2187 new_address += (1 << alignment);
2188 #endif
2189 return (new_address - address);
2192 /* Now we have a segment, not a crowd of sub-segments, we can make
2193 fr_address values.
2195 Relax the frags.
2197 After this, all frags in this segment have addresses that are correct
2198 within the segment. Since segments live in different file addresses,
2199 these frag addresses may not be the same as final object-file
2200 addresses. */
2203 relax_segment (segment_frag_root, segment)
2204 struct frag *segment_frag_root;
2205 segT segment;
2207 register struct frag *fragP;
2208 register relax_addressT address;
2209 int ret;
2211 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
2212 know (segment == SEG_DATA || segment == SEG_TEXT || segment == SEG_BSS);
2213 #endif
2214 /* In case md_estimate_size_before_relax() wants to make fixSs. */
2215 subseg_change (segment, 0);
2217 /* For each frag in segment: count and store (a 1st guess of)
2218 fr_address. */
2219 address = 0;
2220 for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next)
2222 fragP->relax_marker = 0;
2223 fragP->fr_address = address;
2224 address += fragP->fr_fix;
2226 switch (fragP->fr_type)
2228 case rs_fill:
2229 address += fragP->fr_offset * fragP->fr_var;
2230 break;
2232 case rs_align:
2233 case rs_align_code:
2234 case rs_align_test:
2236 addressT offset = relax_align (address, (int) fragP->fr_offset);
2238 if (fragP->fr_subtype != 0 && offset > fragP->fr_subtype)
2239 offset = 0;
2241 if (offset % fragP->fr_var != 0)
2243 as_bad_where (fragP->fr_file, fragP->fr_line,
2244 _("alignment padding (%lu bytes) not a multiple of %ld"),
2245 (unsigned long) offset, (long) fragP->fr_var);
2246 offset -= (offset % fragP->fr_var);
2249 address += offset;
2251 break;
2253 case rs_org:
2254 case rs_space:
2255 /* Assume .org is nugatory. It will grow with 1st relax. */
2256 break;
2258 case rs_machine_dependent:
2259 /* If fr_symbol is an expression, this call to
2260 resolve_symbol_value sets up the correct segment, which will
2261 likely be needed in md_estimate_size_before_relax. */
2262 if (fragP->fr_symbol)
2263 resolve_symbol_value (fragP->fr_symbol);
2265 address += md_estimate_size_before_relax (fragP, segment);
2266 break;
2268 #ifndef WORKING_DOT_WORD
2269 /* Broken words don't concern us yet. */
2270 case rs_broken_word:
2271 break;
2272 #endif
2274 case rs_leb128:
2275 /* Initial guess is always 1; doing otherwise can result in
2276 stable solutions that are larger than the minimum. */
2277 address += fragP->fr_offset = 1;
2278 break;
2280 case rs_cfa:
2281 address += eh_frame_estimate_size_before_relax (fragP);
2282 break;
2284 case rs_dwarf2dbg:
2285 address += dwarf2dbg_estimate_size_before_relax (fragP);
2286 break;
2288 default:
2289 BAD_CASE (fragP->fr_type);
2290 break;
2294 /* Do relax(). */
2296 offsetT stretch; /* May be any size, 0 or negative. */
2297 /* Cumulative number of addresses we have relaxed this pass.
2298 We may have relaxed more than one address. */
2299 int stretched; /* Have we stretched on this pass? */
2300 /* This is 'cuz stretch may be zero, when, in fact some piece of code
2301 grew, and another shrank. If a branch instruction doesn't fit anymore,
2302 we could be scrod. */
2306 stretch = 0;
2307 stretched = 0;
2309 for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next)
2311 offsetT growth = 0;
2312 addressT was_address;
2313 offsetT offset;
2314 symbolS *symbolP;
2316 fragP->relax_marker ^= 1;
2317 was_address = fragP->fr_address;
2318 address = fragP->fr_address += stretch;
2319 symbolP = fragP->fr_symbol;
2320 offset = fragP->fr_offset;
2322 switch (fragP->fr_type)
2324 case rs_fill: /* .fill never relaxes. */
2325 growth = 0;
2326 break;
2328 #ifndef WORKING_DOT_WORD
2329 /* JF: This is RMS's idea. I do *NOT* want to be blamed
2330 for it I do not want to write it. I do not want to have
2331 anything to do with it. This is not the proper way to
2332 implement this misfeature. */
2333 case rs_broken_word:
2335 struct broken_word *lie;
2336 struct broken_word *untruth;
2338 /* Yes this is ugly (storing the broken_word pointer
2339 in the symbol slot). Still, this whole chunk of
2340 code is ugly, and I don't feel like doing anything
2341 about it. Think of it as stubbornness in action. */
2342 growth = 0;
2343 for (lie = (struct broken_word *) (fragP->fr_symbol);
2344 lie && lie->dispfrag == fragP;
2345 lie = lie->next_broken_word)
2348 if (lie->added)
2349 continue;
2351 offset = (S_GET_VALUE (lie->add)
2352 + lie->addnum
2353 - S_GET_VALUE (lie->sub));
2354 if (offset <= -32768 || offset >= 32767)
2356 if (flag_warn_displacement)
2358 char buf[50];
2359 sprint_value (buf, (addressT) lie->addnum);
2360 as_warn_where (fragP->fr_file, fragP->fr_line,
2361 _(".word %s-%s+%s didn't fit"),
2362 S_GET_NAME (lie->add),
2363 S_GET_NAME (lie->sub),
2364 buf);
2366 lie->added = 1;
2367 if (fragP->fr_subtype == 0)
2369 fragP->fr_subtype++;
2370 growth += md_short_jump_size;
2372 for (untruth = lie->next_broken_word;
2373 untruth && untruth->dispfrag == lie->dispfrag;
2374 untruth = untruth->next_broken_word)
2375 if ((symbol_get_frag (untruth->add)
2376 == symbol_get_frag (lie->add))
2377 && (S_GET_VALUE (untruth->add)
2378 == S_GET_VALUE (lie->add)))
2380 untruth->added = 2;
2381 untruth->use_jump = lie;
2383 growth += md_long_jump_size;
2387 break;
2388 } /* case rs_broken_word */
2389 #endif
2390 case rs_align:
2391 case rs_align_code:
2392 case rs_align_test:
2394 addressT oldoff, newoff;
2396 oldoff = relax_align (was_address + fragP->fr_fix,
2397 (int) offset);
2398 newoff = relax_align (address + fragP->fr_fix,
2399 (int) offset);
2401 if (fragP->fr_subtype != 0)
2403 if (oldoff > fragP->fr_subtype)
2404 oldoff = 0;
2405 if (newoff > fragP->fr_subtype)
2406 newoff = 0;
2409 growth = newoff - oldoff;
2411 break;
2413 case rs_org:
2415 addressT target = offset;
2416 addressT after;
2418 if (symbolP)
2420 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
2421 know ((S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE)
2422 || (S_GET_SEGMENT (symbolP) == SEG_DATA)
2423 || (S_GET_SEGMENT (symbolP) == SEG_TEXT)
2424 || S_GET_SEGMENT (symbolP) == SEG_BSS);
2425 know (symbolP->sy_frag);
2426 know (!(S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE)
2427 || (symbolP->sy_frag == &zero_address_frag));
2428 #endif
2429 /* Convert from an actual address to an octet offset
2430 into the section. Here it is assumed that the
2431 section's VMA is zero, and can omit subtracting it
2432 from the symbol's value to get the address offset. */
2433 know (S_GET_SECTION (symbolP)->vma == 0);
2434 target += S_GET_VALUE (symbolP) * OCTETS_PER_BYTE;
2437 know (fragP->fr_next);
2438 after = fragP->fr_next->fr_address;
2439 growth = target - after;
2440 if (growth < 0)
2442 /* Growth may be negative, but variable part of frag
2443 cannot have fewer than 0 chars. That is, we can't
2444 .org backwards. */
2445 as_bad_where (fragP->fr_file, fragP->fr_line,
2446 _("attempt to move .org backwards"));
2448 /* We've issued an error message. Change the
2449 frag to avoid cascading errors. */
2450 fragP->fr_type = rs_align;
2451 fragP->fr_subtype = 0;
2452 fragP->fr_offset = 0;
2453 fragP->fr_fix = after - address;
2454 growth = stretch;
2457 /* This is an absolute growth factor */
2458 growth -= stretch;
2459 break;
2462 case rs_space:
2463 growth = 0;
2464 if (symbolP)
2466 offsetT amount;
2468 amount = S_GET_VALUE (symbolP);
2469 if (S_GET_SEGMENT (symbolP) != absolute_section
2470 || S_IS_COMMON (symbolP)
2471 || ! S_IS_DEFINED (symbolP))
2473 as_bad_where (fragP->fr_file, fragP->fr_line,
2474 _(".space specifies non-absolute value"));
2475 /* Prevent repeat of this error message. */
2476 fragP->fr_symbol = 0;
2478 else if (amount < 0)
2480 as_warn_where (fragP->fr_file, fragP->fr_line,
2481 _(".space or .fill with negative value, ignored"));
2482 fragP->fr_symbol = 0;
2484 else
2485 growth = (was_address + fragP->fr_fix + amount
2486 - fragP->fr_next->fr_address);
2488 break;
2490 case rs_machine_dependent:
2491 #ifdef md_relax_frag
2492 growth = md_relax_frag (segment, fragP, stretch);
2493 #else
2494 #ifdef TC_GENERIC_RELAX_TABLE
2495 /* The default way to relax a frag is to look through
2496 TC_GENERIC_RELAX_TABLE. */
2497 growth = relax_frag (segment, fragP, stretch);
2498 #endif /* TC_GENERIC_RELAX_TABLE */
2499 #endif
2500 break;
2502 case rs_leb128:
2504 valueT value;
2505 offsetT size;
2507 value = resolve_symbol_value (fragP->fr_symbol);
2508 size = sizeof_leb128 (value, fragP->fr_subtype);
2509 growth = size - fragP->fr_offset;
2510 fragP->fr_offset = size;
2512 break;
2514 case rs_cfa:
2515 growth = eh_frame_relax_frag (fragP);
2516 break;
2518 case rs_dwarf2dbg:
2519 growth = dwarf2dbg_relax_frag (fragP);
2520 break;
2522 default:
2523 BAD_CASE (fragP->fr_type);
2524 break;
2526 if (growth)
2528 stretch += growth;
2529 stretched = 1;
2531 } /* For each frag in the segment. */
2533 while (stretched); /* Until nothing further to relax. */
2534 } /* do_relax */
2536 ret = 0;
2537 for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next)
2538 if (fragP->last_fr_address != fragP->fr_address)
2540 fragP->last_fr_address = fragP->fr_address;
2541 ret = 1;
2543 return ret;
2546 #if defined (BFD_ASSEMBLER) || (!defined (BFD) && !defined (OBJ_VMS))
2548 /* fixup_segment()
2550 Go through all the fixS's in a segment and see which ones can be
2551 handled now. (These consist of fixS where we have since discovered
2552 the value of a symbol, or the address of the frag involved.)
2553 For each one, call md_apply_fix3 to put the fix into the frag data.
2555 Result is a count of how many relocation structs will be needed to
2556 handle the remaining fixS's that we couldn't completely handle here.
2557 These will be output later by emit_relocations(). */
2559 static long
2560 fixup_segment (fixP, this_segment)
2561 fixS *fixP;
2562 segT this_segment;
2564 long seg_reloc_count = 0;
2565 valueT add_number;
2566 fragS *fragP;
2567 segT add_symbol_segment = absolute_section;
2569 if (fixP != NULL && abs_section_sym == NULL)
2571 #ifndef BFD_ASSEMBLER
2572 abs_section_sym = &abs_symbol;
2573 #else
2574 abs_section_sym = section_symbol (absolute_section);
2575 #endif
2578 /* If the linker is doing the relaxing, we must not do any fixups.
2580 Well, strictly speaking that's not true -- we could do any that
2581 are PC-relative and don't cross regions that could change size.
2582 And for the i960 we might be able to turn callx/callj into bal
2583 anyways in cases where we know the maximum displacement. */
2584 if (linkrelax && TC_LINKRELAX_FIXUP (this_segment))
2586 for (; fixP; fixP = fixP->fx_next)
2587 if (!fixP->fx_done)
2589 if (fixP->fx_addsy == NULL)
2591 /* There was no symbol required by this relocation.
2592 However, BFD doesn't really handle relocations
2593 without symbols well. So fake up a local symbol in
2594 the absolute section. */
2595 fixP->fx_addsy = abs_section_sym;
2597 symbol_mark_used_in_reloc (fixP->fx_addsy);
2598 if (fixP->fx_subsy != NULL)
2599 symbol_mark_used_in_reloc (fixP->fx_subsy);
2600 seg_reloc_count++;
2602 TC_ADJUST_RELOC_COUNT (fixP, seg_reloc_count);
2603 return seg_reloc_count;
2606 for (; fixP; fixP = fixP->fx_next)
2608 #ifdef DEBUG5
2609 fprintf (stderr, "\nprocessing fixup:\n");
2610 print_fixup (fixP);
2611 #endif
2613 fragP = fixP->fx_frag;
2614 know (fragP);
2615 #ifdef TC_VALIDATE_FIX
2616 TC_VALIDATE_FIX (fixP, this_segment, skip);
2617 #endif
2618 add_number = fixP->fx_offset;
2620 if (fixP->fx_addsy != NULL
2621 && symbol_mri_common_p (fixP->fx_addsy))
2623 know (fixP->fx_addsy->sy_value.X_op == O_symbol);
2624 add_number += S_GET_VALUE (fixP->fx_addsy);
2625 fixP->fx_offset = add_number;
2626 fixP->fx_addsy
2627 = symbol_get_value_expression (fixP->fx_addsy)->X_add_symbol;
2630 if (fixP->fx_addsy != NULL)
2631 add_symbol_segment = S_GET_SEGMENT (fixP->fx_addsy);
2633 if (fixP->fx_subsy != NULL)
2635 segT sub_symbol_segment;
2636 resolve_symbol_value (fixP->fx_subsy);
2637 sub_symbol_segment = S_GET_SEGMENT (fixP->fx_subsy);
2638 if (fixP->fx_addsy != NULL
2639 && sub_symbol_segment == add_symbol_segment
2640 && !TC_FORCE_RELOCATION_SUB_SAME (fixP, add_symbol_segment))
2642 add_number += S_GET_VALUE (fixP->fx_addsy);
2643 add_number -= S_GET_VALUE (fixP->fx_subsy);
2644 fixP->fx_offset = add_number;
2645 /* If the back-end code has selected a pc-relative
2646 reloc, adjust the value to be pc-relative. */
2647 if (1
2648 #ifdef TC_M68K
2649 /* See the comment below about 68k weirdness. */
2650 && 0
2651 #endif
2652 && fixP->fx_pcrel)
2653 add_number -= MD_PCREL_FROM_SECTION (fixP, this_segment);
2654 fixP->fx_addsy = NULL;
2655 fixP->fx_subsy = NULL;
2656 fixP->fx_pcrel = 0;
2658 else if (sub_symbol_segment == absolute_section
2659 && !TC_FORCE_RELOCATION_SUB_ABS (fixP))
2661 add_number -= S_GET_VALUE (fixP->fx_subsy);
2662 fixP->fx_offset = add_number;
2663 fixP->fx_subsy = NULL;
2665 else if (sub_symbol_segment == this_segment
2666 && !TC_FORCE_RELOCATION_SUB_LOCAL (fixP))
2668 add_number -= S_GET_VALUE (fixP->fx_subsy);
2669 fixP->fx_offset = (add_number + fixP->fx_dot_value
2670 + fixP->fx_frag->fr_address);
2672 /* Make it pc-relative. If the back-end code has not
2673 selected a pc-relative reloc, cancel the adjustment
2674 we do later on all pc-relative relocs. */
2675 if (0
2676 #ifdef TC_M68K
2677 /* Do this for m68k even if it's already described
2678 as pc-relative. On the m68k, an operand of
2679 "pc@(foo-.-2)" should address "foo" in a
2680 pc-relative mode. */
2681 || 1
2682 #endif
2683 || !fixP->fx_pcrel)
2684 add_number += MD_PCREL_FROM_SECTION (fixP, this_segment);
2685 fixP->fx_subsy = NULL;
2686 fixP->fx_pcrel = 1;
2688 else if (!TC_VALIDATE_FIX_SUB (fixP))
2690 as_bad_where (fixP->fx_file, fixP->fx_line,
2691 _("can't resolve `%s' {%s section} - `%s' {%s section}"),
2692 fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : "0",
2693 segment_name (add_symbol_segment),
2694 S_GET_NAME (fixP->fx_subsy),
2695 segment_name (sub_symbol_segment));
2699 if (fixP->fx_addsy)
2701 if (add_symbol_segment == this_segment
2702 && !TC_FORCE_RELOCATION_LOCAL (fixP))
2704 /* This fixup was made when the symbol's segment was
2705 SEG_UNKNOWN, but it is now in the local segment.
2706 So we know how to do the address without relocation. */
2707 add_number += S_GET_VALUE (fixP->fx_addsy);
2708 fixP->fx_offset = add_number;
2709 if (fixP->fx_pcrel)
2710 add_number -= MD_PCREL_FROM_SECTION (fixP, this_segment);
2711 fixP->fx_addsy = NULL;
2712 fixP->fx_pcrel = 0;
2714 else if (add_symbol_segment == absolute_section
2715 && !TC_FORCE_RELOCATION_ABS (fixP))
2717 add_number += S_GET_VALUE (fixP->fx_addsy);
2718 fixP->fx_offset = add_number;
2719 fixP->fx_addsy = NULL;
2721 else if (add_symbol_segment != undefined_section
2722 #ifdef BFD_ASSEMBLER
2723 && ! bfd_is_com_section (add_symbol_segment)
2724 #endif
2725 && MD_APPLY_SYM_VALUE (fixP))
2726 add_number += S_GET_VALUE (fixP->fx_addsy);
2729 if (fixP->fx_pcrel)
2731 add_number -= MD_PCREL_FROM_SECTION (fixP, this_segment);
2732 if (!fixP->fx_done && fixP->fx_addsy == NULL)
2734 /* There was no symbol required by this relocation.
2735 However, BFD doesn't really handle relocations
2736 without symbols well. So fake up a local symbol in
2737 the absolute section. */
2738 fixP->fx_addsy = abs_section_sym;
2742 if (!fixP->fx_done)
2743 md_apply_fix3 (fixP, &add_number, this_segment);
2745 if (!fixP->fx_done)
2747 ++seg_reloc_count;
2748 if (fixP->fx_addsy == NULL)
2749 fixP->fx_addsy = abs_section_sym;
2750 symbol_mark_used_in_reloc (fixP->fx_addsy);
2751 if (fixP->fx_subsy != NULL)
2752 symbol_mark_used_in_reloc (fixP->fx_subsy);
2755 if (!fixP->fx_bit_fixP && !fixP->fx_no_overflow && fixP->fx_size != 0)
2757 if (fixP->fx_size < sizeof (valueT))
2759 valueT mask;
2761 mask = 0;
2762 mask--; /* Set all bits to one. */
2763 mask <<= fixP->fx_size * 8 - (fixP->fx_signed ? 1 : 0);
2764 if ((add_number & mask) != 0 && (add_number & mask) != mask)
2766 char buf[50], buf2[50];
2767 sprint_value (buf, fragP->fr_address + fixP->fx_where);
2768 if (add_number > 1000)
2769 sprint_value (buf2, add_number);
2770 else
2771 sprintf (buf2, "%ld", (long) add_number);
2772 as_bad_where (fixP->fx_file, fixP->fx_line,
2773 _("value of %s too large for field of %d bytes at %s"),
2774 buf2, fixP->fx_size, buf);
2775 } /* Generic error checking. */
2777 #ifdef WARN_SIGNED_OVERFLOW_WORD
2778 /* Warn if a .word value is too large when treated as a signed
2779 number. We already know it is not too negative. This is to
2780 catch over-large switches generated by gcc on the 68k. */
2781 if (!flag_signed_overflow_ok
2782 && fixP->fx_size == 2
2783 && add_number > 0x7fff)
2784 as_bad_where (fixP->fx_file, fixP->fx_line,
2785 _("signed .word overflow; switch may be too large; %ld at 0x%lx"),
2786 (long) add_number,
2787 (long) (fragP->fr_address + fixP->fx_where));
2788 #endif
2789 } /* Not a bit fix. */
2791 #ifdef TC_VALIDATE_FIX
2792 skip: ATTRIBUTE_UNUSED_LABEL
2794 #endif
2795 #ifdef DEBUG5
2796 fprintf (stderr, "result:\n");
2797 print_fixup (fixP);
2798 #endif
2799 } /* For each fixS in this segment. */
2801 TC_ADJUST_RELOC_COUNT (fixP, seg_reloc_count);
2802 return seg_reloc_count;
2805 #endif /* defined (BFD_ASSEMBLER) || (!defined (BFD) && !defined (OBJ_VMS)) */
2807 void
2808 number_to_chars_bigendian (buf, val, n)
2809 char *buf;
2810 valueT val;
2811 int n;
2813 if (n <= 0)
2814 abort ();
2815 while (n--)
2817 buf[n] = val & 0xff;
2818 val >>= 8;
2822 void
2823 number_to_chars_littleendian (buf, val, n)
2824 char *buf;
2825 valueT val;
2826 int n;
2828 if (n <= 0)
2829 abort ();
2830 while (n--)
2832 *buf++ = val & 0xff;
2833 val >>= 8;
2837 void
2838 write_print_statistics (file)
2839 FILE *file;
2841 fprintf (file, "fixups: %d\n", n_fixups);
2844 /* For debugging. */
2845 extern int indent_level;
2847 void
2848 print_fixup (fixp)
2849 fixS *fixp;
2851 indent_level = 1;
2852 fprintf (stderr, "fix %lx %s:%d", (long) fixp, fixp->fx_file, fixp->fx_line);
2853 if (fixp->fx_pcrel)
2854 fprintf (stderr, " pcrel");
2855 if (fixp->fx_pcrel_adjust)
2856 fprintf (stderr, " pcrel_adjust=%d", fixp->fx_pcrel_adjust);
2857 if (fixp->fx_im_disp)
2859 #ifdef TC_NS32K
2860 fprintf (stderr, " im_disp=%d", fixp->fx_im_disp);
2861 #else
2862 fprintf (stderr, " im_disp");
2863 #endif
2865 if (fixp->fx_tcbit)
2866 fprintf (stderr, " tcbit");
2867 if (fixp->fx_done)
2868 fprintf (stderr, " done");
2869 fprintf (stderr, "\n size=%d frag=%lx where=%ld offset=%lx addnumber=%lx",
2870 fixp->fx_size, (long) fixp->fx_frag, (long) fixp->fx_where,
2871 (long) fixp->fx_offset, (long) fixp->fx_addnumber);
2872 #ifdef BFD_ASSEMBLER
2873 fprintf (stderr, "\n %s (%d)", bfd_get_reloc_code_name (fixp->fx_r_type),
2874 fixp->fx_r_type);
2875 #else
2876 #ifdef NEED_FX_R_TYPE
2877 fprintf (stderr, " r_type=%d", fixp->fx_r_type);
2878 #endif
2879 #endif
2880 if (fixp->fx_addsy)
2882 fprintf (stderr, "\n +<");
2883 print_symbol_value_1 (stderr, fixp->fx_addsy);
2884 fprintf (stderr, ">");
2886 if (fixp->fx_subsy)
2888 fprintf (stderr, "\n -<");
2889 print_symbol_value_1 (stderr, fixp->fx_subsy);
2890 fprintf (stderr, ">");
2892 fprintf (stderr, "\n");
2893 #ifdef TC_FIX_DATA_PRINT
2894 TC_FIX_DATA_PRINT (stderr, fixp);
2895 #endif