1 /* write.c - emit .o file
2 Copyright (C) 1986-2024 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21 /* This thing should be set up to do byte ordering correctly. But... */
26 #include "output-file.h"
27 #include "dwarf2dbg.h"
28 #include "compress-debug.h"
30 #ifndef TC_FORCE_RELOCATION
31 #define TC_FORCE_RELOCATION(FIX) \
32 (generic_force_reloc (FIX))
35 #ifndef TC_FORCE_RELOCATION_ABS
36 #define TC_FORCE_RELOCATION_ABS(FIX) \
37 (TC_FORCE_RELOCATION (FIX))
40 #define GENERIC_FORCE_RELOCATION_LOCAL(FIX) \
42 || TC_FORCE_RELOCATION (FIX))
43 #ifndef TC_FORCE_RELOCATION_LOCAL
44 #define TC_FORCE_RELOCATION_LOCAL GENERIC_FORCE_RELOCATION_LOCAL
47 #define GENERIC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
49 #ifndef TC_FORCE_RELOCATION_SUB_SAME
50 #define TC_FORCE_RELOCATION_SUB_SAME GENERIC_FORCE_RELOCATION_SUB_SAME
53 #ifndef md_register_arithmetic
54 # define md_register_arithmetic 1
57 #ifndef TC_FORCE_RELOCATION_SUB_ABS
58 #define TC_FORCE_RELOCATION_SUB_ABS(FIX, SEG) \
59 (!md_register_arithmetic && (SEG) == reg_section)
62 #ifndef TC_FORCE_RELOCATION_SUB_LOCAL
64 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) \
65 (!md_register_arithmetic && (SEG) == reg_section)
67 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) 1
71 #ifndef TC_VALIDATE_FIX_SUB
72 #define TC_VALIDATE_FIX_SUB(FIX, SEG) 0
75 #ifndef TC_LINKRELAX_FIXUP
76 #define TC_LINKRELAX_FIXUP(SEG) 1
79 #ifndef MD_APPLY_SYM_VALUE
80 #define MD_APPLY_SYM_VALUE(FIX) 1
83 #ifndef TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
84 #define TC_FINALIZE_SYMS_BEFORE_SIZE_SEG 1
87 #ifndef MD_PCREL_FROM_SECTION
88 #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from (FIX)
92 #define TC_FAKE_LABEL(NAME) (strcmp ((NAME), FAKE_LABEL_NAME) == 0)
95 /* Positive values of TC_FX_SIZE_SLACK allow a target to define
96 fixups that far past the end of a frag. Having such fixups
97 is of course most most likely a bug in setting fx_size correctly.
98 A negative value disables the fixup check entirely, which is
99 appropriate for something like the Renesas / SuperH SH_COUNT
101 #ifndef TC_FX_SIZE_SLACK
102 #define TC_FX_SIZE_SLACK(FIX) 0
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. */
115 /* The frag that dot_value is based from. */
118 /* Relocs generated by ".reloc" pseudo. */
119 struct reloc_list
* reloc_list
;
121 void print_fixup (fixS
*);
123 /* We generally attach relocs to frag chains. However, after we have
124 chained these all together into a segment, any relocs we add after
125 that must be attached to a segment. This will include relocs added
126 in md_estimate_size_before_relax, for example. */
127 static bool frags_chained
= false;
129 static unsigned int n_fixups
;
131 #define RELOC_ENUM enum bfd_reloc_code_real
133 /* Create a fixS in obstack 'notes'. */
136 fix_new_internal (fragS
*frag
, /* Which frag? */
137 unsigned long where
, /* Where in that frag? */
138 unsigned long size
, /* 1, 2, or 4 usually. */
139 symbolS
*add_symbol
, /* X_add_symbol. */
140 symbolS
*sub_symbol
, /* X_op_symbol. */
141 offsetT offset
, /* X_add_number. */
142 int pcrel
, /* TRUE if PC-relative relocation. */
143 RELOC_ENUM r_type
/* Relocation type. */,
144 int at_beginning
) /* Add to the start of the list? */
150 fixP
= (fixS
*) obstack_alloc (¬es
, sizeof (fixS
));
152 fixP
->fx_frag
= frag
;
153 fixP
->fx_where
= where
;
154 fixP
->fx_size
= size
;
155 /* We've made fx_size a narrow field; check that it's wide enough. */
156 if (fixP
->fx_size
!= size
)
158 as_bad (_("field fx_size too small to hold %lu"), size
);
161 fixP
->fx_addsy
= add_symbol
;
162 fixP
->fx_subsy
= sub_symbol
;
163 fixP
->fx_offset
= offset
;
164 fixP
->fx_dot_value
= dot_value
;
165 fixP
->fx_dot_frag
= dot_frag
;
166 fixP
->fx_pcrel
= pcrel
;
167 fixP
->fx_r_type
= r_type
;
168 fixP
->fx_pcrel_adjust
= 0;
169 fixP
->fx_addnumber
= 0;
174 fixP
->fx_no_overflow
= 0;
178 fixP
->fx_cgen
.insn
= NULL
;
179 fixP
->fx_cgen
.opinfo
= 0;
183 TC_INIT_FIX_DATA (fixP
);
186 fixP
->fx_file
= as_where (&fixP
->fx_line
);
190 fixS
**seg_fix_rootP
= (frags_chained
191 ? &seg_info (now_seg
)->fix_root
192 : &frchain_now
->fix_root
);
193 fixS
**seg_fix_tailP
= (frags_chained
194 ? &seg_info (now_seg
)->fix_tail
195 : &frchain_now
->fix_tail
);
199 fixP
->fx_next
= *seg_fix_rootP
;
200 *seg_fix_rootP
= fixP
;
201 if (fixP
->fx_next
== NULL
)
202 *seg_fix_tailP
= fixP
;
206 fixP
->fx_next
= NULL
;
208 (*seg_fix_tailP
)->fx_next
= fixP
;
210 *seg_fix_rootP
= fixP
;
211 *seg_fix_tailP
= fixP
;
218 /* Create a fixup relative to a symbol (plus a constant). */
221 fix_new (fragS
*frag
, /* Which frag? */
222 unsigned long where
, /* Where in that frag? */
223 unsigned long size
, /* 1, 2, or 4 usually. */
224 symbolS
*add_symbol
, /* X_add_symbol. */
225 offsetT offset
, /* X_add_number. */
226 int pcrel
, /* TRUE if PC-relative relocation. */
227 RELOC_ENUM r_type
/* Relocation type. */)
229 return fix_new_internal (frag
, where
, size
, add_symbol
,
230 (symbolS
*) NULL
, offset
, pcrel
, r_type
, false);
233 /* Create a fixup for an expression. Currently we only support fixups
234 for difference expressions. That is itself more than most object
235 file formats support anyhow. */
238 fix_new_exp (fragS
*frag
, /* Which frag? */
239 unsigned long where
, /* Where in that frag? */
240 unsigned long size
, /* 1, 2, or 4 usually. */
241 const expressionS
*exp
, /* Expression. */
242 int pcrel
, /* TRUE if PC-relative relocation. */
243 RELOC_ENUM r_type
/* Relocation type. */)
255 as_bad (_("register value used as expression"));
259 add
= exp
->X_add_symbol
;
260 off
= exp
->X_add_number
;
261 r_type
= BFD_RELOC_RVA
;
265 sub
= exp
->X_add_symbol
;
266 off
= exp
->X_add_number
;
270 sub
= exp
->X_op_symbol
;
273 add
= exp
->X_add_symbol
;
276 off
= exp
->X_add_number
;
279 case O_add
: /* This comes up when _GLOBAL_OFFSET_TABLE_+(.-L0) is read, if
280 the difference expression cannot immediately be reduced. */
282 add
= make_expr_symbol (exp
);
286 return fix_new_internal (frag
, where
, size
, add
, sub
, off
, pcrel
,
290 /* Create a fixup at the beginning of FRAG. The arguments are the same
291 as for fix_new, except that WHERE is implicitly 0. */
294 fix_at_start (fragS
*frag
, unsigned long size
, symbolS
*add_symbol
,
295 offsetT offset
, int pcrel
, RELOC_ENUM r_type
)
297 return fix_new_internal (frag
, 0, size
, add_symbol
,
298 (symbolS
*) NULL
, offset
, pcrel
, r_type
, true);
301 /* Generic function to determine whether a fixup requires a relocation. */
303 generic_force_reloc (fixS
*fix
)
305 if (fix
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
306 || fix
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
309 if (fix
->fx_addsy
== NULL
)
312 return S_FORCE_RELOC (fix
->fx_addsy
, fix
->fx_subsy
== NULL
);
315 /* Append a string onto another string, bumping the pointer along. */
317 append (char **charPP
, char *fromP
, unsigned long length
)
319 /* Don't trust memcpy() of 0 chars. */
323 memcpy (*charPP
, fromP
, length
);
327 /* This routine records the largest alignment seen for each segment.
328 If the beginning of the segment is aligned on the worst-case
329 boundary, all of the other alignments within it will work. At
330 least one object format really uses this info. */
333 record_alignment (/* Segment to which alignment pertains. */
335 /* Alignment, as a power of 2 (e.g., 1 => 2-byte
336 boundary, 2 => 4-byte boundary, etc.) */
339 if (seg
== absolute_section
)
342 if (align
> bfd_section_alignment (seg
))
343 bfd_set_section_alignment (seg
, align
);
347 get_recorded_alignment (segT seg
)
349 if (seg
== absolute_section
)
352 return bfd_section_alignment (seg
);
355 /* Reset the section indices after removing the gas created sections. */
358 renumber_sections (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, void *countparg
)
360 int *countp
= (int *) countparg
;
362 sec
->index
= *countp
;
367 chain_frchains_together_1 (segT section
, struct frchain
*frchp
)
369 fragS dummy
, *prev_frag
= &dummy
;
370 fixS fix_dummy
, *prev_fix
= &fix_dummy
;
374 prev_frag
->fr_next
= frchp
->frch_root
;
375 prev_frag
= frchp
->frch_last
;
376 gas_assert (prev_frag
->fr_type
!= 0);
377 if (frchp
->fix_root
!= (fixS
*) NULL
)
379 if (seg_info (section
)->fix_root
== (fixS
*) NULL
)
380 seg_info (section
)->fix_root
= frchp
->fix_root
;
381 prev_fix
->fx_next
= frchp
->fix_root
;
382 seg_info (section
)->fix_tail
= frchp
->fix_tail
;
383 prev_fix
= frchp
->fix_tail
;
385 frchp
= frchp
->frch_next
;
387 gas_assert (prev_frag
!= &dummy
388 && prev_frag
->fr_type
!= 0);
389 prev_frag
->fr_next
= 0;
394 chain_frchains_together (bfd
*abfd ATTRIBUTE_UNUSED
,
396 void *xxx ATTRIBUTE_UNUSED
)
398 segment_info_type
*info
;
400 /* BFD may have introduced its own sections without using
401 subseg_new, so it is possible that seg_info is NULL. */
402 info
= seg_info (section
);
403 if (info
!= (segment_info_type
*) NULL
)
404 info
->frchainP
->frch_last
405 = chain_frchains_together_1 (section
, info
->frchainP
);
407 /* Now that we've chained the frags together, we must add new fixups
408 to the segment, not to the frag chain. */
409 frags_chained
= true;
413 cvt_frag_to_fill (segT sec ATTRIBUTE_UNUSED
, fragS
*fragP
)
415 switch (fragP
->fr_type
)
425 HANDLE_ALIGN (fragP
);
428 know (fragP
->fr_next
!= NULL
);
429 fragP
->fr_offset
= (fragP
->fr_next
->fr_address
431 - fragP
->fr_fix
) / fragP
->fr_var
;
432 if (fragP
->fr_offset
< 0)
434 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
435 _("attempt to .org/.space/.nops backwards? (%ld)"),
436 (long) fragP
->fr_offset
);
437 fragP
->fr_offset
= 0;
439 if (fragP
->fr_type
== rs_space_nop
)
440 fragP
->fr_type
= rs_fill_nop
;
442 fragP
->fr_type
= rs_fill
;
451 valueT value
= S_GET_VALUE (fragP
->fr_symbol
);
454 if (!S_IS_DEFINED (fragP
->fr_symbol
))
456 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
457 _("leb128 operand is an undefined symbol: %s"),
458 S_GET_NAME (fragP
->fr_symbol
));
461 size
= output_leb128 (fragP
->fr_literal
+ fragP
->fr_fix
, value
,
464 fragP
->fr_fix
+= size
;
465 fragP
->fr_type
= rs_fill
;
467 fragP
->fr_offset
= 0;
468 fragP
->fr_symbol
= NULL
;
473 eh_frame_convert_frag (fragP
);
477 dwarf2dbg_convert_frag (fragP
);
481 sframe_convert_frag (fragP
);
484 case rs_machine_dependent
:
485 md_convert_frag (stdoutput
, sec
, fragP
);
487 gas_assert (fragP
->fr_next
== NULL
488 || (fragP
->fr_next
->fr_address
- fragP
->fr_address
491 /* After md_convert_frag, we make the frag into a ".space 0".
492 md_convert_frag() should set up any fixSs and constants
497 #ifndef WORKING_DOT_WORD
500 struct broken_word
*lie
;
502 if (fragP
->fr_subtype
)
504 fragP
->fr_fix
+= md_short_jump_size
;
505 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
506 lie
&& lie
->dispfrag
== fragP
;
507 lie
= lie
->next_broken_word
)
509 fragP
->fr_fix
+= md_long_jump_size
;
517 BAD_CASE (fragP
->fr_type
);
521 md_frag_check (fragP
);
525 struct relax_seg_info
532 relax_seg (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, void *xxx
)
534 segment_info_type
*seginfo
= seg_info (sec
);
535 struct relax_seg_info
*info
= (struct relax_seg_info
*) xxx
;
537 if (seginfo
&& seginfo
->frchainP
538 && relax_segment (seginfo
->frchainP
->frch_root
, sec
, info
->pass
))
543 size_seg (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, void *xxx ATTRIBUTE_UNUSED
)
547 segment_info_type
*seginfo
;
549 valueT size
, newsize
;
551 subseg_change (sec
, 0);
553 seginfo
= seg_info (sec
);
554 if (seginfo
&& seginfo
->frchainP
)
556 for (fragp
= seginfo
->frchainP
->frch_root
; fragp
; fragp
= fragp
->fr_next
)
557 cvt_frag_to_fill (sec
, fragp
);
558 for (fragp
= seginfo
->frchainP
->frch_root
;
560 fragp
= fragp
->fr_next
)
561 /* Walk to last elt. */
563 size
= fragp
->fr_address
+ fragp
->fr_fix
;
568 flags
= bfd_section_flags (sec
);
569 if (size
== 0 && bfd_section_size (sec
) != 0 &&
570 (flags
& SEC_HAS_CONTENTS
) != 0)
573 if (size
> 0 && ! seginfo
->bss
)
574 flags
|= SEC_HAS_CONTENTS
;
576 x
= bfd_set_section_flags (sec
, flags
);
579 /* If permitted, allow the backend to pad out the section
580 to some alignment boundary. */
581 if (do_not_pad_sections_to_alignment
)
584 newsize
= md_section_align (sec
, size
);
585 x
= bfd_set_section_size (sec
, newsize
);
588 /* If the size had to be rounded up, add some padding in the last
590 gas_assert (newsize
>= size
);
593 fragS
*last
= seginfo
->frchainP
->frch_last
;
594 fragp
= seginfo
->frchainP
->frch_root
;
595 while (fragp
->fr_next
!= last
)
596 fragp
= fragp
->fr_next
;
597 last
->fr_address
= size
;
598 if ((newsize
- size
) % fragp
->fr_var
== 0)
599 fragp
->fr_offset
+= (newsize
- size
) / fragp
->fr_var
;
601 /* If we hit this abort, it's likely due to subsegs_finish not
602 providing sufficient alignment on the last frag, and the
603 machine dependent code using alignment frags with fr_var
608 #ifdef tc_frob_section
609 tc_frob_section (sec
);
611 #ifdef obj_frob_section
612 obj_frob_section (sec
);
618 dump_section_relocs (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, FILE *stream
)
620 segment_info_type
*seginfo
= seg_info (sec
);
621 fixS
*fixp
= seginfo
->fix_root
;
626 fprintf (stream
, "sec %s relocs:\n", sec
->name
);
629 symbolS
*s
= fixp
->fx_addsy
;
631 fprintf (stream
, " %08lx: type %d ", (unsigned long) fixp
,
632 (int) fixp
->fx_r_type
);
634 fprintf (stream
, "no sym\n");
637 print_symbol_value_1 (stream
, s
);
638 fprintf (stream
, "\n");
640 fixp
= fixp
->fx_next
;
644 #define dump_section_relocs(ABFD,SEC,STREAM) ((void) 0)
647 #ifndef EMIT_SECTION_SYMBOLS
648 #define EMIT_SECTION_SYMBOLS 1
651 /* Resolve U.A.OFFSET_SYM and U.A.SYM fields of RELOC_LIST entries,
652 and check for validity. Convert RELOC_LIST from using U.A fields
655 resolve_reloc_expr_symbols (void)
657 bfd_vma addr_mask
= 1;
658 struct reloc_list
*r
;
660 /* Avoid a shift by the width of type. */
661 addr_mask
<<= bfd_arch_bits_per_address (stdoutput
) - 1;
665 for (r
= reloc_list
; r
; r
= r
->next
)
667 reloc_howto_type
*howto
= r
->u
.a
.howto
;
670 bfd_vma offset
, addend
;
673 resolve_symbol_value (r
->u
.a
.offset_sym
);
674 symval
= symbol_get_value_expression (r
->u
.a
.offset_sym
);
678 if (symval
->X_op
== O_constant
)
679 sym
= r
->u
.a
.offset_sym
;
680 else if (symval
->X_op
== O_symbol
)
682 sym
= symval
->X_add_symbol
;
683 offset
= symval
->X_add_number
;
684 symval
= symbol_get_value_expression (symval
->X_add_symbol
);
687 || symval
->X_op
!= O_constant
688 || (sec
= S_GET_SEGMENT (sym
)) == NULL
689 || !SEG_NORMAL (sec
))
691 as_bad_where (r
->file
, r
->line
, _("invalid offset expression"));
695 offset
+= S_GET_VALUE (sym
);
698 addend
= r
->u
.a
.addend
;
699 if (r
->u
.a
.sym
!= NULL
)
701 resolve_symbol_value (r
->u
.a
.sym
);
702 symval
= symbol_get_value_expression (r
->u
.a
.sym
);
703 if (symval
->X_op
== O_constant
)
705 else if (symval
->X_op
== O_symbol
)
707 sym
= symval
->X_add_symbol
;
708 addend
+= symval
->X_add_number
;
709 symval
= symbol_get_value_expression (symval
->X_add_symbol
);
711 if (symval
->X_op
!= O_constant
)
713 as_bad_where (r
->file
, r
->line
, _("invalid reloc expression"));
716 else if (sym
!= NULL
&& sec
!= NULL
)
718 /* Convert relocs against local symbols to refer to the
719 corresponding section symbol plus offset instead. Keep
720 PC-relative relocs of the REL variety intact though to
721 prevent the offset from overflowing the relocated field,
722 unless it has enough bits to cover the whole address
725 && S_IS_DEFINED (sym
)
726 && !symbol_section_p (sym
)
728 || (howto
->partial_inplace
729 && (!howto
->pc_relative
730 || howto
->src_mask
== addr_mask
))))
732 asection
*symsec
= S_GET_SEGMENT (sym
);
733 if (!(((symsec
->flags
& SEC_MERGE
) != 0
735 || (symsec
->flags
& SEC_THREAD_LOCAL
) != 0))
737 addend
+= S_GET_VALUE (sym
);
738 sym
= section_symbol (symsec
);
741 symbol_mark_used_in_reloc (sym
);
746 if (abs_section_sym
== NULL
)
747 abs_section_sym
= section_symbol (absolute_section
);
748 sym
= abs_section_sym
;
752 r
->u
.b
.s
= symbol_get_bfdsym (sym
);
753 r
->u
.b
.r
.sym_ptr_ptr
= &r
->u
.b
.s
;
754 r
->u
.b
.r
.address
= offset
;
755 r
->u
.b
.r
.addend
= addend
;
756 r
->u
.b
.r
.howto
= howto
;
760 /* This pass over fixups decides whether symbols can be replaced with
764 adjust_reloc_syms (bfd
*abfd ATTRIBUTE_UNUSED
,
766 void *xxx ATTRIBUTE_UNUSED
)
768 segment_info_type
*seginfo
= seg_info (sec
);
775 dump_section_relocs (abfd
, sec
, stderr
);
777 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
781 else if (fixp
->fx_addsy
)
787 fprintf (stderr
, "\n\nadjusting fixup:\n");
791 sym
= fixp
->fx_addsy
;
793 /* All symbols should have already been resolved at this
794 point. It is possible to see unresolved expression
795 symbols, though, since they are not in the regular symbol
797 resolve_symbol_value (sym
);
799 if (fixp
->fx_subsy
!= NULL
)
800 resolve_symbol_value (fixp
->fx_subsy
);
802 /* If this symbol is equated to an undefined or common symbol,
803 convert the fixup to being against that symbol. */
804 while (symbol_equated_reloc_p (sym
)
805 || S_IS_WEAKREFR (sym
))
807 symbolS
*newsym
= symbol_get_value_expression (sym
)->X_add_symbol
;
810 fixp
->fx_offset
+= symbol_get_value_expression (sym
)->X_add_number
;
811 fixp
->fx_addsy
= newsym
;
815 if (symbol_mri_common_p (sym
))
817 fixp
->fx_offset
+= S_GET_VALUE (sym
);
818 fixp
->fx_addsy
= symbol_get_value_expression (sym
)->X_add_symbol
;
822 /* If the symbol is undefined, common, weak, or global (ELF
823 shared libs), we can't replace it with the section symbol. */
824 if (S_FORCE_RELOC (fixp
->fx_addsy
, 1))
827 /* Is there some other (target cpu dependent) reason we can't adjust
828 this one? (E.g. relocations involving function addresses on
830 #ifdef tc_fix_adjustable
831 if (! tc_fix_adjustable (fixp
))
835 /* Since we're reducing to section symbols, don't attempt to reduce
836 anything that's already using one. */
837 if (symbol_section_p (sym
))
839 /* Mark the section symbol used in relocation so that it will
840 be included in the symbol table. */
841 symbol_mark_used_in_reloc (sym
);
845 symsec
= S_GET_SEGMENT (sym
);
849 if (bfd_is_abs_section (symsec
)
850 || symsec
== reg_section
)
852 /* The fixup_segment routine normally will not use this
853 symbol in a relocation. */
857 /* Don't try to reduce relocs which refer to non-local symbols
858 in .linkonce sections. It can lead to confusion when a
859 debugging section refers to a .linkonce section. I hope
860 this will always be correct. */
861 if (symsec
!= sec
&& ! S_IS_LOCAL (sym
))
863 if ((symsec
->flags
& SEC_LINK_ONCE
) != 0
865 /* The GNU toolchain uses an extension for ELF: a
866 section beginning with the magic string
867 .gnu.linkonce is a linkonce section. */
868 && startswith (segment_name (symsec
), ".gnu.linkonce")))
872 /* Never adjust a reloc against local symbol in a merge section
873 with non-zero addend. */
874 if ((symsec
->flags
& SEC_MERGE
) != 0
875 && (fixp
->fx_offset
!= 0 || fixp
->fx_subsy
!= NULL
))
878 /* Never adjust a reloc against TLS local symbol. */
879 if ((symsec
->flags
& SEC_THREAD_LOCAL
) != 0)
882 val
= S_GET_VALUE (sym
);
884 #if defined(TC_AARCH64) && defined(OBJ_COFF)
885 /* coff aarch64 relocation offsets need to be limited to 21bits.
886 This is because addend may need to be stored in an ADRP instruction.
887 In this case the addend cannot be stored down shifted otherwise rounding errors occur. */
888 if ((val
+ 0x100000) > 0x1fffff)
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
+= val
;
896 fixp
->fx_addsy
= section_symbol (S_GET_SEGMENT (sym
));
898 fprintf (stderr
, "\nadjusted fixup:\n");
903 dump_section_relocs (abfd
, sec
, stderr
);
907 as_bad_subtract (fixS
*fixp
)
909 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
910 _("can't resolve %s - %s"),
911 fixp
->fx_addsy
? S_GET_NAME (fixp
->fx_addsy
) : "0",
912 S_GET_NAME (fixp
->fx_subsy
));
917 Go through all the fixS's in a segment and see which ones can be
918 handled now. (These consist of fixS where we have since discovered
919 the value of a symbol, or the address of the frag involved.)
920 For each one, call md_apply_fix to put the fix into the frag data.
921 Ones that we couldn't completely handle here will be output later
922 by emit_relocations. */
925 fixup_segment (fixS
*fixP
, segT this_segment
)
930 if (fixP
!= NULL
&& abs_section_sym
== NULL
)
931 abs_section_sym
= section_symbol (absolute_section
);
933 /* If the linker is doing the relaxing, we must not do any fixups.
935 Well, strictly speaking that's not true -- we could do any that
936 are PC-relative and don't cross regions that could change size. */
937 if (linkrelax
&& TC_LINKRELAX_FIXUP (this_segment
))
939 for (; fixP
; fixP
= fixP
->fx_next
)
942 if (fixP
->fx_addsy
== NULL
)
944 /* There was no symbol required by this relocation.
945 However, BFD doesn't really handle relocations
946 without symbols well. So fake up a local symbol in
947 the absolute section. */
948 fixP
->fx_addsy
= abs_section_sym
;
950 symbol_mark_used_in_reloc (fixP
->fx_addsy
);
951 if (fixP
->fx_subsy
!= NULL
)
952 symbol_mark_used_in_reloc (fixP
->fx_subsy
);
957 for (; fixP
; fixP
= fixP
->fx_next
)
959 segT add_symbol_segment
= absolute_section
;
962 fprintf (stderr
, "\nprocessing fixup:\n");
966 fragP
= fixP
->fx_frag
;
968 #ifdef TC_VALIDATE_FIX
969 TC_VALIDATE_FIX (fixP
, this_segment
, skip
);
971 add_number
= fixP
->fx_offset
;
973 if (fixP
->fx_addsy
!= NULL
)
974 add_symbol_segment
= S_GET_SEGMENT (fixP
->fx_addsy
);
976 if (fixP
->fx_subsy
!= NULL
)
978 segT sub_symbol_segment
;
980 resolve_symbol_value (fixP
->fx_subsy
);
981 sub_symbol_segment
= S_GET_SEGMENT (fixP
->fx_subsy
);
983 if (fixP
->fx_addsy
!= NULL
984 && sub_symbol_segment
== add_symbol_segment
985 && !S_FORCE_RELOC (fixP
->fx_addsy
, 0)
986 && !S_FORCE_RELOC (fixP
->fx_subsy
, 0)
987 && !TC_FORCE_RELOCATION_SUB_SAME (fixP
, add_symbol_segment
))
989 add_number
+= S_GET_VALUE_WHERE (fixP
->fx_addsy
, fixP
->fx_file
, fixP
->fx_line
);
990 add_number
-= S_GET_VALUE_WHERE (fixP
->fx_subsy
, fixP
->fx_file
, fixP
->fx_line
);
991 fixP
->fx_offset
= add_number
;
992 fixP
->fx_addsy
= NULL
;
993 fixP
->fx_subsy
= NULL
;
995 /* See the comment below about 68k weirdness. */
999 else if (sub_symbol_segment
== absolute_section
1000 && !S_FORCE_RELOC (fixP
->fx_subsy
, 0)
1001 && !TC_FORCE_RELOCATION_SUB_ABS (fixP
, add_symbol_segment
))
1003 add_number
-= S_GET_VALUE_WHERE (fixP
->fx_subsy
, fixP
->fx_file
, fixP
->fx_line
);
1004 fixP
->fx_offset
= add_number
;
1005 fixP
->fx_subsy
= NULL
;
1007 else if (sub_symbol_segment
== this_segment
1008 && !S_FORCE_RELOC (fixP
->fx_subsy
, 0)
1009 && !TC_FORCE_RELOCATION_SUB_LOCAL (fixP
, add_symbol_segment
))
1011 add_number
-= S_GET_VALUE_WHERE (fixP
->fx_subsy
, fixP
->fx_file
, fixP
->fx_line
);
1012 fixP
->fx_offset
= (add_number
+ fixP
->fx_dot_value
1013 + fixP
->fx_dot_frag
->fr_address
);
1015 /* Make it pc-relative. If the back-end code has not
1016 selected a pc-relative reloc, cancel the adjustment
1017 we do later on all pc-relative relocs. */
1020 /* Do this for m68k even if it's already described
1021 as pc-relative. On the m68k, an operand of
1022 "pc@(foo-.-2)" should address "foo" in a
1023 pc-relative mode. */
1027 add_number
+= MD_PCREL_FROM_SECTION (fixP
, this_segment
);
1028 fixP
->fx_subsy
= NULL
;
1031 else if (!TC_VALIDATE_FIX_SUB (fixP
, add_symbol_segment
))
1033 if (!md_register_arithmetic
1034 && (add_symbol_segment
== reg_section
1035 || sub_symbol_segment
== reg_section
))
1036 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1037 _("register value used as expression"));
1039 as_bad_subtract (fixP
);
1041 else if (sub_symbol_segment
!= undefined_section
1042 && ! bfd_is_com_section (sub_symbol_segment
)
1043 && MD_APPLY_SYM_VALUE (fixP
))
1044 add_number
-= S_GET_VALUE_WHERE (fixP
->fx_subsy
, fixP
->fx_file
, fixP
->fx_line
);
1049 if (add_symbol_segment
== this_segment
1050 && !S_FORCE_RELOC (fixP
->fx_addsy
, 0)
1051 && !TC_FORCE_RELOCATION_LOCAL (fixP
))
1053 /* This fixup was made when the symbol's segment was
1054 SEG_UNKNOWN, but it is now in the local segment.
1055 So we know how to do the address without relocation. */
1056 add_number
+= S_GET_VALUE_WHERE (fixP
->fx_addsy
, fixP
->fx_file
, fixP
->fx_line
);
1057 fixP
->fx_offset
= add_number
;
1059 add_number
-= MD_PCREL_FROM_SECTION (fixP
, this_segment
);
1060 fixP
->fx_addsy
= NULL
;
1063 else if (add_symbol_segment
== absolute_section
1064 && !S_FORCE_RELOC (fixP
->fx_addsy
, 0)
1065 && !TC_FORCE_RELOCATION_ABS (fixP
))
1067 add_number
+= S_GET_VALUE_WHERE (fixP
->fx_addsy
, fixP
->fx_file
, fixP
->fx_line
);
1068 fixP
->fx_offset
= add_number
;
1069 fixP
->fx_addsy
= NULL
;
1071 else if (add_symbol_segment
!= undefined_section
1072 && ! bfd_is_com_section (add_symbol_segment
)
1073 && MD_APPLY_SYM_VALUE (fixP
))
1074 add_number
+= S_GET_VALUE_WHERE (fixP
->fx_addsy
, fixP
->fx_file
, fixP
->fx_line
);
1079 add_number
-= MD_PCREL_FROM_SECTION (fixP
, this_segment
);
1080 if (!fixP
->fx_done
&& fixP
->fx_addsy
== NULL
)
1082 /* There was no symbol required by this relocation.
1083 However, BFD doesn't really handle relocations
1084 without symbols well. So fake up a local symbol in
1085 the absolute section. */
1086 fixP
->fx_addsy
= abs_section_sym
;
1091 md_apply_fix (fixP
, &add_number
, this_segment
);
1095 if (fixP
->fx_addsy
== NULL
)
1096 fixP
->fx_addsy
= abs_section_sym
;
1097 symbol_mark_used_in_reloc (fixP
->fx_addsy
);
1098 if (fixP
->fx_subsy
!= NULL
)
1099 symbol_mark_used_in_reloc (fixP
->fx_subsy
);
1102 if (!fixP
->fx_no_overflow
&& fixP
->fx_size
!= 0)
1104 if (fixP
->fx_size
< sizeof (valueT
))
1109 mask
--; /* Set all bits to one. */
1110 mask
<<= fixP
->fx_size
* 8 - (fixP
->fx_signed
? 1 : 0);
1111 if ((add_number
& mask
) != 0
1113 ? (add_number
& mask
) != mask
1114 : (-add_number
& mask
) != 0))
1116 char buf
[50], buf2
[50];
1117 bfd_sprintf_vma (stdoutput
, buf
, fragP
->fr_address
+ fixP
->fx_where
);
1118 if (add_number
> 1000)
1119 bfd_sprintf_vma (stdoutput
, buf2
, add_number
);
1121 sprintf (buf2
, "%ld", (long) add_number
);
1122 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1123 ngettext ("value of %s too large for field "
1125 "value of %s too large for field "
1126 "of %d bytes at %s",
1128 buf2
, fixP
->fx_size
, buf
);
1129 } /* Generic error checking. */
1131 #ifdef WARN_SIGNED_OVERFLOW_WORD
1132 /* Warn if a .word value is too large when treated as a signed
1133 number. We already know it is not too negative. This is to
1134 catch over-large switches generated by gcc on the 68k. */
1135 if (!flag_signed_overflow_ok
1136 && fixP
->fx_size
== 2
1137 && add_number
> 0x7fff)
1138 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1139 _("signed .word overflow; switch may be too large; %ld at 0x%lx"),
1141 (long) (fragP
->fr_address
+ fixP
->fx_where
));
1145 #ifdef TC_VALIDATE_FIX
1146 skip
: ATTRIBUTE_UNUSED_LABEL
1150 fprintf (stderr
, "result:\n");
1153 } /* For each fixS in this segment. */
1157 fix_segment (bfd
*abfd ATTRIBUTE_UNUSED
,
1159 void *xxx ATTRIBUTE_UNUSED
)
1161 segment_info_type
*seginfo
= seg_info (sec
);
1163 fixup_segment (seginfo
->fix_root
, sec
);
1167 install_reloc (asection
*sec
, arelent
*reloc
, fragS
*fragp
,
1168 const char *file
, unsigned int line
)
1171 bfd_reloc_status_type s
;
1174 if (reloc
->sym_ptr_ptr
!= NULL
1175 && (sym
= *reloc
->sym_ptr_ptr
) != NULL
1176 && (sym
->flags
& BSF_KEEP
) == 0
1177 && ((sym
->flags
& BSF_SECTION_SYM
) == 0
1178 || (EMIT_SECTION_SYMBOLS
1179 && !bfd_is_abs_section (sym
->section
))))
1180 as_bad_where (file
, line
, _("redefined symbol cannot be used on reloc"));
1182 s
= bfd_install_relocation (stdoutput
, reloc
,
1183 fragp
->fr_literal
, fragp
->fr_address
,
1189 case bfd_reloc_overflow
:
1190 as_bad_where (file
, line
, _("relocation overflow"));
1192 case bfd_reloc_outofrange
:
1193 as_bad_where (file
, line
, _("relocation out of range"));
1196 as_fatal (_("%s:%u: bad return from bfd_install_relocation: %x"),
1202 get_frag_for_reloc (fragS
*last_frag
,
1203 const segment_info_type
*seginfo
,
1204 const struct reloc_list
*r
)
1208 for (f
= last_frag
; f
!= NULL
; f
= f
->fr_next
)
1209 if (f
->fr_address
<= r
->u
.b
.r
.address
1210 && r
->u
.b
.r
.address
< f
->fr_address
+ f
->fr_fix
)
1213 for (f
= seginfo
->frchainP
->frch_root
; f
!= NULL
; 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 for (f
= seginfo
->frchainP
->frch_root
; f
!= NULL
; f
= f
->fr_next
)
1219 if (f
->fr_address
<= r
->u
.b
.r
.address
1220 && r
->u
.b
.r
.address
<= f
->fr_address
+ f
->fr_fix
)
1223 as_bad_where (r
->file
, r
->line
,
1224 _("reloc not within (fixed part of) section"));
1229 write_relocs (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
,
1230 void *xxx ATTRIBUTE_UNUSED
)
1232 segment_info_type
*seginfo
= seg_info (sec
);
1234 struct reloc_list
*my_reloc_list
, **rp
, *r
;
1239 /* If seginfo is NULL, we did not create this section; don't do
1240 anything with it. */
1241 if (seginfo
== NULL
)
1245 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
1249 #ifdef RELOC_EXPANSION_POSSIBLE
1250 n
*= MAX_RELOC_EXPANSION
;
1253 /* Extract relocs for this section from reloc_list. */
1256 my_reloc_list
= NULL
;
1257 while ((r
= *rp
) != NULL
)
1259 if (r
->u
.b
.sec
== sec
)
1262 r
->next
= my_reloc_list
;
1270 relocs
= XCNEWVEC (arelent
*, n
);
1275 for (fixp
= seginfo
->fix_root
; fixp
!= (fixS
*) NULL
; fixp
= fixp
->fx_next
)
1280 #ifndef RELOC_EXPANSION_POSSIBLE
1289 fx_size
= fixp
->fx_size
;
1290 slack
= TC_FX_SIZE_SLACK (fixp
);
1292 fx_size
= fx_size
> slack
? fx_size
- slack
: 0;
1293 loc
= fixp
->fx_where
+ fx_size
;
1294 if (slack
>= 0 && loc
> fixp
->fx_frag
->fr_fix
)
1295 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1296 _("internal error: fixup not contained within frag"));
1298 #ifdef obj_fixup_removed_symbol
1299 if (fixp
->fx_addsy
&& symbol_removed_p (fixp
->fx_addsy
))
1300 obj_fixup_removed_symbol (&fixp
->fx_addsy
);
1301 if (fixp
->fx_subsy
&& symbol_removed_p (fixp
->fx_subsy
))
1302 obj_fixup_removed_symbol (&fixp
->fx_subsy
);
1305 #ifndef RELOC_EXPANSION_POSSIBLE
1306 *reloc
= tc_gen_reloc (sec
, fixp
);
1308 reloc
= tc_gen_reloc (sec
, fixp
);
1313 while (r
!= NULL
&& r
->u
.b
.r
.address
< (*reloc
)->address
)
1315 fragS
*f
= get_frag_for_reloc (last_frag
, seginfo
, r
);
1319 relocs
[n
++] = &r
->u
.b
.r
;
1320 install_reloc (sec
, &r
->u
.b
.r
, f
, r
->file
, r
->line
);
1324 #ifdef GAS_SORT_RELOCS
1325 if (n
!= 0 && (*reloc
)->address
< relocs
[n
- 1]->address
)
1329 bfd_vma look
= (*reloc
)->address
;
1332 size_t mid
= (lo
+ hi
) / 2;
1333 if (relocs
[mid
]->address
> look
)
1338 if (relocs
[mid
]->address
== look
)
1342 while (lo
< hi
&& relocs
[lo
]->address
== look
)
1344 memmove (relocs
+ lo
+ 1, relocs
+ lo
,
1345 (n
- lo
) * sizeof (*relocs
));
1347 relocs
[lo
] = *reloc
;
1351 relocs
[n
++] = *reloc
;
1352 install_reloc (sec
, *reloc
, fixp
->fx_frag
,
1353 fixp
->fx_file
, fixp
->fx_line
);
1354 #ifndef RELOC_EXPANSION_POSSIBLE
1364 fragS
*f
= get_frag_for_reloc (last_frag
, seginfo
, r
);
1368 relocs
[n
++] = &r
->u
.b
.r
;
1369 install_reloc (sec
, &r
->u
.b
.r
, f
, r
->file
, r
->line
);
1376 unsigned int k
, j
, nsyms
;
1378 sympp
= bfd_get_outsymbols (stdoutput
);
1379 nsyms
= bfd_get_symcount (stdoutput
);
1380 for (k
= 0; k
< n
; k
++)
1381 if (((*relocs
[k
]->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
) == 0)
1383 for (j
= 0; j
< nsyms
; j
++)
1384 if (sympp
[j
] == *relocs
[k
]->sym_ptr_ptr
)
1392 bfd_set_reloc (stdoutput
, sec
, n
? relocs
: NULL
, n
);
1394 #ifdef SET_SECTION_RELOCS
1395 SET_SECTION_RELOCS (sec
, relocs
, n
);
1402 fprintf (stderr
, "relocs for sec %s\n", sec
->name
);
1403 for (k
= 0; k
< n
; k
++)
1405 arelent
*rel
= relocs
[k
];
1406 asymbol
*s
= *rel
->sym_ptr_ptr
;
1407 fprintf (stderr
, " reloc %2d @%p off %4lx : sym %-10s addend %lx\n",
1408 k
, rel
, (unsigned long)rel
->address
, s
->name
,
1409 (unsigned long)rel
->addend
);
1416 compress_frag (bool use_zstd
, void *ctx
, const char *contents
, int in_size
,
1417 fragS
**last_newf
, struct obstack
*ob
)
1420 int total_out_size
= 0;
1421 fragS
*f
= *last_newf
;
1425 /* Call the compression routine repeatedly until it has finished
1426 processing the frag. */
1429 /* Reserve all the space available in the current chunk.
1430 If none is available, start a new frag. */
1431 avail_out
= obstack_room (ob
);
1434 obstack_finish (ob
);
1435 f
= frag_alloc (ob
);
1436 f
->fr_type
= rs_fill
;
1437 (*last_newf
)->fr_next
= f
;
1439 avail_out
= obstack_room (ob
);
1442 as_fatal (_("can't extend frag"));
1443 next_out
= obstack_next_free (ob
);
1444 obstack_blank_fast (ob
, avail_out
);
1445 out_size
= compress_data (use_zstd
, ctx
, &contents
, &in_size
, &next_out
,
1450 f
->fr_fix
+= out_size
;
1451 total_out_size
+= out_size
;
1453 /* Return unused space. */
1455 obstack_blank_fast (ob
, -avail_out
);
1458 return total_out_size
;
1462 compress_debug (bfd
*abfd
, asection
*sec
, void *xxx ATTRIBUTE_UNUSED
)
1464 segment_info_type
*seginfo
= seg_info (sec
);
1465 bfd_size_type uncompressed_size
= sec
->size
;
1466 flagword flags
= bfd_section_flags (sec
);
1469 || uncompressed_size
< 32
1470 || (flags
& SEC_HAS_CONTENTS
) == 0)
1473 const char *section_name
= bfd_section_name (sec
);
1474 if (!startswith (section_name
, ".debug_")
1475 && !startswith (section_name
, ".gnu.debuglto_.debug_")
1476 && !startswith (section_name
, ".gnu.linkonce.wi."))
1479 bool use_zstd
= abfd
->flags
& BFD_COMPRESS_ZSTD
;
1480 void *ctx
= compress_init (use_zstd
);
1484 unsigned int header_size
;
1485 if ((abfd
->flags
& BFD_COMPRESS_GABI
) == 0)
1488 header_size
= bfd_get_compression_header_size (stdoutput
, NULL
);
1490 /* Create a new frag to contain the compression header. */
1491 struct obstack
*ob
= &seginfo
->frchainP
->frch_obstack
;
1492 fragS
*first_newf
= frag_alloc (ob
);
1493 if (obstack_room (ob
) < header_size
)
1494 first_newf
= frag_alloc (ob
);
1495 if (obstack_room (ob
) < header_size
)
1496 as_fatal (ngettext ("can't extend frag %lu char",
1497 "can't extend frag %lu chars",
1498 (unsigned long) header_size
),
1499 (unsigned long) header_size
);
1500 fragS
*last_newf
= first_newf
;
1501 obstack_blank_fast (ob
, header_size
);
1502 last_newf
->fr_type
= rs_fill
;
1503 last_newf
->fr_fix
= header_size
;
1504 char *header
= last_newf
->fr_literal
;
1505 bfd_size_type compressed_size
= header_size
;
1507 /* Stream the frags through the compression engine, adding new frags
1508 as necessary to accommodate the compressed output. */
1509 for (fragS
*f
= seginfo
->frchainP
->frch_root
;
1518 gas_assert (f
->fr_type
== rs_fill
);
1521 out_size
= compress_frag (use_zstd
, ctx
, f
->fr_literal
, f
->fr_fix
,
1525 compressed_size
+= out_size
;
1527 fill_literal
= f
->fr_literal
+ f
->fr_fix
;
1528 fill_size
= f
->fr_var
;
1529 count
= f
->fr_offset
;
1530 gas_assert (count
>= 0);
1531 if (fill_size
&& count
)
1535 out_size
= compress_frag (use_zstd
, ctx
, fill_literal
,
1536 (int)fill_size
, &last_newf
, ob
);
1539 compressed_size
+= out_size
;
1544 /* Flush the compression state. */
1551 /* Reserve all the space available in the current chunk.
1552 If none is available, start a new frag. */
1553 avail_out
= obstack_room (ob
);
1558 obstack_finish (ob
);
1559 newf
= frag_alloc (ob
);
1560 newf
->fr_type
= rs_fill
;
1561 last_newf
->fr_next
= newf
;
1563 avail_out
= obstack_room (ob
);
1566 as_fatal (_("can't extend frag"));
1567 next_out
= obstack_next_free (ob
);
1568 obstack_blank_fast (ob
, avail_out
);
1569 int x
= compress_finish (use_zstd
, ctx
, &next_out
, &avail_out
, &out_size
);
1573 last_newf
->fr_fix
+= out_size
;
1574 compressed_size
+= out_size
;
1576 /* Return unused space. */
1578 obstack_blank_fast (ob
, -avail_out
);
1584 /* PR binutils/18087: If compression didn't make the section smaller,
1585 just keep it uncompressed. */
1586 if (compressed_size
>= uncompressed_size
)
1589 /* Replace the uncompressed frag list with the compressed frag list. */
1590 seginfo
->frchainP
->frch_root
= first_newf
;
1591 seginfo
->frchainP
->frch_last
= last_newf
;
1593 /* Update the section size and its name. */
1594 bfd_update_compression_header (abfd
, (bfd_byte
*) header
, sec
);
1595 bool x
= bfd_set_section_size (sec
, compressed_size
);
1597 if ((abfd
->flags
& BFD_COMPRESS_GABI
) == 0
1598 && section_name
[1] == 'd')
1600 char *compressed_name
= bfd_debug_name_to_zdebug (abfd
, section_name
);
1601 bfd_rename_section (sec
, compressed_name
);
1605 #ifndef md_generate_nops
1606 /* Genenerate COUNT bytes of no-op instructions to WHERE. A target
1607 backend must override this with proper no-op instructions. */
1610 md_generate_nops (fragS
*f ATTRIBUTE_UNUSED
,
1611 char *where ATTRIBUTE_UNUSED
,
1612 offsetT count ATTRIBUTE_UNUSED
,
1613 int control ATTRIBUTE_UNUSED
)
1615 as_bad (_("unimplemented .nops directive"));
1620 write_contents (bfd
*abfd ATTRIBUTE_UNUSED
,
1622 void *xxx ATTRIBUTE_UNUSED
)
1624 segment_info_type
*seginfo
= seg_info (sec
);
1625 addressT offset
= 0;
1628 /* Write out the frags. */
1630 || !(bfd_section_flags (sec
) & SEC_HAS_CONTENTS
))
1633 for (f
= seginfo
->frchainP
->frch_root
;
1642 gas_assert (f
->fr_type
== rs_fill
|| f
->fr_type
== rs_fill_nop
);
1645 x
= bfd_set_section_contents (stdoutput
, sec
,
1646 f
->fr_literal
, (file_ptr
) offset
,
1647 (bfd_size_type
) f
->fr_fix
);
1649 as_fatal (ngettext ("can't write %ld byte "
1650 "to section %s of %s: '%s'",
1651 "can't write %ld bytes "
1652 "to section %s of %s: '%s'",
1655 bfd_section_name (sec
), bfd_get_filename (stdoutput
),
1656 bfd_errmsg (bfd_get_error ()));
1657 offset
+= f
->fr_fix
;
1660 fill_size
= f
->fr_var
;
1661 count
= f
->fr_offset
;
1662 fill_literal
= f
->fr_literal
+ f
->fr_fix
;
1664 if (f
->fr_type
== rs_fill_nop
)
1666 gas_assert (count
>= 0 && fill_size
== 1);
1669 char *buf
= xmalloc (count
);
1670 md_generate_nops (f
, buf
, count
, *fill_literal
);
1671 x
= bfd_set_section_contents
1672 (stdoutput
, sec
, buf
, (file_ptr
) offset
,
1673 (bfd_size_type
) count
);
1675 as_fatal (ngettext ("can't fill %ld byte "
1676 "in section %s of %s: '%s'",
1677 "can't fill %ld bytes "
1678 "in section %s of %s: '%s'",
1681 bfd_section_name (sec
),
1682 bfd_get_filename (stdoutput
),
1683 bfd_errmsg (bfd_get_error ()));
1686 if (listing
& LISTING_LISTING
)
1695 gas_assert (count
>= 0);
1696 if (fill_size
&& count
)
1699 if (fill_size
> sizeof (buf
))
1701 /* Do it the old way. Can this ever happen? */
1704 x
= bfd_set_section_contents (stdoutput
, sec
,
1707 (bfd_size_type
) fill_size
);
1709 as_fatal (ngettext ("can't fill %ld byte "
1710 "in section %s of %s: '%s'",
1711 "can't fill %ld bytes "
1712 "in section %s of %s: '%s'",
1715 bfd_section_name (sec
),
1716 bfd_get_filename (stdoutput
),
1717 bfd_errmsg (bfd_get_error ()));
1718 offset
+= fill_size
;
1723 /* Build a buffer full of fill objects and output it as
1724 often as necessary. This saves on the overhead of
1725 potentially lots of bfd_set_section_contents calls. */
1729 n_per_buf
= sizeof (buf
);
1730 memset (buf
, *fill_literal
, n_per_buf
);
1735 n_per_buf
= sizeof (buf
) / fill_size
;
1736 for (i
= n_per_buf
, bufp
= buf
; i
; i
--, bufp
+= fill_size
)
1737 memcpy (bufp
, fill_literal
, fill_size
);
1739 for (; count
> 0; count
-= n_per_buf
)
1741 n_per_buf
= n_per_buf
> count
? count
: n_per_buf
;
1742 x
= bfd_set_section_contents
1743 (stdoutput
, sec
, buf
, (file_ptr
) offset
,
1744 (bfd_size_type
) n_per_buf
* fill_size
);
1746 as_fatal (ngettext ("can't fill %ld byte "
1747 "in section %s of %s: '%s'",
1748 "can't fill %ld bytes "
1749 "in section %s of %s: '%s'",
1750 (long) (n_per_buf
* fill_size
)),
1751 (long) (n_per_buf
* fill_size
),
1752 bfd_section_name (sec
),
1753 bfd_get_filename (stdoutput
),
1754 bfd_errmsg (bfd_get_error ()));
1755 offset
+= n_per_buf
* fill_size
;
1763 merge_data_into_text (void)
1765 seg_info (text_section
)->frchainP
->frch_last
->fr_next
=
1766 seg_info (data_section
)->frchainP
->frch_root
;
1767 seg_info (text_section
)->frchainP
->frch_last
=
1768 seg_info (data_section
)->frchainP
->frch_last
;
1769 seg_info (data_section
)->frchainP
= 0;
1780 /* Count symbols. We can't rely on a count made by the loop in
1781 write_object_file, because *_frob_file may add a new symbol or
1782 two. Generate unused section symbols only if needed. */
1784 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
1785 if (!symbol_removed_p (symp
)
1786 && (bfd_keep_unused_section_symbols (stdoutput
)
1787 || !symbol_section_p (symp
)
1788 || symbol_used_in_reloc_p (symp
)))
1794 bfd_size_type amt
= (bfd_size_type
) nsyms
* sizeof (asymbol
*);
1796 asympp
= (asymbol
**) bfd_alloc (stdoutput
, amt
);
1797 symp
= symbol_rootP
;
1798 for (i
= 0; i
< nsyms
; symp
= symbol_next (symp
))
1799 if (!symbol_removed_p (symp
)
1800 && (bfd_keep_unused_section_symbols (stdoutput
)
1801 || !symbol_section_p (symp
)
1802 || symbol_used_in_reloc_p (symp
)))
1804 asympp
[i
] = symbol_get_bfdsym (symp
);
1805 if (asympp
[i
]->flags
!= BSF_SECTION_SYM
1806 || !(bfd_is_const_section (asympp
[i
]->section
)
1807 && asympp
[i
]->section
->symbol
== asympp
[i
]))
1808 asympp
[i
]->flags
|= BSF_KEEP
;
1809 symbol_mark_written (symp
);
1810 /* Include this section symbol in the symbol table. */
1811 if (symbol_section_p (symp
))
1812 asympp
[i
]->flags
|= BSF_SECTION_SYM_USED
;
1818 result
= bfd_set_symtab (stdoutput
, asympp
, nsyms
);
1819 gas_assert (result
);
1820 symbol_table_frozen
= 1;
1823 /* Finish the subsegments. After every sub-segment, we fake an
1824 ".align ...". This conforms to BSD4.2 brain-damage. We then fake
1825 ".fill 0" because that is the kind of frag that requires least
1826 thought. ".align" frags like to have a following frag since that
1827 makes calculating their intended length trivial. */
1829 #ifndef SUB_SEGMENT_ALIGN
1831 /* The last subsegment gets an alignment corresponding to the alignment
1832 of the section. This allows proper nop-filling at the end of
1833 code-bearing sections. */
1834 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \
1835 (!(FRCHAIN)->frch_next && subseg_text_p (SEG) \
1836 && !do_not_pad_sections_to_alignment \
1837 ? get_recorded_alignment (SEG) \
1840 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
1845 subsegs_finish_section (asection
*s
)
1847 struct frchain
*frchainP
;
1848 segment_info_type
*seginfo
= seg_info (s
);
1852 for (frchainP
= seginfo
->frchainP
;
1854 frchainP
= frchainP
->frch_next
)
1858 subseg_set (s
, frchainP
->frch_subseg
);
1860 /* This now gets called even if we had errors. In that case,
1861 any alignment is meaningless, and, moreover, will look weird
1862 if we are generating a listing. */
1864 do_not_pad_sections_to_alignment
= 1;
1866 alignment
= SUB_SEGMENT_ALIGN (now_seg
, frchainP
);
1867 if ((bfd_section_flags (now_seg
) & SEC_MERGE
)
1868 && now_seg
->entsize
)
1870 unsigned int entsize
= now_seg
->entsize
;
1873 while ((entsize
& 1) == 0)
1879 if (entalign
> alignment
)
1880 alignment
= entalign
;
1883 if (subseg_text_p (now_seg
))
1884 frag_align_code (alignment
, 0);
1886 frag_align (alignment
, 0, 0);
1888 /* frag_align will have left a new frag.
1889 Use this last frag for an empty ".fill".
1891 For this segment ...
1892 Create a last frag. Do not leave a "being filled in frag". */
1893 frag_wane (frag_now
);
1894 frag_now
->fr_fix
= 0;
1895 know (frag_now
->fr_next
== NULL
);
1900 subsegs_finish (void)
1904 for (s
= stdoutput
->sections
; s
; s
= s
->next
)
1905 subsegs_finish_section (s
);
1910 create_obj_attrs_section (void)
1917 size
= bfd_elf_obj_attr_size (stdoutput
);
1921 name
= get_elf_backend_data (stdoutput
)->obj_attrs_section
;
1923 name
= ".gnu.attributes";
1924 s
= subseg_new (name
, 0);
1925 elf_section_type (s
)
1926 = get_elf_backend_data (stdoutput
)->obj_attrs_section_type
;
1927 bfd_set_section_flags (s
, SEC_READONLY
| SEC_DATA
);
1929 p
= frag_more (size
);
1930 bfd_elf_set_obj_attr_contents (stdoutput
, (bfd_byte
*)p
, size
);
1932 subsegs_finish_section (s
);
1933 relax_segment (seg_info (s
)->frchainP
->frch_root
, s
, 0);
1934 size_seg (stdoutput
, s
, NULL
);
1937 /* Create a relocation against an entry in a GNU Build attribute section. */
1940 create_note_reloc (segT sec
,
1942 bfd_size_type note_offset
,
1943 bfd_size_type desc2_offset
,
1949 struct reloc_list
* reloc
;
1951 reloc
= XNEW (struct reloc_list
);
1953 /* We create a .b type reloc as resolve_reloc_expr_symbols() has already been called. */
1954 reloc
->u
.b
.sec
= sec
;
1955 reloc
->u
.b
.s
= symbol_get_bfdsym (sym
);
1956 reloc
->u
.b
.r
.sym_ptr_ptr
= & reloc
->u
.b
.s
;
1957 reloc
->u
.b
.r
.address
= note_offset
+ desc2_offset
;
1958 reloc
->u
.b
.r
.addend
= addend
;
1959 reloc
->u
.b
.r
.howto
= bfd_reloc_type_lookup (stdoutput
, reloc_type
);
1961 if (reloc
->u
.b
.r
.howto
== NULL
)
1963 as_bad (_("unable to create reloc for build note"));
1967 reloc
->file
= N_("<gnu build note>");
1970 reloc
->next
= reloc_list
;
1973 /* For REL relocs, store the addend in the section. */
1974 if (! sec
->use_rela_p
1975 /* The SH target is a special case that uses RELA relocs
1976 but still stores the addend in the word being relocated. */
1977 || strstr (bfd_get_target (stdoutput
), "-sh") != NULL
)
1981 /* Zero out the addend, since it is now stored in the note. */
1982 reloc
->u
.b
.r
.addend
= 0;
1984 if (target_big_endian
)
1986 for (i
= desc2_size
; addend
!= 0 && i
> 0; addend
>>= 8, i
--)
1987 note
[desc2_offset
+ i
- 1] = (addend
& 0xff);
1991 for (i
= 0; addend
!= 0 && i
< desc2_size
; addend
>>= 8, i
++)
1992 note
[desc2_offset
+ i
] = (addend
& 0xff);
1998 maybe_generate_build_notes (void)
2005 offsetT desc2_offset
;
2010 if (! flag_generate_build_notes
2011 || bfd_get_section_by_name (stdoutput
,
2012 GNU_BUILD_ATTRS_SECTION_NAME
) != NULL
)
2015 /* Create a GNU Build Attribute section. */
2016 sec
= subseg_new (GNU_BUILD_ATTRS_SECTION_NAME
, false);
2017 elf_section_type (sec
) = SHT_NOTE
;
2018 bfd_set_section_flags (sec
, (SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_DATA
2020 bfd_set_section_alignment (sec
, 2);
2022 /* Work out the size of the notes that we will create,
2023 and the relocation we should use. */
2024 if (bfd_arch_bits_per_address (stdoutput
) <= 32)
2027 desc_size
= 8; /* Two 4-byte offsets. */
2030 /* FIXME: The BFD backend for the CRX target does not support the
2031 BFD_RELOC_32, even though it really should. Likewise for the
2032 CR16 target. So we have special case code here... */
2033 if (strstr (bfd_get_target (stdoutput
), "-crx") != NULL
)
2034 desc_reloc
= BFD_RELOC_CRX_NUM32
;
2035 else if (strstr (bfd_get_target (stdoutput
), "-cr16") != NULL
)
2036 desc_reloc
= BFD_RELOC_CR16_NUM32
;
2038 desc_reloc
= BFD_RELOC_32
;
2043 desc_size
= 16; /* Two 8-byte offsets. */
2045 /* FIXME: The BFD backend for the IA64 target does not support the
2046 BFD_RELOC_64, even though it really should. The HPPA backend
2047 has a similar issue, although it does not support BFD_RELOCs at
2048 all! So we have special case code to handle these targets. */
2049 if (strstr (bfd_get_target (stdoutput
), "-ia64") != NULL
)
2050 desc_reloc
= target_big_endian
? BFD_RELOC_IA64_DIR32MSB
: BFD_RELOC_IA64_DIR32LSB
;
2051 else if (strstr (bfd_get_target (stdoutput
), "-hppa") != NULL
)
2052 desc_reloc
= 80; /* R_PARISC_DIR64. */
2054 desc_reloc
= BFD_RELOC_64
;
2057 /* We have to create a note for *each* code section.
2058 Linker garbage collection might discard some. */
2062 for (sym
= symbol_rootP
; sym
!= NULL
; sym
= symbol_next (sym
))
2063 if ((bsym
= symbol_get_bfdsym (sym
)) != NULL
2064 && bsym
->flags
& BSF_SECTION_SYM
2065 && bsym
->section
!= NULL
2066 /* Skip linkonce sections - we cannot use these section symbols as they may disappear. */
2067 && (bsym
->section
->flags
& (SEC_CODE
| SEC_LINK_ONCE
)) == SEC_CODE
2068 /* Not all linkonce sections are flagged... */
2069 && !startswith (S_GET_NAME (sym
), ".gnu.linkonce"))
2071 /* Create a version note. */
2073 note
= frag_more (note_size
);
2074 memset (note
, 0, note_size
);
2076 if (target_big_endian
)
2078 note
[3] = 8; /* strlen (name) + 1. */
2079 note
[7] = desc_size
; /* Two N-byte offsets. */
2080 note
[10] = NT_GNU_BUILD_ATTRIBUTE_OPEN
>> 8;
2081 note
[11] = NT_GNU_BUILD_ATTRIBUTE_OPEN
& 0xff;
2085 note
[0] = 8; /* strlen (name) + 1. */
2086 note
[4] = desc_size
; /* Two N-byte offsets. */
2087 note
[8] = NT_GNU_BUILD_ATTRIBUTE_OPEN
& 0xff;
2088 note
[9] = NT_GNU_BUILD_ATTRIBUTE_OPEN
>> 8;
2091 /* The a1 version number indicates that this note was
2092 generated by the assembler and not the gcc annobin plugin. */
2093 memcpy (note
+ 12, "GA$\x013a1", 8);
2095 /* Create a relocation to install the start address of the note... */
2096 create_note_reloc (sec
, sym
, total_size
, 20, desc_size
/ 2, desc_reloc
, 0, note
);
2098 /* ...and another one to install the end address. */
2099 create_note_reloc (sec
, sym
, total_size
, desc2_offset
,
2102 bfd_section_size (bsym
->section
),
2105 /* Mark the section symbol used in relocation so that it will be
2106 included in the symbol table. */
2107 symbol_mark_used_in_reloc (sym
);
2109 total_size
+= note_size
;
2110 /* FIXME: Maybe add a note recording the assembler command line and version ? */
2113 /* Install the note(s) into the section. */
2115 bfd_set_section_contents (stdoutput
, sec
, (bfd_byte
*) note
, 0, total_size
);
2116 subsegs_finish_section (sec
);
2117 relax_segment (seg_info (sec
)->frchainP
->frch_root
, sec
, 0);
2118 size_seg (stdoutput
, sec
, NULL
);
2120 #endif /* OBJ_ELF */
2122 /* Write the object file. */
2125 write_object_file (void)
2127 struct relax_seg_info rsi
;
2128 #ifndef WORKING_DOT_WORD
2129 fragS
*fragP
; /* Track along all frags. */
2134 #ifdef md_pre_output_hook
2138 #ifdef md_pre_relax_hook
2142 /* From now on, we don't care about sub-segments. Build one frag chain
2143 for each segment. Linked through fr_next. */
2145 /* Remove the sections created by gas for its own purposes. */
2149 bfd_section_list_remove (stdoutput
, reg_section
);
2150 bfd_section_list_remove (stdoutput
, expr_section
);
2151 stdoutput
->section_count
-= 2;
2153 bfd_map_over_sections (stdoutput
, renumber_sections
, &i
);
2156 bfd_map_over_sections (stdoutput
, chain_frchains_together
, (char *) 0);
2158 /* We have two segments. If user gave -R flag, then we must put the
2159 data frags into the text segment. Do this before relaxing so
2160 we know to take advantage of -R and make shorter addresses. */
2161 if (flag_readonly_data_in_text
)
2163 merge_data_into_text ();
2169 #ifndef WORKING_DOT_WORD
2170 /* We need to reset the markers in the broken word list and
2171 associated frags between calls to relax_segment (via
2172 relax_seg). Since the broken word list is global, we do it
2173 once per round, rather than locally in relax_segment for each
2175 struct broken_word
*brokp
;
2177 for (brokp
= broken_words
;
2178 brokp
!= (struct broken_word
*) NULL
;
2179 brokp
= brokp
->next_broken_word
)
2183 if (brokp
->dispfrag
!= (fragS
*) NULL
2184 && brokp
->dispfrag
->fr_type
== rs_broken_word
)
2185 brokp
->dispfrag
->fr_subtype
= 0;
2190 bfd_map_over_sections (stdoutput
, relax_seg
, &rsi
);
2196 /* Note - Most ports will use the default value of
2197 TC_FINALIZE_SYMS_BEFORE_SIZE_SEG, which 1. This will force
2198 local symbols to be resolved, removing their frag information.
2199 Some ports however, will not have finished relaxing all of
2200 their frags and will still need the local symbol frag
2201 information. These ports can set
2202 TC_FINALIZE_SYMS_BEFORE_SIZE_SEG to 0. */
2203 finalize_syms
= TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
;
2205 bfd_map_over_sections (stdoutput
, size_seg
, (char *) 0);
2207 /* Relaxation has completed. Freeze all syms. */
2210 dwarf2dbg_final_check ();
2212 #ifdef md_post_relax_hook
2218 create_obj_attrs_section ();
2221 #ifndef WORKING_DOT_WORD
2223 struct broken_word
*lie
;
2224 struct broken_word
**prevP
;
2226 prevP
= &broken_words
;
2227 for (lie
= broken_words
; lie
; lie
= lie
->next_broken_word
)
2232 subseg_change (lie
->seg
, lie
->subseg
);
2233 exp
.X_op
= O_subtract
;
2234 exp
.X_add_symbol
= lie
->add
;
2235 exp
.X_op_symbol
= lie
->sub
;
2236 exp
.X_add_number
= lie
->addnum
;
2237 #ifdef TC_CONS_FIX_NEW
2238 TC_CONS_FIX_NEW (lie
->frag
,
2239 lie
->word_goes_here
- lie
->frag
->fr_literal
,
2240 2, &exp
, TC_PARSE_CONS_RETURN_NONE
);
2242 fix_new_exp (lie
->frag
,
2243 lie
->word_goes_here
- lie
->frag
->fr_literal
,
2244 2, &exp
, 0, BFD_RELOC_16
);
2246 *prevP
= lie
->next_broken_word
;
2249 prevP
= &(lie
->next_broken_word
);
2251 for (lie
= broken_words
; lie
;)
2253 struct broken_word
*untruth
;
2255 addressT table_addr
;
2256 addressT from_addr
, to_addr
;
2259 subseg_change (lie
->seg
, lie
->subseg
);
2260 fragP
= lie
->dispfrag
;
2262 /* Find out how many broken_words go here. */
2265 untruth
&& untruth
->dispfrag
== fragP
;
2266 untruth
= untruth
->next_broken_word
)
2267 if (untruth
->added
== 1)
2270 table_ptr
= lie
->dispfrag
->fr_opcode
;
2271 table_addr
= (lie
->dispfrag
->fr_address
2272 + (table_ptr
- lie
->dispfrag
->fr_literal
));
2273 /* Create the jump around the long jumps. This is a short
2274 jump from table_ptr+0 to table_ptr+n*long_jump_size. */
2275 from_addr
= table_addr
;
2276 to_addr
= table_addr
+ md_short_jump_size
+ n
* md_long_jump_size
;
2277 md_create_short_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
,
2279 table_ptr
+= md_short_jump_size
;
2280 table_addr
+= md_short_jump_size
;
2283 lie
&& lie
->dispfrag
== fragP
;
2284 m
++, lie
= lie
->next_broken_word
)
2286 if (lie
->added
== 2)
2288 /* Patch the jump table. */
2289 for (untruth
= (struct broken_word
*) (fragP
->fr_symbol
);
2290 untruth
&& untruth
->dispfrag
== fragP
;
2291 untruth
= untruth
->next_broken_word
)
2293 if (untruth
->use_jump
== lie
)
2295 /* This is the offset from ??? to table_ptr+0.
2296 The target is the same for all users of this
2297 md_long_jump, but the "sub" bases (and hence the
2298 offsets) may be different. */
2299 addressT to_word
= table_addr
- S_GET_VALUE (untruth
->sub
);
2300 #ifdef TC_CHECK_ADJUSTED_BROKEN_DOT_WORD
2301 TC_CHECK_ADJUSTED_BROKEN_DOT_WORD (to_word
, untruth
);
2303 md_number_to_chars (untruth
->word_goes_here
, to_word
, 2);
2307 /* Install the long jump. */
2308 /* This is a long jump from table_ptr+0 to the final target. */
2309 from_addr
= table_addr
;
2310 to_addr
= S_GET_VALUE (lie
->add
) + lie
->addnum
;
2311 md_create_long_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
,
2313 table_ptr
+= md_long_jump_size
;
2314 table_addr
+= md_long_jump_size
;
2318 #endif /* not WORKING_DOT_WORD */
2320 /* Resolve symbol values. This needs to be done before processing
2326 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
2327 resolve_symbol_value (symp
);
2329 resolve_local_symbol_values ();
2330 resolve_reloc_expr_symbols ();
2334 maybe_generate_build_notes ();
2337 #ifdef tc_frob_file_before_adjust
2338 tc_frob_file_before_adjust ();
2340 #ifdef obj_frob_file_before_adjust
2341 obj_frob_file_before_adjust ();
2344 bfd_map_over_sections (stdoutput
, adjust_reloc_syms
, (char *) 0);
2346 #ifdef tc_frob_file_before_fix
2347 tc_frob_file_before_fix ();
2349 #ifdef obj_frob_file_before_fix
2350 obj_frob_file_before_fix ();
2353 bfd_map_over_sections (stdoutput
, fix_segment
, (char *) 0);
2355 /* Set up symbol table, and write it out. */
2359 bool skip_next_symbol
= false;
2361 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
2366 if (skip_next_symbol
)
2368 /* Don't do anything besides moving the value of the
2369 symbol from the GAS value-field to the BFD value-field. */
2370 symbol_get_bfdsym (symp
)->value
= S_GET_VALUE (symp
);
2371 skip_next_symbol
= false;
2375 if (symbol_mri_common_p (symp
))
2377 if (S_IS_EXTERNAL (symp
))
2378 as_bad (_("%s: global symbols not supported in common sections"),
2380 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
2384 name
= S_GET_NAME (symp
);
2388 decode_local_label_name ((char *) S_GET_NAME (symp
));
2389 /* They only differ if `name' is a fb or dollar local
2391 if (name2
!= name
&& ! S_IS_DEFINED (symp
))
2392 as_bad (_("local label `%s' is not defined"), name2
);
2395 /* Do it again, because adjust_reloc_syms might introduce
2396 more symbols. They'll probably only be section symbols,
2397 but they'll still need to have the values computed. */
2398 resolve_symbol_value (symp
);
2400 /* Skip symbols which were equated to undefined or common
2402 if (symbol_equated_reloc_p (symp
)
2403 || S_IS_WEAKREFR (symp
))
2405 const char *sname
= S_GET_NAME (symp
);
2407 if (S_IS_COMMON (symp
)
2408 && !TC_FAKE_LABEL (sname
)
2409 && !S_IS_WEAKREFR (symp
))
2411 expressionS
*e
= symbol_get_value_expression (symp
);
2413 as_bad (_("`%s' can't be equated to common symbol `%s'"),
2414 sname
, S_GET_NAME (e
->X_add_symbol
));
2416 if (S_GET_SEGMENT (symp
) == reg_section
)
2418 /* Report error only if we know the symbol name. */
2419 if (S_GET_NAME (symp
) != reg_section
->name
)
2420 as_bad (_("can't make global register symbol `%s'"),
2423 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
2427 #ifdef obj_frob_symbol
2428 obj_frob_symbol (symp
, punt
);
2430 #ifdef tc_frob_symbol
2431 if (! punt
|| symbol_used_in_reloc_p (symp
))
2432 tc_frob_symbol (symp
, punt
);
2435 /* If we don't want to keep this symbol, splice it out of
2436 the chain now. If EMIT_SECTION_SYMBOLS is 0, we never
2437 want section symbols. Otherwise, we skip local symbols
2438 and symbols that the frob_symbol macros told us to punt,
2439 but we keep such symbols if they are used in relocs. */
2440 if (symp
== abs_section_sym
2441 || (! EMIT_SECTION_SYMBOLS
2442 && symbol_section_p (symp
))
2443 /* Note that S_IS_EXTERNAL and S_IS_LOCAL are not always
2444 opposites. Sometimes the former checks flags and the
2445 latter examines the name... */
2446 || (!S_IS_EXTERNAL (symp
)
2447 && (punt
|| S_IS_LOCAL (symp
) ||
2448 (S_IS_WEAKREFD (symp
) && ! symbol_used_p (symp
)))
2449 && ! symbol_used_in_reloc_p (symp
)))
2451 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
2453 /* After symbol_remove, symbol_next(symp) still returns
2454 the one that came after it in the chain. So we don't
2455 need to do any extra cleanup work here. */
2459 /* Make sure we really got a value for the symbol. */
2460 if (! symbol_resolved_p (symp
))
2462 as_bad (_("can't resolve value for symbol `%s'"),
2464 symbol_mark_resolved (symp
);
2467 /* Set the value into the BFD symbol. Up til now the value
2468 has only been kept in the gas symbolS struct. */
2469 symbol_get_bfdsym (symp
)->value
= S_GET_VALUE (symp
);
2471 /* A warning construct is a warning symbol followed by the
2472 symbol warned about. Don't let anything object-format or
2473 target-specific muck with it; it's ready for output. */
2474 if (symbol_get_bfdsym (symp
)->flags
& BSF_WARNING
)
2475 skip_next_symbol
= true;
2479 /* Now do any format-specific adjustments to the symbol table, such
2480 as adding file symbols. */
2481 #ifdef tc_adjust_symtab
2482 tc_adjust_symtab ();
2484 #ifdef obj_adjust_symtab
2485 obj_adjust_symtab ();
2488 /* Stop if there is an error. */
2489 if (!flag_always_generate_output
&& had_errors ())
2492 /* Now that all the sizes are known, and contents correct, we can
2493 start writing to the file. */
2496 /* If *_frob_file changes the symbol value at this point, it is
2497 responsible for moving the changed value into symp->bsym->value
2498 as well. Hopefully all symbol value changing can be done in
2503 #ifdef obj_frob_file
2506 #ifdef obj_coff_generate_pdata
2507 obj_coff_generate_pdata ();
2510 bfd_map_over_sections (stdoutput
, write_relocs
, (char *) 0);
2512 #ifdef tc_frob_file_after_relocs
2513 tc_frob_file_after_relocs ();
2515 #ifdef obj_frob_file_after_relocs
2516 obj_frob_file_after_relocs ();
2519 #if defined OBJ_ELF || defined OBJ_MAYBE_ELF
2520 if (IS_ELF
&& flag_use_elf_stt_common
)
2521 stdoutput
->flags
|= BFD_CONVERT_ELF_COMMON
| BFD_USE_ELF_STT_COMMON
;
2524 /* Once all relocations have been written, we can compress the
2525 contents of the debug sections. This needs to be done before
2526 we start writing any sections, because it will affect the file
2527 layout, which is fixed once we start writing contents. */
2528 if (flag_compress_debug
!= COMPRESS_DEBUG_NONE
)
2530 flagword flags
= BFD_COMPRESS
;
2531 if (flag_compress_debug
== COMPRESS_DEBUG_GABI_ZLIB
)
2532 flags
= BFD_COMPRESS
| BFD_COMPRESS_GABI
;
2533 else if (flag_compress_debug
== COMPRESS_DEBUG_ZSTD
)
2534 flags
= BFD_COMPRESS
| BFD_COMPRESS_GABI
| BFD_COMPRESS_ZSTD
;
2535 stdoutput
->flags
|= flags
& bfd_applicable_file_flags (stdoutput
);
2536 if ((stdoutput
->flags
& BFD_COMPRESS
) != 0)
2537 bfd_map_over_sections (stdoutput
, compress_debug
, (char *) 0);
2540 bfd_map_over_sections (stdoutput
, write_contents
, (char *) 0);
2543 #ifdef TC_GENERIC_RELAX_TABLE
2544 #ifndef md_generic_table_relax_frag
2545 #define md_generic_table_relax_frag relax_frag
2548 /* Relax a fragment by scanning TC_GENERIC_RELAX_TABLE. */
2551 relax_frag (segT segment
, fragS
*fragP
, long stretch
)
2553 const relax_typeS
*this_type
;
2554 const relax_typeS
*start_type
;
2555 relax_substateT next_state
;
2556 relax_substateT this_state
;
2562 const relax_typeS
*table
;
2564 target
= fragP
->fr_offset
;
2565 address
= fragP
->fr_address
+ fragP
->fr_fix
;
2566 table
= TC_GENERIC_RELAX_TABLE
;
2567 this_state
= fragP
->fr_subtype
;
2568 start_type
= this_type
= table
+ this_state
;
2569 symbolP
= fragP
->fr_symbol
;
2575 sym_frag
= symbol_get_frag (symbolP
);
2577 #ifndef DIFF_EXPR_OK
2578 know (sym_frag
!= NULL
);
2580 know (S_GET_SEGMENT (symbolP
) != absolute_section
2581 || sym_frag
== &zero_address_frag
);
2582 target
+= S_GET_VALUE (symbolP
);
2584 /* If SYM_FRAG has yet to be reached on this pass, assume it
2585 will move by STRETCH just as we did, unless there is an
2586 alignment frag between here and SYM_FRAG. An alignment may
2587 well absorb any STRETCH, and we don't want to choose a larger
2588 branch insn by overestimating the needed reach of this
2589 branch. It isn't critical to calculate TARGET exactly; We
2590 know we'll be doing another pass if STRETCH is non-zero. */
2593 && sym_frag
->relax_marker
!= fragP
->relax_marker
2594 && S_GET_SEGMENT (symbolP
) == segment
)
2597 || sym_frag
->region
== fragP
->region
)
2599 /* If we get here we know we have a forward branch. This
2600 relax pass may have stretched previous instructions so
2601 far that omitting STRETCH would make the branch
2602 negative. Don't allow this in case the negative reach is
2603 large enough to require a larger branch instruction. */
2604 else if (target
< address
)
2609 aim
= target
- address
;
2610 #ifdef TC_PCREL_ADJUST
2611 /* Currently only the ns32k and arc needs this. */
2612 aim
+= TC_PCREL_ADJUST (fragP
);
2615 #ifdef md_prepare_relax_scan
2616 /* Formerly called M68K_AIM_KLUDGE. */
2617 md_prepare_relax_scan (fragP
, address
, aim
, this_state
, this_type
);
2622 /* Look backwards. */
2623 for (next_state
= this_type
->rlx_more
; next_state
;)
2624 if (aim
>= this_type
->rlx_backward
)
2628 /* Grow to next state. */
2629 this_state
= next_state
;
2630 this_type
= table
+ this_state
;
2631 next_state
= this_type
->rlx_more
;
2636 /* Look forwards. */
2637 for (next_state
= this_type
->rlx_more
; next_state
;)
2638 if (aim
<= this_type
->rlx_forward
)
2642 /* Grow to next state. */
2643 this_state
= next_state
;
2644 this_type
= table
+ this_state
;
2645 next_state
= this_type
->rlx_more
;
2649 growth
= this_type
->rlx_length
- start_type
->rlx_length
;
2651 fragP
->fr_subtype
= this_state
;
2655 #endif /* defined (TC_GENERIC_RELAX_TABLE) */
2657 /* Relax_align. Advance location counter to next address that has 'alignment'
2658 lowest order bits all 0s, return size of adjustment made. */
2659 static relax_addressT
2660 relax_align (relax_addressT address
, /* Address now. */
2661 int alignment
/* Alignment (binary). */)
2663 relax_addressT mask
;
2664 relax_addressT new_address
;
2666 mask
= ~((relax_addressT
) ~0 << alignment
);
2667 new_address
= (address
+ mask
) & (~mask
);
2668 #ifdef LINKER_RELAXING_SHRINKS_ONLY
2670 /* We must provide lots of padding, so the linker can discard it
2671 when needed. The linker will not add extra space, ever. */
2672 new_address
+= (1 << alignment
);
2674 return (new_address
- address
);
2677 /* Now we have a segment, not a crowd of sub-segments, we can make
2682 After this, all frags in this segment have addresses that are correct
2683 within the segment. Since segments live in different file addresses,
2684 these frag addresses may not be the same as final object-file
2688 relax_segment (struct frag
*segment_frag_root
, segT segment
, int pass
)
2690 unsigned long frag_count
;
2692 relax_addressT address
;
2696 /* In case md_estimate_size_before_relax() wants to make fixSs. */
2697 subseg_change (segment
, 0);
2699 /* For each frag in segment: count and store (a 1st guess of)
2703 for (frag_count
= 0, fragP
= segment_frag_root
;
2705 fragP
= fragP
->fr_next
, frag_count
++)
2707 fragP
->region
= region
;
2708 fragP
->relax_marker
= 0;
2709 fragP
->fr_address
= address
;
2710 address
+= fragP
->fr_fix
;
2712 switch (fragP
->fr_type
)
2715 address
+= fragP
->fr_offset
* fragP
->fr_var
;
2722 addressT offset
= relax_align (address
, (int) fragP
->fr_offset
);
2724 if (fragP
->fr_subtype
!= 0 && offset
> fragP
->fr_subtype
)
2727 if (offset
% fragP
->fr_var
!= 0)
2729 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
2730 ngettext ("alignment padding (%lu byte) "
2731 "not a multiple of %ld",
2732 "alignment padding (%lu bytes) "
2733 "not a multiple of %ld",
2734 (unsigned long) offset
),
2735 (unsigned long) offset
, (long) fragP
->fr_var
);
2736 offset
-= (offset
% fragP
->fr_var
);
2745 /* Assume .org is nugatory. It will grow with 1st relax. */
2753 case rs_machine_dependent
:
2754 /* If fr_symbol is an expression, this call to
2755 resolve_symbol_value sets up the correct segment, which will
2756 likely be needed in md_estimate_size_before_relax. */
2757 if (fragP
->fr_symbol
)
2758 resolve_symbol_value (fragP
->fr_symbol
);
2760 address
+= md_estimate_size_before_relax (fragP
, segment
);
2763 #ifndef WORKING_DOT_WORD
2764 /* Broken words don't concern us yet. */
2765 case rs_broken_word
:
2770 /* Initial guess is always 1; doing otherwise can result in
2771 stable solutions that are larger than the minimum. */
2772 address
+= fragP
->fr_offset
= 1;
2776 address
+= eh_frame_estimate_size_before_relax (fragP
);
2780 address
+= dwarf2dbg_estimate_size_before_relax (fragP
);
2784 /* Initial estimate can be set to atleast 1 byte. */
2785 address
+= sframe_estimate_size_before_relax (fragP
);
2789 BAD_CASE (fragP
->fr_type
);
2796 unsigned long max_iterations
;
2798 /* Cumulative address adjustment. */
2801 /* Have we made any adjustment this pass? We can't just test
2802 stretch because one piece of code may have grown and another
2806 /* Most horrible, but gcc may give us some exception data that
2807 is impossible to assemble, of the form
2811 .uleb128 end - start
2817 If the leb128 is two bytes in size, then end-start is 128*128,
2818 which requires a three byte leb128. If the leb128 is three
2819 bytes in size, then end-start is 128*128-1, which requires a
2820 two byte leb128. We work around this dilemma by inserting
2821 an extra 4 bytes of alignment just after the .align. This
2822 works because the data after the align is accessed relative to
2825 This counter is used in a tiny state machine to detect
2826 whether a leb128 followed by an align is impossible to
2828 int rs_leb128_fudge
= 0;
2830 /* We want to prevent going into an infinite loop where one frag grows
2831 depending upon the location of a symbol which is in turn moved by
2832 the growing frag. eg:
2838 So we dictate that this algorithm can be at most O2. */
2839 max_iterations
= frag_count
* frag_count
;
2840 /* Check for overflow. */
2841 if (max_iterations
< frag_count
)
2842 max_iterations
= frag_count
;
2850 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
2853 addressT was_address
;
2857 fragP
->relax_marker
^= 1;
2858 was_address
= fragP
->fr_address
;
2859 address
= fragP
->fr_address
+= stretch
;
2860 symbolP
= fragP
->fr_symbol
;
2861 offset
= fragP
->fr_offset
;
2863 switch (fragP
->fr_type
)
2865 case rs_fill
: /* .fill never relaxes. */
2869 #ifndef WORKING_DOT_WORD
2870 /* JF: This is RMS's idea. I do *NOT* want to be blamed
2871 for it I do not want to write it. I do not want to have
2872 anything to do with it. This is not the proper way to
2873 implement this misfeature. */
2874 case rs_broken_word
:
2876 struct broken_word
*lie
;
2877 struct broken_word
*untruth
;
2879 /* Yes this is ugly (storing the broken_word pointer
2880 in the symbol slot). Still, this whole chunk of
2881 code is ugly, and I don't feel like doing anything
2882 about it. Think of it as stubbornness in action. */
2884 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
2885 lie
&& lie
->dispfrag
== fragP
;
2886 lie
= lie
->next_broken_word
)
2892 offset
= (S_GET_VALUE (lie
->add
)
2894 - S_GET_VALUE (lie
->sub
));
2895 if (offset
<= -32768 || offset
>= 32767)
2897 if (flag_warn_displacement
)
2901 bfd_sprintf_vma (stdoutput
, buf
,
2902 (addressT
) lie
->addnum
);
2903 as_warn_where (fragP
->fr_file
, fragP
->fr_line
,
2904 _(".word %s-%s+%s didn't fit"),
2905 S_GET_NAME (lie
->add
),
2906 S_GET_NAME (lie
->sub
),
2909 if (fragP
->fr_subtype
== 0)
2911 fragP
->fr_subtype
++;
2912 growth
+= md_short_jump_size
;
2915 /* Redirect *all* words of this table with the same
2916 target, lest we have to handle the case where the
2917 same target but with a offset that fits on this
2918 round overflows at the next relaxation round. */
2919 for (untruth
= (struct broken_word
*) (fragP
->fr_symbol
);
2920 untruth
&& untruth
->dispfrag
== lie
->dispfrag
;
2921 untruth
= untruth
->next_broken_word
)
2922 if ((symbol_get_frag (untruth
->add
)
2923 == symbol_get_frag (lie
->add
))
2924 && (S_GET_VALUE (untruth
->add
)
2925 == S_GET_VALUE (lie
->add
)))
2928 untruth
->use_jump
= lie
;
2932 growth
+= md_long_jump_size
;
2937 } /* case rs_broken_word */
2943 addressT oldoff
, newoff
;
2945 oldoff
= relax_align (was_address
+ fragP
->fr_fix
,
2947 newoff
= relax_align (address
+ fragP
->fr_fix
,
2950 if (fragP
->fr_subtype
!= 0)
2952 if (oldoff
> fragP
->fr_subtype
)
2954 if (newoff
> fragP
->fr_subtype
)
2958 growth
= newoff
- oldoff
;
2960 /* If this align happens to follow a leb128 and
2961 we have determined that the leb128 is bouncing
2962 in size, then break the cycle by inserting an
2965 && (rs_leb128_fudge
& 16) != 0
2966 && (rs_leb128_fudge
& 15) >= 2)
2968 segment_info_type
*seginfo
= seg_info (segment
);
2969 struct obstack
*ob
= &seginfo
->frchainP
->frch_obstack
;
2972 newf
= frag_alloc (ob
);
2973 obstack_blank_fast (ob
, fragP
->fr_var
);
2974 obstack_finish (ob
);
2975 memcpy (newf
, fragP
, SIZEOF_STRUCT_FRAG
);
2976 memcpy (newf
->fr_literal
,
2977 fragP
->fr_literal
+ fragP
->fr_fix
,
2979 newf
->fr_type
= rs_fill
;
2980 newf
->fr_address
= address
+ fragP
->fr_fix
+ newoff
;
2982 newf
->fr_offset
= (((offsetT
) 1 << fragP
->fr_offset
)
2984 if (newf
->fr_offset
* newf
->fr_var
2985 != (offsetT
) 1 << fragP
->fr_offset
)
2987 newf
->fr_offset
= (offsetT
) 1 << fragP
->fr_offset
;
2990 /* Include size of new frag in GROWTH. */
2991 growth
+= newf
->fr_offset
* newf
->fr_var
;
2992 /* Adjust the new frag address for the amount
2993 we'll add when we process the new frag. */
2994 newf
->fr_address
-= stretch
+ growth
;
2995 newf
->relax_marker
^= 1;
2996 fragP
->fr_next
= newf
;
2998 as_warn (_("padding added"));
3006 offsetT target
= offset
;
3011 /* Convert from an actual address to an octet offset
3012 into the section. Here it is assumed that the
3013 section's VMA is zero, and can omit subtracting it
3014 from the symbol's value to get the address offset. */
3015 know (S_GET_SEGMENT (symbolP
)->vma
== 0);
3016 target
+= S_GET_VALUE (symbolP
) * OCTETS_PER_BYTE
;
3019 know (fragP
->fr_next
);
3020 after
= fragP
->fr_next
->fr_address
+ stretch
;
3021 growth
= target
- after
;
3023 /* Growth may be negative, but variable part of frag
3024 cannot have fewer than 0 chars. That is, we can't
3026 if ((offsetT
) (address
+ fragP
->fr_fix
) > target
)
3030 /* Don't error on first few frag relax passes.
3031 The symbol might be an expression involving
3032 symbol values from other sections. If those
3033 sections have not yet been processed their
3034 frags will all have zero addresses, so we
3035 will calculate incorrect values for them. The
3036 number of passes we allow before giving an
3037 error is somewhat arbitrary. It should be at
3038 least one, with larger values requiring
3039 increasingly contrived dependencies between
3040 frags to trigger a false error. */
3043 /* Force another pass. */
3048 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
3049 _("attempt to move .org backwards"));
3051 /* We've issued an error message. Change the
3052 frag to avoid cascading errors. */
3053 fragP
->fr_type
= rs_align
;
3054 fragP
->fr_subtype
= 0;
3055 fragP
->fr_offset
= 0;
3056 fragP
->fr_fix
= after
- address
;
3068 amount
= S_GET_VALUE (symbolP
);
3069 if (S_GET_SEGMENT (symbolP
) != absolute_section
3070 || S_IS_COMMON (symbolP
)
3071 || ! S_IS_DEFINED (symbolP
))
3073 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
3074 _(".space, .nops or .fill specifies non-absolute value"));
3075 /* Prevent repeat of this error message. */
3076 fragP
->fr_symbol
= 0;
3078 else if (amount
< 0)
3080 /* Don't error on first few frag relax passes.
3081 See rs_org comment for a longer explanation. */
3088 as_warn_where (fragP
->fr_file
, fragP
->fr_line
,
3089 _(".space, .nops or .fill with negative value, ignored"));
3090 fragP
->fr_symbol
= 0;
3093 growth
= (was_address
+ fragP
->fr_fix
+ amount
3094 - fragP
->fr_next
->fr_address
);
3098 case rs_machine_dependent
:
3099 #ifdef md_relax_frag
3100 growth
= md_relax_frag (segment
, fragP
, stretch
);
3102 #ifdef TC_GENERIC_RELAX_TABLE
3103 /* The default way to relax a frag is to look through
3104 TC_GENERIC_RELAX_TABLE. */
3105 growth
= md_generic_table_relax_frag (segment
, fragP
,
3107 #endif /* TC_GENERIC_RELAX_TABLE */
3116 value
= resolve_symbol_value (fragP
->fr_symbol
);
3117 size
= sizeof_leb128 (value
, fragP
->fr_subtype
);
3118 growth
= size
- fragP
->fr_offset
;
3119 fragP
->fr_offset
= size
;
3124 growth
= eh_frame_relax_frag (fragP
);
3128 growth
= dwarf2dbg_relax_frag (fragP
);
3132 growth
= sframe_relax_frag (fragP
);
3136 BAD_CASE (fragP
->fr_type
);
3143 if (fragP
->fr_type
== rs_leb128
)
3144 rs_leb128_fudge
+= 16;
3145 else if (fragP
->fr_type
== rs_align
3146 && (rs_leb128_fudge
& 16) != 0
3148 rs_leb128_fudge
+= 16;
3150 rs_leb128_fudge
= 0;
3155 && (rs_leb128_fudge
& 16) == 0
3156 && (rs_leb128_fudge
& -16) != 0)
3157 rs_leb128_fudge
+= 1;
3159 rs_leb128_fudge
= 0;
3161 /* Until nothing further to relax. */
3162 while (stretched
&& -- max_iterations
);
3165 as_fatal (_("Infinite loop encountered whilst attempting to compute the addresses of symbols in section %s"),
3166 segment_name (segment
));
3169 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
3170 if (fragP
->last_fr_address
!= fragP
->fr_address
)
3172 fragP
->last_fr_address
= fragP
->fr_address
;
3179 number_to_chars_bigendian (char *buf
, valueT val
, int n
)
3185 buf
[n
] = val
& 0xff;
3191 number_to_chars_littleendian (char *buf
, valueT val
, int n
)
3197 *buf
++ = val
& 0xff;
3203 write_print_statistics (FILE *file
)
3205 fprintf (file
, "fixups: %d\n", n_fixups
);
3208 /* For debugging. */
3209 extern int indent_level
;
3212 print_fixup (fixS
*fixp
)
3215 fprintf (stderr
, "fix %p %s:%d", fixp
, fixp
->fx_file
, fixp
->fx_line
);
3217 fprintf (stderr
, " pcrel");
3218 if (fixp
->fx_pcrel_adjust
)
3219 fprintf (stderr
, " pcrel_adjust=%d", fixp
->fx_pcrel_adjust
);
3221 fprintf (stderr
, " tcbit");
3223 fprintf (stderr
, " done");
3224 fprintf (stderr
, "\n size=%d frag=%p", fixp
->fx_size
, fixp
->fx_frag
);
3225 fprintf (stderr
, " where=%ld offset=%" PRIx64
" addnumber=%" PRIx64
,
3226 fixp
->fx_where
, (uint64_t) fixp
->fx_offset
,
3227 (uint64_t) fixp
->fx_addnumber
);
3228 fprintf (stderr
, "\n %s (%d)", bfd_get_reloc_code_name (fixp
->fx_r_type
),
3232 fprintf (stderr
, "\n +<");
3233 print_symbol_value_1 (stderr
, fixp
->fx_addsy
);
3234 fprintf (stderr
, ">");
3238 fprintf (stderr
, "\n -<");
3239 print_symbol_value_1 (stderr
, fixp
->fx_subsy
);
3240 fprintf (stderr
, ">");
3242 fprintf (stderr
, "\n");
3243 #ifdef TC_FIX_DATA_PRINT
3244 TC_FIX_DATA_PRINT (stderr
, fixp
);