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, 2004, 2005, 2006, 2007
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 3, or (at your option)
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, 51 Franklin Street - Fifth Floor, Boston, MA
23 /* This thing should be set up to do byteordering correctly. But... */
28 #include "output-file.h"
29 #include "dwarf2dbg.h"
32 #ifndef TC_ADJUST_RELOC_COUNT
33 #define TC_ADJUST_RELOC_COUNT(FIX, COUNT)
36 #ifndef TC_FORCE_RELOCATION
37 #define TC_FORCE_RELOCATION(FIX) \
38 (generic_force_reloc (FIX))
41 #ifndef TC_FORCE_RELOCATION_ABS
42 #define TC_FORCE_RELOCATION_ABS(FIX) \
43 (TC_FORCE_RELOCATION (FIX))
46 #ifndef TC_FORCE_RELOCATION_LOCAL
47 #define TC_FORCE_RELOCATION_LOCAL(FIX) \
49 || TC_FORCE_RELOCATION (FIX))
52 #ifndef TC_FORCE_RELOCATION_SUB_SAME
53 #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
57 #ifndef TC_FORCE_RELOCATION_SUB_ABS
58 #define TC_FORCE_RELOCATION_SUB_ABS(FIX) 0
61 #ifndef TC_FORCE_RELOCATION_SUB_LOCAL
63 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) 0
65 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) 1
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
74 #define TC_VALIDATE_FIX_SUB(FIX) \
75 ((FIX)->fx_r_type == BFD_RELOC_GPREL32 \
76 || (FIX)->fx_r_type == BFD_RELOC_GPREL16)
80 #ifndef TC_LINKRELAX_FIXUP
81 #define TC_LINKRELAX_FIXUP(SEG) 1
84 #ifndef MD_APPLY_SYM_VALUE
85 #define MD_APPLY_SYM_VALUE(FIX) 1
88 #ifndef TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
89 #define TC_FINALIZE_SYMS_BEFORE_SIZE_SEG 1
92 #ifndef MD_PCREL_FROM_SECTION
93 #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from (FIX)
97 #define TC_FAKE_LABEL(NAME) (strcmp ((NAME), FAKE_LABEL_NAME) == 0)
100 /* Positive values of TC_FX_SIZE_SLACK allow a target to define
101 fixups that far past the end of a frag. Having such fixups
102 is of course most most likely a bug in setting fx_size correctly.
103 A negative value disables the fixup check entirely, which is
104 appropriate for something like the Renesas / SuperH SH_COUNT
106 #ifndef TC_FX_SIZE_SLACK
107 #define TC_FX_SIZE_SLACK(FIX) 0
110 /* Used to control final evaluation of expressions. */
111 int finalize_syms
= 0;
113 int symbol_table_frozen
;
115 symbolS
*abs_section_sym
;
117 /* Remember the value of dot when parsing expressions. */
120 /* Relocs generated by ".reloc" pseudo. */
121 struct reloc_list
* reloc_list
;
123 void print_fixup (fixS
*);
125 /* We generally attach relocs to frag chains. However, after we have
126 chained these all together into a segment, any relocs we add after
127 that must be attached to a segment. This will include relocs added
128 in md_estimate_size_for_relax, for example. */
129 static int frags_chained
= 0;
133 #define RELOC_ENUM enum bfd_reloc_code_real
135 /* Create a fixS in obstack 'notes'. */
138 fix_new_internal (fragS
*frag
, /* Which frag? */
139 int where
, /* Where in that frag? */
140 int size
, /* 1, 2, or 4 usually. */
141 symbolS
*add_symbol
, /* X_add_symbol. */
142 symbolS
*sub_symbol
, /* X_op_symbol. */
143 offsetT offset
, /* X_add_number. */
144 int pcrel
, /* TRUE if PC-relative relocation. */
145 RELOC_ENUM r_type ATTRIBUTE_UNUSED
/* Relocation type. */)
151 fixP
= obstack_alloc (¬es
, sizeof (fixS
));
153 fixP
->fx_frag
= frag
;
154 fixP
->fx_where
= where
;
155 fixP
->fx_size
= size
;
156 /* We've made fx_size a narrow field; check that it's wide enough. */
157 if (fixP
->fx_size
!= size
)
159 as_bad (_("field fx_size too small to hold %d"), size
);
162 fixP
->fx_addsy
= add_symbol
;
163 fixP
->fx_subsy
= sub_symbol
;
164 fixP
->fx_offset
= offset
;
165 fixP
->fx_dot_value
= dot_value
;
166 fixP
->fx_pcrel
= pcrel
;
167 fixP
->fx_r_type
= r_type
;
168 fixP
->fx_im_disp
= 0;
169 fixP
->fx_pcrel_adjust
= 0;
170 fixP
->fx_bit_fixP
= 0;
171 fixP
->fx_addnumber
= 0;
175 fixP
->fx_no_overflow
= 0;
179 fixP
->fx_cgen
.insn
= NULL
;
180 fixP
->fx_cgen
.opinfo
= 0;
184 TC_INIT_FIX_DATA (fixP
);
187 as_where (&fixP
->fx_file
, &fixP
->fx_line
);
189 /* Usually, we want relocs sorted numerically, but while
190 comparing to older versions of gas that have relocs
191 reverse sorted, it is convenient to have this compile
192 time option. xoxorich. */
195 fixS
**seg_fix_rootP
= (frags_chained
196 ? &seg_info (now_seg
)->fix_root
197 : &frchain_now
->fix_root
);
198 fixS
**seg_fix_tailP
= (frags_chained
199 ? &seg_info (now_seg
)->fix_tail
200 : &frchain_now
->fix_tail
);
202 #ifdef REVERSE_SORT_RELOCS
204 fixP
->fx_next
= *seg_fix_rootP
;
205 *seg_fix_rootP
= fixP
;
207 #else /* REVERSE_SORT_RELOCS */
209 fixP
->fx_next
= NULL
;
212 (*seg_fix_tailP
)->fx_next
= fixP
;
214 *seg_fix_rootP
= fixP
;
215 *seg_fix_tailP
= fixP
;
217 #endif /* REVERSE_SORT_RELOCS */
223 /* Create a fixup relative to a symbol (plus a constant). */
226 fix_new (fragS
*frag
, /* Which frag? */
227 int where
, /* Where in that frag? */
228 int size
, /* 1, 2, or 4 usually. */
229 symbolS
*add_symbol
, /* X_add_symbol. */
230 offsetT offset
, /* X_add_number. */
231 int pcrel
, /* TRUE if PC-relative relocation. */
232 RELOC_ENUM r_type
/* Relocation type. */)
234 return fix_new_internal (frag
, where
, size
, add_symbol
,
235 (symbolS
*) NULL
, offset
, pcrel
, r_type
);
238 /* Create a fixup for an expression. Currently we only support fixups
239 for difference expressions. That is itself more than most object
240 file formats support anyhow. */
243 fix_new_exp (fragS
*frag
, /* Which frag? */
244 int where
, /* Where in that frag? */
245 int size
, /* 1, 2, or 4 usually. */
246 expressionS
*exp
, /* Expression. */
247 int pcrel
, /* TRUE if PC-relative relocation. */
248 RELOC_ENUM r_type
/* Relocation type. */)
260 as_bad (_("register value used as expression"));
264 /* This comes up when _GLOBAL_OFFSET_TABLE_+(.-L0) is read, if
265 the difference expression cannot immediately be reduced. */
267 symbolS
*stmp
= make_expr_symbol (exp
);
269 exp
->X_op
= O_symbol
;
270 exp
->X_op_symbol
= 0;
271 exp
->X_add_symbol
= stmp
;
272 exp
->X_add_number
= 0;
274 return fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
278 add
= exp
->X_add_symbol
;
279 off
= exp
->X_add_number
;
280 r_type
= BFD_RELOC_RVA
;
284 sub
= exp
->X_add_symbol
;
285 off
= exp
->X_add_number
;
289 sub
= exp
->X_op_symbol
;
292 add
= exp
->X_add_symbol
;
295 off
= exp
->X_add_number
;
299 add
= make_expr_symbol (exp
);
303 return fix_new_internal (frag
, where
, size
, add
, sub
, off
, pcrel
, r_type
);
306 /* Generic function to determine whether a fixup requires a relocation. */
308 generic_force_reloc (fixS
*fix
)
310 if (fix
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
311 || fix
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
314 if (fix
->fx_addsy
== NULL
)
317 return S_FORCE_RELOC (fix
->fx_addsy
, fix
->fx_subsy
== NULL
);
320 /* Append a string onto another string, bumping the pointer along. */
322 append (char **charPP
, char *fromP
, unsigned long length
)
324 /* Don't trust memcpy() of 0 chars. */
328 memcpy (*charPP
, fromP
, length
);
332 /* This routine records the largest alignment seen for each segment.
333 If the beginning of the segment is aligned on the worst-case
334 boundary, all of the other alignments within it will work. At
335 least one object format really uses this info. */
338 record_alignment (/* Segment to which alignment pertains. */
340 /* Alignment, as a power of 2 (e.g., 1 => 2-byte
341 boundary, 2 => 4-byte boundary, etc.) */
344 if (seg
== absolute_section
)
347 if ((unsigned int) align
> bfd_get_section_alignment (stdoutput
, seg
))
348 bfd_set_section_alignment (stdoutput
, seg
, align
);
352 get_recorded_alignment (segT seg
)
354 if (seg
== absolute_section
)
357 return bfd_get_section_alignment (stdoutput
, seg
);
360 /* Reset the section indices after removing the gas created sections. */
363 renumber_sections (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, void *countparg
)
365 int *countp
= (int *) countparg
;
367 sec
->index
= *countp
;
372 chain_frchains_together_1 (segT section
, struct frchain
*frchp
)
374 fragS dummy
, *prev_frag
= &dummy
;
375 fixS fix_dummy
, *prev_fix
= &fix_dummy
;
377 for (; frchp
; frchp
= frchp
->frch_next
)
379 prev_frag
->fr_next
= frchp
->frch_root
;
380 prev_frag
= frchp
->frch_last
;
381 assert (prev_frag
->fr_type
!= 0);
382 if (frchp
->fix_root
!= (fixS
*) NULL
)
384 if (seg_info (section
)->fix_root
== (fixS
*) NULL
)
385 seg_info (section
)->fix_root
= frchp
->fix_root
;
386 prev_fix
->fx_next
= frchp
->fix_root
;
387 seg_info (section
)->fix_tail
= frchp
->fix_tail
;
388 prev_fix
= frchp
->fix_tail
;
391 assert (prev_frag
->fr_type
!= 0);
392 assert (prev_frag
!= &dummy
);
393 prev_frag
->fr_next
= 0;
398 chain_frchains_together (bfd
*abfd ATTRIBUTE_UNUSED
,
400 void *xxx ATTRIBUTE_UNUSED
)
402 segment_info_type
*info
;
404 /* BFD may have introduced its own sections without using
405 subseg_new, so it is possible that seg_info is NULL. */
406 info
= seg_info (section
);
407 if (info
!= (segment_info_type
*) NULL
)
408 info
->frchainP
->frch_last
409 = chain_frchains_together_1 (section
, info
->frchainP
);
411 /* Now that we've chained the frags together, we must add new fixups
412 to the segment, not to the frag chain. */
417 cvt_frag_to_fill (segT sec ATTRIBUTE_UNUSED
, fragS
*fragP
)
419 switch (fragP
->fr_type
)
427 HANDLE_ALIGN (fragP
);
429 know (fragP
->fr_next
!= NULL
);
430 fragP
->fr_offset
= (fragP
->fr_next
->fr_address
432 - fragP
->fr_fix
) / fragP
->fr_var
;
433 if (fragP
->fr_offset
< 0)
435 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
436 _("attempt to .org/.space backwards? (%ld)"),
437 (long) fragP
->fr_offset
);
438 fragP
->fr_offset
= 0;
440 fragP
->fr_type
= rs_fill
;
448 valueT value
= S_GET_VALUE (fragP
->fr_symbol
);
451 size
= output_leb128 (fragP
->fr_literal
+ fragP
->fr_fix
, value
,
454 fragP
->fr_fix
+= size
;
455 fragP
->fr_type
= rs_fill
;
457 fragP
->fr_offset
= 0;
458 fragP
->fr_symbol
= NULL
;
463 eh_frame_convert_frag (fragP
);
467 dwarf2dbg_convert_frag (fragP
);
470 case rs_machine_dependent
:
471 md_convert_frag (stdoutput
, sec
, fragP
);
473 assert (fragP
->fr_next
== NULL
474 || ((offsetT
) (fragP
->fr_next
->fr_address
- fragP
->fr_address
)
477 /* After md_convert_frag, we make the frag into a ".space 0".
478 md_convert_frag() should set up any fixSs and constants
483 #ifndef WORKING_DOT_WORD
486 struct broken_word
*lie
;
488 if (fragP
->fr_subtype
)
490 fragP
->fr_fix
+= md_short_jump_size
;
491 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
492 lie
&& lie
->dispfrag
== fragP
;
493 lie
= lie
->next_broken_word
)
495 fragP
->fr_fix
+= md_long_jump_size
;
503 BAD_CASE (fragP
->fr_type
);
507 md_frag_check (fragP
);
511 struct relax_seg_info
518 relax_seg (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, void *xxx
)
520 segment_info_type
*seginfo
= seg_info (sec
);
521 struct relax_seg_info
*info
= (struct relax_seg_info
*) xxx
;
523 if (seginfo
&& seginfo
->frchainP
524 && relax_segment (seginfo
->frchainP
->frch_root
, sec
, info
->pass
))
529 size_seg (bfd
*abfd
, asection
*sec
, void *xxx ATTRIBUTE_UNUSED
)
533 segment_info_type
*seginfo
;
535 valueT size
, newsize
;
537 subseg_change (sec
, 0);
539 seginfo
= seg_info (sec
);
540 if (seginfo
&& seginfo
->frchainP
)
542 for (fragp
= seginfo
->frchainP
->frch_root
; fragp
; fragp
= fragp
->fr_next
)
543 cvt_frag_to_fill (sec
, fragp
);
544 for (fragp
= seginfo
->frchainP
->frch_root
;
546 fragp
= fragp
->fr_next
)
547 /* Walk to last elt. */
549 size
= fragp
->fr_address
+ fragp
->fr_fix
;
554 flags
= bfd_get_section_flags (abfd
, sec
);
556 if (size
> 0 && ! seginfo
->bss
)
557 flags
|= SEC_HAS_CONTENTS
;
560 x
= bfd_set_section_flags (abfd
, sec
, flags
);
563 newsize
= md_section_align (sec
, size
);
564 x
= bfd_set_section_size (abfd
, sec
, newsize
);
567 /* If the size had to be rounded up, add some padding in the last
569 assert (newsize
>= size
);
572 fragS
*last
= seginfo
->frchainP
->frch_last
;
573 fragp
= seginfo
->frchainP
->frch_root
;
574 while (fragp
->fr_next
!= last
)
575 fragp
= fragp
->fr_next
;
576 last
->fr_address
= size
;
577 if ((newsize
- size
) % fragp
->fr_var
== 0)
578 fragp
->fr_offset
+= (newsize
- size
) / fragp
->fr_var
;
580 /* If we hit this abort, it's likely due to subsegs_finish not
581 providing sufficient alignment on the last frag, and the
582 machine dependent code using alignment frags with fr_var
587 #ifdef tc_frob_section
588 tc_frob_section (sec
);
590 #ifdef obj_frob_section
591 obj_frob_section (sec
);
597 dump_section_relocs (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, FILE *stream
)
599 segment_info_type
*seginfo
= seg_info (sec
);
600 fixS
*fixp
= seginfo
->fix_root
;
605 fprintf (stream
, "sec %s relocs:\n", sec
->name
);
608 symbolS
*s
= fixp
->fx_addsy
;
610 fprintf (stream
, " %08lx: type %d ", (unsigned long) fixp
,
611 (int) fixp
->fx_r_type
);
613 fprintf (stream
, "no sym\n");
616 print_symbol_value_1 (stream
, s
);
617 fprintf (stream
, "\n");
619 fixp
= fixp
->fx_next
;
623 #define dump_section_relocs(ABFD,SEC,STREAM) ((void) 0)
626 #ifndef EMIT_SECTION_SYMBOLS
627 #define EMIT_SECTION_SYMBOLS 1
630 /* Resolve U.A.OFFSET_SYM and U.A.SYM fields of RELOC_LIST entries,
631 and check for validity. Convert RELOC_LIST from using U.A fields
634 resolve_reloc_expr_symbols (void)
636 struct reloc_list
*r
;
638 for (r
= reloc_list
; r
; r
= r
->next
)
642 bfd_vma offset
, addend
;
644 reloc_howto_type
*howto
;
646 resolve_symbol_value (r
->u
.a
.offset_sym
);
647 symval
= symbol_get_value_expression (r
->u
.a
.offset_sym
);
651 if (symval
->X_op
== O_constant
)
652 sym
= r
->u
.a
.offset_sym
;
653 else if (symval
->X_op
== O_symbol
)
655 sym
= symval
->X_add_symbol
;
656 offset
= symval
->X_add_number
;
657 symval
= symbol_get_value_expression (symval
->X_add_symbol
);
660 || symval
->X_op
!= O_constant
661 || (sec
= S_GET_SEGMENT (sym
)) == NULL
662 || !SEG_NORMAL (sec
))
664 as_bad_where (r
->file
, r
->line
, _("invalid offset expression"));
668 offset
+= S_GET_VALUE (sym
);
671 addend
= r
->u
.a
.addend
;
672 if (r
->u
.a
.sym
!= NULL
)
674 resolve_symbol_value (r
->u
.a
.sym
);
675 symval
= symbol_get_value_expression (r
->u
.a
.sym
);
676 if (symval
->X_op
== O_constant
)
678 else if (symval
->X_op
== O_symbol
)
680 sym
= symval
->X_add_symbol
;
681 addend
+= symval
->X_add_number
;
682 symval
= symbol_get_value_expression (symval
->X_add_symbol
);
684 if (symval
->X_op
!= O_constant
)
686 as_bad_where (r
->file
, r
->line
, _("invalid reloc expression"));
689 else if (sym
!= NULL
)
690 symbol_mark_used_in_reloc (sym
);
694 if (abs_section_sym
== NULL
)
695 abs_section_sym
= section_symbol (absolute_section
);
696 sym
= abs_section_sym
;
699 howto
= r
->u
.a
.howto
;
702 r
->u
.b
.s
= symbol_get_bfdsym (sym
);
703 r
->u
.b
.r
.sym_ptr_ptr
= &r
->u
.b
.s
;
704 r
->u
.b
.r
.address
= offset
;
705 r
->u
.b
.r
.addend
= addend
;
706 r
->u
.b
.r
.howto
= howto
;
710 /* This pass over fixups decides whether symbols can be replaced with
714 adjust_reloc_syms (bfd
*abfd ATTRIBUTE_UNUSED
,
716 void *xxx ATTRIBUTE_UNUSED
)
718 segment_info_type
*seginfo
= seg_info (sec
);
724 dump_section_relocs (abfd
, sec
, stderr
);
726 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
730 else if (fixp
->fx_addsy
)
736 fprintf (stderr
, "\n\nadjusting fixup:\n");
740 sym
= fixp
->fx_addsy
;
742 /* All symbols should have already been resolved at this
743 point. It is possible to see unresolved expression
744 symbols, though, since they are not in the regular symbol
746 resolve_symbol_value (sym
);
748 if (fixp
->fx_subsy
!= NULL
)
749 resolve_symbol_value (fixp
->fx_subsy
);
751 /* If this symbol is equated to an undefined or common symbol,
752 convert the fixup to being against that symbol. */
753 while (symbol_equated_reloc_p (sym
)
754 || S_IS_WEAKREFR (sym
))
756 symbolS
*newsym
= symbol_get_value_expression (sym
)->X_add_symbol
;
759 fixp
->fx_offset
+= symbol_get_value_expression (sym
)->X_add_number
;
760 fixp
->fx_addsy
= newsym
;
764 if (symbol_mri_common_p (sym
))
766 fixp
->fx_offset
+= S_GET_VALUE (sym
);
767 fixp
->fx_addsy
= symbol_get_value_expression (sym
)->X_add_symbol
;
771 /* If the symbol is undefined, common, weak, or global (ELF
772 shared libs), we can't replace it with the section symbol. */
773 if (S_FORCE_RELOC (fixp
->fx_addsy
, 1))
776 /* Is there some other (target cpu dependent) reason we can't adjust
777 this one? (E.g. relocations involving function addresses on
779 #ifdef tc_fix_adjustable
780 if (! tc_fix_adjustable (fixp
))
784 /* Since we're reducing to section symbols, don't attempt to reduce
785 anything that's already using one. */
786 if (symbol_section_p (sym
))
789 symsec
= S_GET_SEGMENT (sym
);
793 if (bfd_is_abs_section (symsec
))
795 /* The fixup_segment routine normally will not use this
796 symbol in a relocation. */
800 /* Don't try to reduce relocs which refer to non-local symbols
801 in .linkonce sections. It can lead to confusion when a
802 debugging section refers to a .linkonce section. I hope
803 this will always be correct. */
804 if (symsec
!= sec
&& ! S_IS_LOCAL (sym
))
806 if ((symsec
->flags
& SEC_LINK_ONCE
) != 0
808 /* The GNU toolchain uses an extension for ELF: a
809 section beginning with the magic string
810 .gnu.linkonce is a linkonce section. */
811 && strncmp (segment_name (symsec
), ".gnu.linkonce",
812 sizeof ".gnu.linkonce" - 1) == 0))
816 /* Never adjust a reloc against local symbol in a merge section
817 with non-zero addend. */
818 if ((symsec
->flags
& SEC_MERGE
) != 0
819 && (fixp
->fx_offset
!= 0 || fixp
->fx_subsy
!= NULL
))
822 /* Never adjust a reloc against TLS local symbol. */
823 if ((symsec
->flags
& SEC_THREAD_LOCAL
) != 0)
826 /* We refetch the segment when calling section_symbol, rather
827 than using symsec, because S_GET_VALUE may wind up changing
828 the section when it calls resolve_symbol_value. */
829 fixp
->fx_offset
+= S_GET_VALUE (sym
);
830 fixp
->fx_addsy
= section_symbol (S_GET_SEGMENT (sym
));
832 fprintf (stderr
, "\nadjusted fixup:\n");
837 dump_section_relocs (abfd
, sec
, stderr
);
842 Go through all the fixS's in a segment and see which ones can be
843 handled now. (These consist of fixS where we have since discovered
844 the value of a symbol, or the address of the frag involved.)
845 For each one, call md_apply_fix to put the fix into the frag data.
847 Result is a count of how many relocation structs will be needed to
848 handle the remaining fixS's that we couldn't completely handle here.
849 These will be output later by emit_relocations(). */
852 fixup_segment (fixS
*fixP
, segT this_segment
)
854 long seg_reloc_count
= 0;
857 segT add_symbol_segment
= absolute_section
;
859 if (fixP
!= NULL
&& abs_section_sym
== NULL
)
860 abs_section_sym
= section_symbol (absolute_section
);
862 /* If the linker is doing the relaxing, we must not do any fixups.
864 Well, strictly speaking that's not true -- we could do any that
865 are PC-relative and don't cross regions that could change size.
866 And for the i960 we might be able to turn callx/callj into bal
867 anyways in cases where we know the maximum displacement. */
868 if (linkrelax
&& TC_LINKRELAX_FIXUP (this_segment
))
870 for (; fixP
; fixP
= fixP
->fx_next
)
873 if (fixP
->fx_addsy
== NULL
)
875 /* There was no symbol required by this relocation.
876 However, BFD doesn't really handle relocations
877 without symbols well. So fake up a local symbol in
878 the absolute section. */
879 fixP
->fx_addsy
= abs_section_sym
;
881 symbol_mark_used_in_reloc (fixP
->fx_addsy
);
882 if (fixP
->fx_subsy
!= NULL
)
883 symbol_mark_used_in_reloc (fixP
->fx_subsy
);
886 TC_ADJUST_RELOC_COUNT (fixP
, seg_reloc_count
);
887 return seg_reloc_count
;
890 for (; fixP
; fixP
= fixP
->fx_next
)
893 fprintf (stderr
, "\nprocessing fixup:\n");
897 fragP
= fixP
->fx_frag
;
899 #ifdef TC_VALIDATE_FIX
900 TC_VALIDATE_FIX (fixP
, this_segment
, skip
);
902 add_number
= fixP
->fx_offset
;
904 if (fixP
->fx_addsy
!= NULL
)
905 add_symbol_segment
= S_GET_SEGMENT (fixP
->fx_addsy
);
907 if (fixP
->fx_subsy
!= NULL
)
909 segT sub_symbol_segment
;
910 resolve_symbol_value (fixP
->fx_subsy
);
911 sub_symbol_segment
= S_GET_SEGMENT (fixP
->fx_subsy
);
912 if (fixP
->fx_addsy
!= NULL
913 && sub_symbol_segment
== add_symbol_segment
914 && !TC_FORCE_RELOCATION_SUB_SAME (fixP
, add_symbol_segment
))
916 add_number
+= S_GET_VALUE (fixP
->fx_addsy
);
917 add_number
-= S_GET_VALUE (fixP
->fx_subsy
);
918 fixP
->fx_offset
= add_number
;
919 fixP
->fx_addsy
= NULL
;
920 fixP
->fx_subsy
= NULL
;
922 /* See the comment below about 68k weirdness. */
926 else if (sub_symbol_segment
== absolute_section
927 && !TC_FORCE_RELOCATION_SUB_ABS (fixP
))
929 add_number
-= S_GET_VALUE (fixP
->fx_subsy
);
930 fixP
->fx_offset
= add_number
;
931 fixP
->fx_subsy
= NULL
;
933 else if (sub_symbol_segment
== this_segment
934 && !TC_FORCE_RELOCATION_SUB_LOCAL (fixP
))
936 add_number
-= S_GET_VALUE (fixP
->fx_subsy
);
937 fixP
->fx_offset
= (add_number
+ fixP
->fx_dot_value
938 + fixP
->fx_frag
->fr_address
);
940 /* Make it pc-relative. If the back-end code has not
941 selected a pc-relative reloc, cancel the adjustment
942 we do later on all pc-relative relocs. */
945 /* Do this for m68k even if it's already described
946 as pc-relative. On the m68k, an operand of
947 "pc@(foo-.-2)" should address "foo" in a
952 add_number
+= MD_PCREL_FROM_SECTION (fixP
, this_segment
);
953 fixP
->fx_subsy
= NULL
;
956 else if (!TC_VALIDATE_FIX_SUB (fixP
))
958 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
959 _("can't resolve `%s' {%s section} - `%s' {%s section}"),
960 fixP
->fx_addsy
? S_GET_NAME (fixP
->fx_addsy
) : "0",
961 segment_name (add_symbol_segment
),
962 S_GET_NAME (fixP
->fx_subsy
),
963 segment_name (sub_symbol_segment
));
969 if (add_symbol_segment
== this_segment
970 && !TC_FORCE_RELOCATION_LOCAL (fixP
))
972 /* This fixup was made when the symbol's segment was
973 SEG_UNKNOWN, but it is now in the local segment.
974 So we know how to do the address without relocation. */
975 add_number
+= S_GET_VALUE (fixP
->fx_addsy
);
976 fixP
->fx_offset
= add_number
;
978 add_number
-= MD_PCREL_FROM_SECTION (fixP
, this_segment
);
979 fixP
->fx_addsy
= NULL
;
982 else if (add_symbol_segment
== absolute_section
983 && !TC_FORCE_RELOCATION_ABS (fixP
))
985 add_number
+= S_GET_VALUE (fixP
->fx_addsy
);
986 fixP
->fx_offset
= add_number
;
987 fixP
->fx_addsy
= NULL
;
989 else if (add_symbol_segment
!= undefined_section
990 && ! bfd_is_com_section (add_symbol_segment
)
991 && MD_APPLY_SYM_VALUE (fixP
))
992 add_number
+= S_GET_VALUE (fixP
->fx_addsy
);
997 add_number
-= MD_PCREL_FROM_SECTION (fixP
, this_segment
);
998 if (!fixP
->fx_done
&& fixP
->fx_addsy
== NULL
)
1000 /* There was no symbol required by this relocation.
1001 However, BFD doesn't really handle relocations
1002 without symbols well. So fake up a local symbol in
1003 the absolute section. */
1004 fixP
->fx_addsy
= abs_section_sym
;
1009 md_apply_fix (fixP
, &add_number
, this_segment
);
1014 if (fixP
->fx_addsy
== NULL
)
1015 fixP
->fx_addsy
= abs_section_sym
;
1016 symbol_mark_used_in_reloc (fixP
->fx_addsy
);
1017 if (fixP
->fx_subsy
!= NULL
)
1018 symbol_mark_used_in_reloc (fixP
->fx_subsy
);
1021 if (!fixP
->fx_bit_fixP
&& !fixP
->fx_no_overflow
&& fixP
->fx_size
!= 0)
1023 if (fixP
->fx_size
< sizeof (valueT
))
1028 mask
--; /* Set all bits to one. */
1029 mask
<<= fixP
->fx_size
* 8 - (fixP
->fx_signed
? 1 : 0);
1030 if ((add_number
& mask
) != 0 && (add_number
& mask
) != mask
)
1032 char buf
[50], buf2
[50];
1033 sprint_value (buf
, fragP
->fr_address
+ fixP
->fx_where
);
1034 if (add_number
> 1000)
1035 sprint_value (buf2
, add_number
);
1037 sprintf (buf2
, "%ld", (long) add_number
);
1038 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1039 _("value of %s too large for field of %d bytes at %s"),
1040 buf2
, fixP
->fx_size
, buf
);
1041 } /* Generic error checking. */
1043 #ifdef WARN_SIGNED_OVERFLOW_WORD
1044 /* Warn if a .word value is too large when treated as a signed
1045 number. We already know it is not too negative. This is to
1046 catch over-large switches generated by gcc on the 68k. */
1047 if (!flag_signed_overflow_ok
1048 && fixP
->fx_size
== 2
1049 && add_number
> 0x7fff)
1050 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1051 _("signed .word overflow; switch may be too large; %ld at 0x%lx"),
1053 (long) (fragP
->fr_address
+ fixP
->fx_where
));
1055 } /* Not a bit fix. */
1057 #ifdef TC_VALIDATE_FIX
1058 skip
: ATTRIBUTE_UNUSED_LABEL
1062 fprintf (stderr
, "result:\n");
1065 } /* For each fixS in this segment. */
1067 TC_ADJUST_RELOC_COUNT (fixP
, seg_reloc_count
);
1068 return seg_reloc_count
;
1072 fix_segment (bfd
*abfd ATTRIBUTE_UNUSED
,
1074 void *xxx ATTRIBUTE_UNUSED
)
1076 segment_info_type
*seginfo
= seg_info (sec
);
1078 fixup_segment (seginfo
->fix_root
, sec
);
1082 install_reloc (asection
*sec
, arelent
*reloc
, fragS
*fragp
,
1083 char *file
, unsigned int line
)
1086 bfd_reloc_status_type s
;
1088 s
= bfd_install_relocation (stdoutput
, reloc
,
1089 fragp
->fr_literal
, fragp
->fr_address
,
1095 case bfd_reloc_overflow
:
1096 as_bad_where (file
, line
, _("relocation overflow"));
1098 case bfd_reloc_outofrange
:
1099 as_bad_where (file
, line
, _("relocation out of range"));
1102 as_fatal (_("%s:%u: bad return from bfd_install_relocation: %x"),
1108 write_relocs (bfd
*abfd
, asection
*sec
, void *xxx ATTRIBUTE_UNUSED
)
1110 segment_info_type
*seginfo
= seg_info (sec
);
1113 struct reloc_list
*my_reloc_list
, **rp
, *r
;
1117 /* If seginfo is NULL, we did not create this section; don't do
1118 anything with it. */
1119 if (seginfo
== NULL
)
1123 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
1127 #ifdef RELOC_EXPANSION_POSSIBLE
1128 n
*= MAX_RELOC_EXPANSION
;
1131 /* Extract relocs for this section from reloc_list. */
1133 my_reloc_list
= NULL
;
1134 while ((r
= *rp
) != NULL
)
1136 if (r
->u
.b
.sec
== sec
)
1139 r
->next
= my_reloc_list
;
1147 relocs
= xcalloc (n
, sizeof (arelent
*));
1150 for (fixp
= seginfo
->fix_root
; fixp
!= (fixS
*) NULL
; fixp
= fixp
->fx_next
)
1159 fx_size
= fixp
->fx_size
;
1160 slack
= TC_FX_SIZE_SLACK (fixp
);
1162 fx_size
= fx_size
> slack
? fx_size
- slack
: 0;
1163 loc
= fixp
->fx_where
+ fx_size
;
1164 if (slack
>= 0 && loc
> fixp
->fx_frag
->fr_fix
)
1165 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1166 _("internal error: fixup not contained within frag"));
1168 #ifndef RELOC_EXPANSION_POSSIBLE
1170 arelent
*reloc
= tc_gen_reloc (sec
, fixp
);
1174 relocs
[i
++] = reloc
;
1179 arelent
**reloc
= tc_gen_reloc (sec
, fixp
);
1181 for (j
= 0; reloc
[j
]; j
++)
1182 relocs
[i
++] = reloc
[j
];
1186 for ( ; j
!= 0; --j
)
1187 install_reloc (sec
, relocs
[i
- j
], fixp
->fx_frag
,
1188 fixp
->fx_file
, fixp
->fx_line
);
1194 unsigned int i
, j
, nsyms
;
1196 sympp
= bfd_get_outsymbols (stdoutput
);
1197 nsyms
= bfd_get_symcount (stdoutput
);
1198 for (i
= 0; i
< n
; i
++)
1199 if (((*relocs
[i
]->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
) == 0)
1201 for (j
= 0; j
< nsyms
; j
++)
1202 if (sympp
[j
] == *relocs
[i
]->sym_ptr_ptr
)
1210 for (r
= my_reloc_list
; r
!= NULL
; r
= r
->next
)
1213 for (f
= seginfo
->frchainP
->frch_root
; f
; f
= f
->fr_next
)
1214 if (f
->fr_address
<= r
->u
.b
.r
.address
1215 && r
->u
.b
.r
.address
< f
->fr_address
+ f
->fr_fix
)
1218 as_bad_where (r
->file
, r
->line
,
1219 _("reloc not within (fixed part of) section"));
1222 relocs
[n
++] = &r
->u
.b
.r
;
1223 install_reloc (sec
, &r
->u
.b
.r
, f
, r
->file
, r
->line
);
1229 flagword flags
= bfd_get_section_flags (abfd
, sec
);
1231 bfd_set_section_flags (abfd
, sec
, flags
);
1232 bfd_set_reloc (stdoutput
, sec
, relocs
, n
);
1235 #ifdef SET_SECTION_RELOCS
1236 SET_SECTION_RELOCS (sec
, relocs
, n
);
1244 fprintf (stderr
, "relocs for sec %s\n", sec
->name
);
1245 for (i
= 0; i
< n
; i
++)
1248 s
= *r
->sym_ptr_ptr
;
1249 fprintf (stderr
, " reloc %2d @%p off %4lx : sym %-10s addend %lx\n",
1250 i
, r
, (unsigned long)r
->address
, s
->name
, (unsigned long)r
->addend
);
1257 write_contents (bfd
*abfd ATTRIBUTE_UNUSED
,
1259 void *xxx ATTRIBUTE_UNUSED
)
1261 segment_info_type
*seginfo
= seg_info (sec
);
1262 addressT offset
= 0;
1265 /* Write out the frags. */
1267 || !(bfd_get_section_flags (abfd
, sec
) & SEC_HAS_CONTENTS
))
1270 for (f
= seginfo
->frchainP
->frch_root
;
1279 assert (f
->fr_type
== rs_fill
);
1282 x
= bfd_set_section_contents (stdoutput
, sec
,
1283 f
->fr_literal
, (file_ptr
) offset
,
1284 (bfd_size_type
) f
->fr_fix
);
1286 as_fatal (_("can't write %s: %s"), stdoutput
->filename
,
1287 bfd_errmsg (bfd_get_error ()));
1288 offset
+= f
->fr_fix
;
1290 fill_literal
= f
->fr_literal
+ f
->fr_fix
;
1291 fill_size
= f
->fr_var
;
1292 count
= f
->fr_offset
;
1293 assert (count
>= 0);
1294 if (fill_size
&& count
)
1297 if (fill_size
> sizeof (buf
))
1299 /* Do it the old way. Can this ever happen? */
1302 x
= bfd_set_section_contents (stdoutput
, sec
,
1305 (bfd_size_type
) fill_size
);
1307 as_fatal (_("can't write %s: %s"), stdoutput
->filename
,
1308 bfd_errmsg (bfd_get_error ()));
1309 offset
+= fill_size
;
1314 /* Build a buffer full of fill objects and output it as
1315 often as necessary. This saves on the overhead of
1316 potentially lots of bfd_set_section_contents calls. */
1320 n_per_buf
= sizeof (buf
);
1321 memset (buf
, *fill_literal
, n_per_buf
);
1326 n_per_buf
= sizeof (buf
) / fill_size
;
1327 for (i
= n_per_buf
, bufp
= buf
; i
; i
--, bufp
+= fill_size
)
1328 memcpy (bufp
, fill_literal
, fill_size
);
1330 for (; count
> 0; count
-= n_per_buf
)
1332 n_per_buf
= n_per_buf
> count
? count
: n_per_buf
;
1333 x
= bfd_set_section_contents
1334 (stdoutput
, sec
, buf
, (file_ptr
) offset
,
1335 (bfd_size_type
) n_per_buf
* fill_size
);
1337 as_fatal (_("cannot write to output file"));
1338 offset
+= n_per_buf
* fill_size
;
1346 merge_data_into_text (void)
1348 seg_info (text_section
)->frchainP
->frch_last
->fr_next
=
1349 seg_info (data_section
)->frchainP
->frch_root
;
1350 seg_info (text_section
)->frchainP
->frch_last
=
1351 seg_info (data_section
)->frchainP
->frch_last
;
1352 seg_info (data_section
)->frchainP
= 0;
1363 /* Count symbols. We can't rely on a count made by the loop in
1364 write_object_file, because *_frob_file may add a new symbol or
1367 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
1373 bfd_size_type amt
= (bfd_size_type
) nsyms
* sizeof (asymbol
*);
1375 asympp
= bfd_alloc (stdoutput
, amt
);
1376 symp
= symbol_rootP
;
1377 for (i
= 0; i
< nsyms
; i
++, symp
= symbol_next (symp
))
1379 asympp
[i
] = symbol_get_bfdsym (symp
);
1380 symbol_mark_written (symp
);
1385 result
= bfd_set_symtab (stdoutput
, asympp
, nsyms
);
1387 symbol_table_frozen
= 1;
1390 /* Finish the subsegments. After every sub-segment, we fake an
1391 ".align ...". This conforms to BSD4.2 brane-damage. We then fake
1392 ".fill 0" because that is the kind of frag that requires least
1393 thought. ".align" frags like to have a following frag since that
1394 makes calculating their intended length trivial. */
1396 #ifndef SUB_SEGMENT_ALIGN
1398 /* The last subsegment gets an alignment corresponding to the alignment
1399 of the section. This allows proper nop-filling at the end of
1400 code-bearing sections. */
1401 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \
1402 (!(FRCHAIN)->frch_next ? get_recorded_alignment (SEG) : 0)
1404 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
1409 subsegs_finish (void)
1411 struct frchain
*frchainP
;
1414 for (s
= stdoutput
->sections
; s
; s
= s
->next
)
1416 segment_info_type
*seginfo
= seg_info (s
);
1420 for (frchainP
= seginfo
->frchainP
;
1422 frchainP
= frchainP
->frch_next
)
1426 subseg_set (s
, frchainP
->frch_subseg
);
1428 /* This now gets called even if we had errors. In that case,
1429 any alignment is meaningless, and, moreover, will look weird
1430 if we are generating a listing. */
1433 alignment
= SUB_SEGMENT_ALIGN (now_seg
, frchainP
);
1434 if ((bfd_get_section_flags (now_seg
->owner
, now_seg
) & SEC_MERGE
)
1435 && now_seg
->entsize
)
1437 unsigned int entsize
= now_seg
->entsize
;
1440 while ((entsize
& 1) == 0)
1445 if (entalign
> alignment
)
1446 alignment
= entalign
;
1450 if (subseg_text_p (now_seg
))
1451 frag_align_code (alignment
, 0);
1453 frag_align (alignment
, 0, 0);
1455 /* frag_align will have left a new frag.
1456 Use this last frag for an empty ".fill".
1458 For this segment ...
1459 Create a last frag. Do not leave a "being filled in frag". */
1460 frag_wane (frag_now
);
1461 frag_now
->fr_fix
= 0;
1462 know (frag_now
->fr_next
== NULL
);
1467 /* Write the object file. */
1470 write_object_file (void)
1472 struct relax_seg_info rsi
;
1473 #ifndef WORKING_DOT_WORD
1474 fragS
*fragP
; /* Track along all frags. */
1477 /* Do we really want to write it? */
1479 int n_warns
, n_errs
;
1480 n_warns
= had_warnings ();
1481 n_errs
= had_errors ();
1482 /* The -Z flag indicates that an object file should be generated,
1483 regardless of warnings and errors. */
1484 if (flag_always_generate_output
)
1486 if (n_warns
|| n_errs
)
1487 as_warn (_("%d error%s, %d warning%s, generating bad object file"),
1488 n_errs
, n_errs
== 1 ? "" : "s",
1489 n_warns
, n_warns
== 1 ? "" : "s");
1494 as_fatal (_("%d error%s, %d warning%s, no object file generated"),
1495 n_errs
, n_errs
== 1 ? "" : "s",
1496 n_warns
, n_warns
== 1 ? "" : "s");
1501 /* Under VMS we try to be compatible with VAX-11 "C". Thus, we call
1502 a routine to check for the definition of the procedure "_main",
1503 and if so -- fix it up so that it can be program entry point. */
1504 vms_check_for_main ();
1505 #endif /* OBJ_VMS */
1507 /* From now on, we don't care about sub-segments. Build one frag chain
1508 for each segment. Linked thru fr_next. */
1510 /* Remove the sections created by gas for its own purposes. */
1514 bfd_section_list_remove (stdoutput
, reg_section
);
1515 bfd_section_list_remove (stdoutput
, expr_section
);
1516 stdoutput
->section_count
-= 2;
1518 bfd_map_over_sections (stdoutput
, renumber_sections
, &i
);
1521 bfd_map_over_sections (stdoutput
, chain_frchains_together
, (char *) 0);
1523 /* We have two segments. If user gave -R flag, then we must put the
1524 data frags into the text segment. Do this before relaxing so
1525 we know to take advantage of -R and make shorter addresses. */
1526 if (flag_readonly_data_in_text
)
1528 merge_data_into_text ();
1534 #ifndef WORKING_DOT_WORD
1535 /* We need to reset the markers in the broken word list and
1536 associated frags between calls to relax_segment (via
1537 relax_seg). Since the broken word list is global, we do it
1538 once per round, rather than locally in relax_segment for each
1540 struct broken_word
*brokp
;
1542 for (brokp
= broken_words
;
1543 brokp
!= (struct broken_word
*) NULL
;
1544 brokp
= brokp
->next_broken_word
)
1548 if (brokp
->dispfrag
!= (fragS
*) NULL
1549 && brokp
->dispfrag
->fr_type
== rs_broken_word
)
1550 brokp
->dispfrag
->fr_subtype
= 0;
1555 bfd_map_over_sections (stdoutput
, relax_seg
, &rsi
);
1561 /* Note - Most ports will use the default value of
1562 TC_FINALIZE_SYMS_BEFORE_SIZE_SEG, which 1. This will force
1563 local symbols to be resolved, removing their frag information.
1564 Some ports however, will not have finished relaxing all of
1565 their frags and will still need the local symbol frag
1566 information. These ports can set
1567 TC_FINALIZE_SYMS_BEFORE_SIZE_SEG to 0. */
1568 finalize_syms
= TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
;
1570 bfd_map_over_sections (stdoutput
, size_seg
, (char *) 0);
1572 /* Relaxation has completed. Freeze all syms. */
1575 #ifdef md_post_relax_hook
1579 #ifndef WORKING_DOT_WORD
1581 struct broken_word
*lie
;
1582 struct broken_word
**prevP
;
1584 prevP
= &broken_words
;
1585 for (lie
= broken_words
; lie
; lie
= lie
->next_broken_word
)
1590 subseg_change (lie
->seg
, lie
->subseg
);
1591 exp
.X_op
= O_subtract
;
1592 exp
.X_add_symbol
= lie
->add
;
1593 exp
.X_op_symbol
= lie
->sub
;
1594 exp
.X_add_number
= lie
->addnum
;
1595 #ifdef TC_CONS_FIX_NEW
1596 TC_CONS_FIX_NEW (lie
->frag
,
1597 lie
->word_goes_here
- lie
->frag
->fr_literal
,
1600 fix_new_exp (lie
->frag
,
1601 lie
->word_goes_here
- lie
->frag
->fr_literal
,
1602 2, &exp
, 0, BFD_RELOC_16
);
1604 *prevP
= lie
->next_broken_word
;
1607 prevP
= &(lie
->next_broken_word
);
1609 for (lie
= broken_words
; lie
;)
1611 struct broken_word
*untruth
;
1613 addressT table_addr
;
1614 addressT from_addr
, to_addr
;
1617 subseg_change (lie
->seg
, lie
->subseg
);
1618 fragP
= lie
->dispfrag
;
1620 /* Find out how many broken_words go here. */
1623 untruth
&& untruth
->dispfrag
== fragP
;
1624 untruth
= untruth
->next_broken_word
)
1625 if (untruth
->added
== 1)
1628 table_ptr
= lie
->dispfrag
->fr_opcode
;
1629 table_addr
= (lie
->dispfrag
->fr_address
1630 + (table_ptr
- lie
->dispfrag
->fr_literal
));
1631 /* Create the jump around the long jumps. This is a short
1632 jump from table_ptr+0 to table_ptr+n*long_jump_size. */
1633 from_addr
= table_addr
;
1634 to_addr
= table_addr
+ md_short_jump_size
+ n
* md_long_jump_size
;
1635 md_create_short_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
,
1637 table_ptr
+= md_short_jump_size
;
1638 table_addr
+= md_short_jump_size
;
1641 lie
&& lie
->dispfrag
== fragP
;
1642 m
++, lie
= lie
->next_broken_word
)
1644 if (lie
->added
== 2)
1646 /* Patch the jump table. */
1647 /* This is the offset from ??? to table_ptr+0. */
1648 to_addr
= table_addr
- S_GET_VALUE (lie
->sub
);
1649 #ifdef TC_CHECK_ADJUSTED_BROKEN_DOT_WORD
1650 TC_CHECK_ADJUSTED_BROKEN_DOT_WORD (to_addr
, lie
);
1652 md_number_to_chars (lie
->word_goes_here
, to_addr
, 2);
1653 for (untruth
= lie
->next_broken_word
;
1654 untruth
&& untruth
->dispfrag
== fragP
;
1655 untruth
= untruth
->next_broken_word
)
1657 if (untruth
->use_jump
== lie
)
1658 md_number_to_chars (untruth
->word_goes_here
, to_addr
, 2);
1661 /* Install the long jump. */
1662 /* This is a long jump from table_ptr+0 to the final target. */
1663 from_addr
= table_addr
;
1664 to_addr
= S_GET_VALUE (lie
->add
) + lie
->addnum
;
1665 md_create_long_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
,
1667 table_ptr
+= md_long_jump_size
;
1668 table_addr
+= md_long_jump_size
;
1672 #endif /* not WORKING_DOT_WORD */
1674 /* Resolve symbol values. This needs to be done before processing
1680 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
1681 resolve_symbol_value (symp
);
1683 resolve_local_symbol_values ();
1684 resolve_reloc_expr_symbols ();
1688 #ifdef tc_frob_file_before_adjust
1689 tc_frob_file_before_adjust ();
1691 #ifdef obj_frob_file_before_adjust
1692 obj_frob_file_before_adjust ();
1695 bfd_map_over_sections (stdoutput
, adjust_reloc_syms
, (char *) 0);
1697 #ifdef tc_frob_file_before_fix
1698 tc_frob_file_before_fix ();
1700 #ifdef obj_frob_file_before_fix
1701 obj_frob_file_before_fix ();
1704 bfd_map_over_sections (stdoutput
, fix_segment
, (char *) 0);
1706 /* Set up symbol table, and write it out. */
1710 bfd_boolean skip_next_symbol
= FALSE
;
1712 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
1717 if (skip_next_symbol
)
1719 /* Don't do anything besides moving the value of the
1720 symbol from the GAS value-field to the BFD value-field. */
1721 symbol_get_bfdsym (symp
)->value
= S_GET_VALUE (symp
);
1722 skip_next_symbol
= FALSE
;
1726 if (symbol_mri_common_p (symp
))
1728 if (S_IS_EXTERNAL (symp
))
1729 as_bad (_("%s: global symbols not supported in common sections"),
1731 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
1735 name
= S_GET_NAME (symp
);
1739 decode_local_label_name ((char *) S_GET_NAME (symp
));
1740 /* They only differ if `name' is a fb or dollar local
1742 if (name2
!= name
&& ! S_IS_DEFINED (symp
))
1743 as_bad (_("local label `%s' is not defined"), name2
);
1746 /* Do it again, because adjust_reloc_syms might introduce
1747 more symbols. They'll probably only be section symbols,
1748 but they'll still need to have the values computed. */
1749 resolve_symbol_value (symp
);
1751 /* Skip symbols which were equated to undefined or common
1753 if (symbol_equated_reloc_p (symp
)
1754 || S_IS_WEAKREFR (symp
))
1756 const char *name
= S_GET_NAME (symp
);
1757 if (S_IS_COMMON (symp
)
1758 && !TC_FAKE_LABEL (name
)
1759 && !S_IS_WEAKREFR (symp
)
1760 && (!S_IS_EXTERNAL (symp
) || S_IS_LOCAL (symp
)))
1762 expressionS
*e
= symbol_get_value_expression (symp
);
1763 as_bad (_("Local symbol `%s' can't be equated to common symbol `%s'"),
1764 name
, S_GET_NAME (e
->X_add_symbol
));
1766 if (S_GET_SEGMENT (symp
) == reg_section
)
1768 /* Report error only if we know the symbol name. */
1769 if (S_GET_NAME (symp
) != reg_section
->name
)
1770 as_bad (_("can't make global register symbol `%s'"),
1773 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
1777 #ifdef obj_frob_symbol
1778 obj_frob_symbol (symp
, punt
);
1780 #ifdef tc_frob_symbol
1781 if (! punt
|| symbol_used_in_reloc_p (symp
))
1782 tc_frob_symbol (symp
, punt
);
1785 /* If we don't want to keep this symbol, splice it out of
1786 the chain now. If EMIT_SECTION_SYMBOLS is 0, we never
1787 want section symbols. Otherwise, we skip local symbols
1788 and symbols that the frob_symbol macros told us to punt,
1789 but we keep such symbols if they are used in relocs. */
1790 if (symp
== abs_section_sym
1791 || (! EMIT_SECTION_SYMBOLS
1792 && symbol_section_p (symp
))
1793 /* Note that S_IS_EXTERNAL and S_IS_LOCAL are not always
1794 opposites. Sometimes the former checks flags and the
1795 latter examines the name... */
1796 || (!S_IS_EXTERNAL (symp
)
1797 && (punt
|| S_IS_LOCAL (symp
) ||
1798 (S_IS_WEAKREFD (symp
) && ! symbol_used_p (symp
)))
1799 && ! symbol_used_in_reloc_p (symp
)))
1801 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
1803 /* After symbol_remove, symbol_next(symp) still returns
1804 the one that came after it in the chain. So we don't
1805 need to do any extra cleanup work here. */
1809 /* Make sure we really got a value for the symbol. */
1810 if (! symbol_resolved_p (symp
))
1812 as_bad (_("can't resolve value for symbol `%s'"),
1814 symbol_mark_resolved (symp
);
1817 /* Set the value into the BFD symbol. Up til now the value
1818 has only been kept in the gas symbolS struct. */
1819 symbol_get_bfdsym (symp
)->value
= S_GET_VALUE (symp
);
1821 /* A warning construct is a warning symbol followed by the
1822 symbol warned about. Don't let anything object-format or
1823 target-specific muck with it; it's ready for output. */
1824 if (symbol_get_bfdsym (symp
)->flags
& BSF_WARNING
)
1825 skip_next_symbol
= TRUE
;
1831 /* Now do any format-specific adjustments to the symbol table, such
1832 as adding file symbols. */
1833 #ifdef tc_adjust_symtab
1834 tc_adjust_symtab ();
1836 #ifdef obj_adjust_symtab
1837 obj_adjust_symtab ();
1840 /* Stop if there is an error. */
1844 /* Now that all the sizes are known, and contents correct, we can
1845 start writing to the file. */
1848 /* If *_frob_file changes the symbol value at this point, it is
1849 responsible for moving the changed value into symp->bsym->value
1850 as well. Hopefully all symbol value changing can be done in
1855 #ifdef obj_frob_file
1859 bfd_map_over_sections (stdoutput
, write_relocs
, (char *) 0);
1861 #ifdef tc_frob_file_after_relocs
1862 tc_frob_file_after_relocs ();
1864 #ifdef obj_frob_file_after_relocs
1865 obj_frob_file_after_relocs ();
1868 bfd_map_over_sections (stdoutput
, write_contents
, (char *) 0);
1871 #ifdef TC_GENERIC_RELAX_TABLE
1872 /* Relax a fragment by scanning TC_GENERIC_RELAX_TABLE. */
1875 relax_frag (segT segment
, fragS
*fragP
, long stretch
)
1877 const relax_typeS
*this_type
;
1878 const relax_typeS
*start_type
;
1879 relax_substateT next_state
;
1880 relax_substateT this_state
;
1886 const relax_typeS
*table
;
1888 target
= fragP
->fr_offset
;
1889 address
= fragP
->fr_address
;
1890 table
= TC_GENERIC_RELAX_TABLE
;
1891 this_state
= fragP
->fr_subtype
;
1892 start_type
= this_type
= table
+ this_state
;
1893 symbolP
= fragP
->fr_symbol
;
1899 sym_frag
= symbol_get_frag (symbolP
);
1901 #ifndef DIFF_EXPR_OK
1902 know (sym_frag
!= NULL
);
1904 know (S_GET_SEGMENT (symbolP
) != absolute_section
1905 || sym_frag
== &zero_address_frag
);
1906 target
+= S_GET_VALUE (symbolP
);
1908 /* If frag has yet to be reached on this pass,
1909 assume it will move by STRETCH just as we did.
1910 If this is not so, it will be because some frag
1911 between grows, and that will force another pass. */
1914 && sym_frag
->relax_marker
!= fragP
->relax_marker
1915 && S_GET_SEGMENT (symbolP
) == segment
)
1921 aim
= target
- address
- fragP
->fr_fix
;
1922 #ifdef TC_PCREL_ADJUST
1923 /* Currently only the ns32k family needs this. */
1924 aim
+= TC_PCREL_ADJUST (fragP
);
1927 #ifdef md_prepare_relax_scan
1928 /* Formerly called M68K_AIM_KLUDGE. */
1929 md_prepare_relax_scan (fragP
, address
, aim
, this_state
, this_type
);
1934 /* Look backwards. */
1935 for (next_state
= this_type
->rlx_more
; next_state
;)
1936 if (aim
>= this_type
->rlx_backward
)
1940 /* Grow to next state. */
1941 this_state
= next_state
;
1942 this_type
= table
+ this_state
;
1943 next_state
= this_type
->rlx_more
;
1948 /* Look forwards. */
1949 for (next_state
= this_type
->rlx_more
; next_state
;)
1950 if (aim
<= this_type
->rlx_forward
)
1954 /* Grow to next state. */
1955 this_state
= next_state
;
1956 this_type
= table
+ this_state
;
1957 next_state
= this_type
->rlx_more
;
1961 growth
= this_type
->rlx_length
- start_type
->rlx_length
;
1963 fragP
->fr_subtype
= this_state
;
1967 #endif /* defined (TC_GENERIC_RELAX_TABLE) */
1969 /* Relax_align. Advance location counter to next address that has 'alignment'
1970 lowest order bits all 0s, return size of adjustment made. */
1971 static relax_addressT
1972 relax_align (register relax_addressT address
, /* Address now. */
1973 register int alignment
/* Alignment (binary). */)
1975 relax_addressT mask
;
1976 relax_addressT new_address
;
1978 mask
= ~((~0) << alignment
);
1979 new_address
= (address
+ mask
) & (~mask
);
1980 #ifdef LINKER_RELAXING_SHRINKS_ONLY
1982 /* We must provide lots of padding, so the linker can discard it
1983 when needed. The linker will not add extra space, ever. */
1984 new_address
+= (1 << alignment
);
1986 return (new_address
- address
);
1989 /* Now we have a segment, not a crowd of sub-segments, we can make
1994 After this, all frags in this segment have addresses that are correct
1995 within the segment. Since segments live in different file addresses,
1996 these frag addresses may not be the same as final object-file
2000 relax_segment (struct frag
*segment_frag_root
, segT segment
, int pass
)
2002 unsigned long frag_count
;
2004 relax_addressT address
;
2007 /* In case md_estimate_size_before_relax() wants to make fixSs. */
2008 subseg_change (segment
, 0);
2010 /* For each frag in segment: count and store (a 1st guess of)
2013 for (frag_count
= 0, fragP
= segment_frag_root
;
2015 fragP
= fragP
->fr_next
, frag_count
++)
2017 fragP
->relax_marker
= 0;
2018 fragP
->fr_address
= address
;
2019 address
+= fragP
->fr_fix
;
2021 switch (fragP
->fr_type
)
2024 address
+= fragP
->fr_offset
* fragP
->fr_var
;
2031 addressT offset
= relax_align (address
, (int) fragP
->fr_offset
);
2033 if (fragP
->fr_subtype
!= 0 && offset
> fragP
->fr_subtype
)
2036 if (offset
% fragP
->fr_var
!= 0)
2038 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
2039 _("alignment padding (%lu bytes) not a multiple of %ld"),
2040 (unsigned long) offset
, (long) fragP
->fr_var
);
2041 offset
-= (offset
% fragP
->fr_var
);
2050 /* Assume .org is nugatory. It will grow with 1st relax. */
2053 case rs_machine_dependent
:
2054 /* If fr_symbol is an expression, this call to
2055 resolve_symbol_value sets up the correct segment, which will
2056 likely be needed in md_estimate_size_before_relax. */
2057 if (fragP
->fr_symbol
)
2058 resolve_symbol_value (fragP
->fr_symbol
);
2060 address
+= md_estimate_size_before_relax (fragP
, segment
);
2063 #ifndef WORKING_DOT_WORD
2064 /* Broken words don't concern us yet. */
2065 case rs_broken_word
:
2070 /* Initial guess is always 1; doing otherwise can result in
2071 stable solutions that are larger than the minimum. */
2072 address
+= fragP
->fr_offset
= 1;
2076 address
+= eh_frame_estimate_size_before_relax (fragP
);
2080 address
+= dwarf2dbg_estimate_size_before_relax (fragP
);
2084 BAD_CASE (fragP
->fr_type
);
2091 unsigned long max_iterations
;
2093 /* Cumulative address adjustment. */
2096 /* Have we made any adjustment this pass? We can't just test
2097 stretch because one piece of code may have grown and another
2101 /* Most horrible, but gcc may give us some exception data that
2102 is impossible to assemble, of the form
2106 .uleb128 end - start
2112 If the leb128 is two bytes in size, then end-start is 128*128,
2113 which requires a three byte leb128. If the leb128 is three
2114 bytes in size, then end-start is 128*128-1, which requires a
2115 two byte leb128. We work around this dilemma by inserting
2116 an extra 4 bytes of alignment just after the .align. This
2117 works because the data after the align is accessed relative to
2120 This counter is used in a tiny state machine to detect
2121 whether a leb128 followed by an align is impossible to
2123 int rs_leb128_fudge
= 0;
2125 /* We want to prevent going into an infinite loop where one frag grows
2126 depending upon the location of a symbol which is in turn moved by
2127 the growing frag. eg:
2133 So we dictate that this algorithm can be at most O2. */
2134 max_iterations
= frag_count
* frag_count
;
2135 /* Check for overflow. */
2136 if (max_iterations
< frag_count
)
2137 max_iterations
= frag_count
;
2145 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
2148 addressT was_address
;
2152 fragP
->relax_marker
^= 1;
2153 was_address
= fragP
->fr_address
;
2154 address
= fragP
->fr_address
+= stretch
;
2155 symbolP
= fragP
->fr_symbol
;
2156 offset
= fragP
->fr_offset
;
2158 switch (fragP
->fr_type
)
2160 case rs_fill
: /* .fill never relaxes. */
2164 #ifndef WORKING_DOT_WORD
2165 /* JF: This is RMS's idea. I do *NOT* want to be blamed
2166 for it I do not want to write it. I do not want to have
2167 anything to do with it. This is not the proper way to
2168 implement this misfeature. */
2169 case rs_broken_word
:
2171 struct broken_word
*lie
;
2172 struct broken_word
*untruth
;
2174 /* Yes this is ugly (storing the broken_word pointer
2175 in the symbol slot). Still, this whole chunk of
2176 code is ugly, and I don't feel like doing anything
2177 about it. Think of it as stubbornness in action. */
2179 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
2180 lie
&& lie
->dispfrag
== fragP
;
2181 lie
= lie
->next_broken_word
)
2187 offset
= (S_GET_VALUE (lie
->add
)
2189 - S_GET_VALUE (lie
->sub
));
2190 if (offset
<= -32768 || offset
>= 32767)
2192 if (flag_warn_displacement
)
2195 sprint_value (buf
, (addressT
) lie
->addnum
);
2196 as_warn_where (fragP
->fr_file
, fragP
->fr_line
,
2197 _(".word %s-%s+%s didn't fit"),
2198 S_GET_NAME (lie
->add
),
2199 S_GET_NAME (lie
->sub
),
2203 if (fragP
->fr_subtype
== 0)
2205 fragP
->fr_subtype
++;
2206 growth
+= md_short_jump_size
;
2208 for (untruth
= lie
->next_broken_word
;
2209 untruth
&& untruth
->dispfrag
== lie
->dispfrag
;
2210 untruth
= untruth
->next_broken_word
)
2211 if ((symbol_get_frag (untruth
->add
)
2212 == symbol_get_frag (lie
->add
))
2213 && (S_GET_VALUE (untruth
->add
)
2214 == S_GET_VALUE (lie
->add
)))
2217 untruth
->use_jump
= lie
;
2219 growth
+= md_long_jump_size
;
2224 } /* case rs_broken_word */
2230 addressT oldoff
, newoff
;
2232 oldoff
= relax_align (was_address
+ fragP
->fr_fix
,
2234 newoff
= relax_align (address
+ fragP
->fr_fix
,
2237 if (fragP
->fr_subtype
!= 0)
2239 if (oldoff
> fragP
->fr_subtype
)
2241 if (newoff
> fragP
->fr_subtype
)
2245 growth
= newoff
- oldoff
;
2247 /* If this align happens to follow a leb128 and
2248 we have determined that the leb128 is bouncing
2249 in size, then break the cycle by inserting an
2252 && (rs_leb128_fudge
& 16) != 0
2253 && (rs_leb128_fudge
& 15) >= 2)
2255 segment_info_type
*seginfo
= seg_info (segment
);
2256 struct obstack
*ob
= &seginfo
->frchainP
->frch_obstack
;
2259 newf
= frag_alloc (ob
);
2260 obstack_blank_fast (ob
, fragP
->fr_var
);
2261 obstack_finish (ob
);
2262 memcpy (newf
, fragP
, SIZEOF_STRUCT_FRAG
);
2263 memcpy (newf
->fr_literal
,
2264 fragP
->fr_literal
+ fragP
->fr_fix
,
2266 newf
->fr_type
= rs_fill
;
2268 newf
->fr_offset
= (((offsetT
) 1 << fragP
->fr_offset
)
2270 if (newf
->fr_offset
* newf
->fr_var
2271 != (offsetT
) 1 << fragP
->fr_offset
)
2273 newf
->fr_offset
= (offsetT
) 1 << fragP
->fr_offset
;
2276 /* Include growth of new frag, because rs_fill
2277 frags don't normally grow. */
2278 growth
+= newf
->fr_offset
* newf
->fr_var
;
2279 /* The new frag address is newoff. Adjust this
2280 for the amount we'll add when we process the
2282 newf
->fr_address
= newoff
- stretch
- growth
;
2283 newf
->relax_marker
^= 1;
2284 fragP
->fr_next
= newf
;
2286 as_warn (_("padding added"));
2294 addressT target
= offset
;
2299 /* Convert from an actual address to an octet offset
2300 into the section. Here it is assumed that the
2301 section's VMA is zero, and can omit subtracting it
2302 from the symbol's value to get the address offset. */
2303 know (S_GET_SEGMENT (symbolP
)->vma
== 0);
2304 target
+= S_GET_VALUE (symbolP
) * OCTETS_PER_BYTE
;
2307 know (fragP
->fr_next
);
2308 after
= fragP
->fr_next
->fr_address
+ stretch
;
2309 growth
= target
- after
;
2314 /* Don't error on first few frag relax passes.
2315 The symbol might be an expression involving
2316 symbol values from other sections. If those
2317 sections have not yet been processed their
2318 frags will all have zero addresses, so we
2319 will calculate incorrect values for them. The
2320 number of passes we allow before giving an
2321 error is somewhat arbitrary. It should be at
2322 least one, with larger values requiring
2323 increasingly contrived dependencies between
2324 frags to trigger a false error. */
2327 /* Force another pass. */
2332 /* Growth may be negative, but variable part of frag
2333 cannot have fewer than 0 chars. That is, we can't
2335 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
2336 _("attempt to move .org backwards"));
2338 /* We've issued an error message. Change the
2339 frag to avoid cascading errors. */
2340 fragP
->fr_type
= rs_align
;
2341 fragP
->fr_subtype
= 0;
2342 fragP
->fr_offset
= 0;
2343 fragP
->fr_fix
= after
- address
;
2354 amount
= S_GET_VALUE (symbolP
);
2355 if (S_GET_SEGMENT (symbolP
) != absolute_section
2356 || S_IS_COMMON (symbolP
)
2357 || ! S_IS_DEFINED (symbolP
))
2359 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
2360 _(".space specifies non-absolute value"));
2361 /* Prevent repeat of this error message. */
2362 fragP
->fr_symbol
= 0;
2364 else if (amount
< 0)
2366 /* Don't error on first few frag relax passes.
2367 See rs_org comment for a longer explanation. */
2374 as_warn_where (fragP
->fr_file
, fragP
->fr_line
,
2375 _(".space or .fill with negative value, ignored"));
2376 fragP
->fr_symbol
= 0;
2379 growth
= (was_address
+ fragP
->fr_fix
+ amount
2380 - fragP
->fr_next
->fr_address
);
2384 case rs_machine_dependent
:
2385 #ifdef md_relax_frag
2386 growth
= md_relax_frag (segment
, fragP
, stretch
);
2388 #ifdef TC_GENERIC_RELAX_TABLE
2389 /* The default way to relax a frag is to look through
2390 TC_GENERIC_RELAX_TABLE. */
2391 growth
= relax_frag (segment
, fragP
, stretch
);
2392 #endif /* TC_GENERIC_RELAX_TABLE */
2401 value
= resolve_symbol_value (fragP
->fr_symbol
);
2402 size
= sizeof_leb128 (value
, fragP
->fr_subtype
);
2403 growth
= size
- fragP
->fr_offset
;
2404 fragP
->fr_offset
= size
;
2409 growth
= eh_frame_relax_frag (fragP
);
2413 growth
= dwarf2dbg_relax_frag (fragP
);
2417 BAD_CASE (fragP
->fr_type
);
2424 if (fragP
->fr_type
== rs_leb128
)
2425 rs_leb128_fudge
+= 16;
2426 else if (fragP
->fr_type
== rs_align
2427 && (rs_leb128_fudge
& 16) != 0
2429 rs_leb128_fudge
+= 16;
2431 rs_leb128_fudge
= 0;
2436 && (rs_leb128_fudge
& 16) == 0
2437 && (rs_leb128_fudge
& -16) != 0)
2438 rs_leb128_fudge
+= 1;
2440 rs_leb128_fudge
= 0;
2442 /* Until nothing further to relax. */
2443 while (stretched
&& -- max_iterations
);
2446 as_fatal (_("Infinite loop encountered whilst attempting to compute the addresses of symbols in section %s"),
2447 segment_name (segment
));
2450 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
2451 if (fragP
->last_fr_address
!= fragP
->fr_address
)
2453 fragP
->last_fr_address
= fragP
->fr_address
;
2460 number_to_chars_bigendian (char *buf
, valueT val
, int n
)
2466 buf
[n
] = val
& 0xff;
2472 number_to_chars_littleendian (char *buf
, valueT val
, int n
)
2478 *buf
++ = val
& 0xff;
2484 write_print_statistics (FILE *file
)
2486 fprintf (file
, "fixups: %d\n", n_fixups
);
2489 /* For debugging. */
2490 extern int indent_level
;
2493 print_fixup (fixS
*fixp
)
2496 fprintf (stderr
, "fix ");
2497 fprintf_vma (stderr
, (bfd_vma
)((bfd_hostptr_t
) fixp
));
2498 fprintf (stderr
, " %s:%d",fixp
->fx_file
, fixp
->fx_line
);
2500 fprintf (stderr
, " pcrel");
2501 if (fixp
->fx_pcrel_adjust
)
2502 fprintf (stderr
, " pcrel_adjust=%d", fixp
->fx_pcrel_adjust
);
2503 if (fixp
->fx_im_disp
)
2506 fprintf (stderr
, " im_disp=%d", fixp
->fx_im_disp
);
2508 fprintf (stderr
, " im_disp");
2512 fprintf (stderr
, " tcbit");
2514 fprintf (stderr
, " done");
2515 fprintf (stderr
, "\n size=%d frag=", fixp
->fx_size
);
2516 fprintf_vma (stderr
, (bfd_vma
) ((bfd_hostptr_t
) fixp
->fx_frag
));
2517 fprintf (stderr
, " where=%ld offset=%lx addnumber=%lx",
2518 (long) fixp
->fx_where
,
2519 (long) fixp
->fx_offset
, (long) fixp
->fx_addnumber
);
2520 fprintf (stderr
, "\n %s (%d)", bfd_get_reloc_code_name (fixp
->fx_r_type
),
2524 fprintf (stderr
, "\n +<");
2525 print_symbol_value_1 (stderr
, fixp
->fx_addsy
);
2526 fprintf (stderr
, ">");
2530 fprintf (stderr
, "\n -<");
2531 print_symbol_value_1 (stderr
, fixp
->fx_subsy
);
2532 fprintf (stderr
, ">");
2534 fprintf (stderr
, "\n");
2535 #ifdef TC_FIX_DATA_PRINT
2536 TC_FIX_DATA_PRINT (stderr
, fixp
);