1 /* write.c - emit .o file
2 Copyright (C) 1986-2023 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;
173 fixP
->fx_no_overflow
= 0;
177 fixP
->fx_cgen
.insn
= NULL
;
178 fixP
->fx_cgen
.opinfo
= 0;
182 TC_INIT_FIX_DATA (fixP
);
185 fixP
->fx_file
= as_where (&fixP
->fx_line
);
189 fixS
**seg_fix_rootP
= (frags_chained
190 ? &seg_info (now_seg
)->fix_root
191 : &frchain_now
->fix_root
);
192 fixS
**seg_fix_tailP
= (frags_chained
193 ? &seg_info (now_seg
)->fix_tail
194 : &frchain_now
->fix_tail
);
198 fixP
->fx_next
= *seg_fix_rootP
;
199 *seg_fix_rootP
= fixP
;
200 if (fixP
->fx_next
== NULL
)
201 *seg_fix_tailP
= fixP
;
205 fixP
->fx_next
= NULL
;
207 (*seg_fix_tailP
)->fx_next
= fixP
;
209 *seg_fix_rootP
= fixP
;
210 *seg_fix_tailP
= fixP
;
217 /* Create a fixup relative to a symbol (plus a constant). */
220 fix_new (fragS
*frag
, /* Which frag? */
221 unsigned long where
, /* Where in that frag? */
222 unsigned long size
, /* 1, 2, or 4 usually. */
223 symbolS
*add_symbol
, /* X_add_symbol. */
224 offsetT offset
, /* X_add_number. */
225 int pcrel
, /* TRUE if PC-relative relocation. */
226 RELOC_ENUM r_type
/* Relocation type. */)
228 return fix_new_internal (frag
, where
, size
, add_symbol
,
229 (symbolS
*) NULL
, offset
, pcrel
, r_type
, false);
232 /* Create a fixup for an expression. Currently we only support fixups
233 for difference expressions. That is itself more than most object
234 file formats support anyhow. */
237 fix_new_exp (fragS
*frag
, /* Which frag? */
238 unsigned long where
, /* Where in that frag? */
239 unsigned long size
, /* 1, 2, or 4 usually. */
240 expressionS
*exp
, /* Expression. */
241 int pcrel
, /* TRUE if PC-relative relocation. */
242 RELOC_ENUM r_type
/* Relocation type. */)
254 as_bad (_("register value used as expression"));
258 /* This comes up when _GLOBAL_OFFSET_TABLE_+(.-L0) is read, if
259 the difference expression cannot immediately be reduced. */
261 symbolS
*stmp
= make_expr_symbol (exp
);
263 exp
->X_op
= O_symbol
;
264 exp
->X_op_symbol
= 0;
265 exp
->X_add_symbol
= stmp
;
266 exp
->X_add_number
= 0;
268 return fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
272 add
= exp
->X_add_symbol
;
273 off
= exp
->X_add_number
;
274 r_type
= BFD_RELOC_RVA
;
278 sub
= exp
->X_add_symbol
;
279 off
= exp
->X_add_number
;
283 sub
= exp
->X_op_symbol
;
286 add
= exp
->X_add_symbol
;
289 off
= exp
->X_add_number
;
293 add
= make_expr_symbol (exp
);
297 return fix_new_internal (frag
, where
, size
, add
, sub
, off
, pcrel
,
301 /* Create a fixup at the beginning of FRAG. The arguments are the same
302 as for fix_new, except that WHERE is implicitly 0. */
305 fix_at_start (fragS
*frag
, unsigned long size
, symbolS
*add_symbol
,
306 offsetT offset
, int pcrel
, RELOC_ENUM r_type
)
308 return fix_new_internal (frag
, 0, size
, add_symbol
,
309 (symbolS
*) NULL
, offset
, pcrel
, r_type
, true);
312 /* Generic function to determine whether a fixup requires a relocation. */
314 generic_force_reloc (fixS
*fix
)
316 if (fix
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
317 || fix
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
320 if (fix
->fx_addsy
== NULL
)
323 return S_FORCE_RELOC (fix
->fx_addsy
, fix
->fx_subsy
== NULL
);
326 /* Append a string onto another string, bumping the pointer along. */
328 append (char **charPP
, char *fromP
, unsigned long length
)
330 /* Don't trust memcpy() of 0 chars. */
334 memcpy (*charPP
, fromP
, length
);
338 /* This routine records the largest alignment seen for each segment.
339 If the beginning of the segment is aligned on the worst-case
340 boundary, all of the other alignments within it will work. At
341 least one object format really uses this info. */
344 record_alignment (/* Segment to which alignment pertains. */
346 /* Alignment, as a power of 2 (e.g., 1 => 2-byte
347 boundary, 2 => 4-byte boundary, etc.) */
350 if (seg
== absolute_section
)
353 if (align
> bfd_section_alignment (seg
))
354 bfd_set_section_alignment (seg
, align
);
358 get_recorded_alignment (segT seg
)
360 if (seg
== absolute_section
)
363 return bfd_section_alignment (seg
);
366 /* Reset the section indices after removing the gas created sections. */
369 renumber_sections (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, void *countparg
)
371 int *countp
= (int *) countparg
;
373 sec
->index
= *countp
;
378 chain_frchains_together_1 (segT section
, struct frchain
*frchp
)
380 fragS dummy
, *prev_frag
= &dummy
;
381 fixS fix_dummy
, *prev_fix
= &fix_dummy
;
385 prev_frag
->fr_next
= frchp
->frch_root
;
386 prev_frag
= frchp
->frch_last
;
387 gas_assert (prev_frag
->fr_type
!= 0);
388 if (frchp
->fix_root
!= (fixS
*) NULL
)
390 if (seg_info (section
)->fix_root
== (fixS
*) NULL
)
391 seg_info (section
)->fix_root
= frchp
->fix_root
;
392 prev_fix
->fx_next
= frchp
->fix_root
;
393 seg_info (section
)->fix_tail
= frchp
->fix_tail
;
394 prev_fix
= frchp
->fix_tail
;
396 frchp
= frchp
->frch_next
;
398 gas_assert (prev_frag
!= &dummy
399 && prev_frag
->fr_type
!= 0);
400 prev_frag
->fr_next
= 0;
405 chain_frchains_together (bfd
*abfd ATTRIBUTE_UNUSED
,
407 void *xxx ATTRIBUTE_UNUSED
)
409 segment_info_type
*info
;
411 /* BFD may have introduced its own sections without using
412 subseg_new, so it is possible that seg_info is NULL. */
413 info
= seg_info (section
);
414 if (info
!= (segment_info_type
*) NULL
)
415 info
->frchainP
->frch_last
416 = chain_frchains_together_1 (section
, info
->frchainP
);
418 /* Now that we've chained the frags together, we must add new fixups
419 to the segment, not to the frag chain. */
420 frags_chained
= true;
424 cvt_frag_to_fill (segT sec ATTRIBUTE_UNUSED
, fragS
*fragP
)
426 switch (fragP
->fr_type
)
436 HANDLE_ALIGN (fragP
);
439 know (fragP
->fr_next
!= NULL
);
440 fragP
->fr_offset
= (fragP
->fr_next
->fr_address
442 - fragP
->fr_fix
) / fragP
->fr_var
;
443 if (fragP
->fr_offset
< 0)
445 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
446 _("attempt to .org/.space/.nops backwards? (%ld)"),
447 (long) fragP
->fr_offset
);
448 fragP
->fr_offset
= 0;
450 if (fragP
->fr_type
== rs_space_nop
)
451 fragP
->fr_type
= rs_fill_nop
;
453 fragP
->fr_type
= rs_fill
;
462 valueT value
= S_GET_VALUE (fragP
->fr_symbol
);
465 if (!S_IS_DEFINED (fragP
->fr_symbol
))
467 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
468 _("leb128 operand is an undefined symbol: %s"),
469 S_GET_NAME (fragP
->fr_symbol
));
472 size
= output_leb128 (fragP
->fr_literal
+ fragP
->fr_fix
, value
,
475 fragP
->fr_fix
+= size
;
476 fragP
->fr_type
= rs_fill
;
478 fragP
->fr_offset
= 0;
479 fragP
->fr_symbol
= NULL
;
484 eh_frame_convert_frag (fragP
);
488 dwarf2dbg_convert_frag (fragP
);
492 sframe_convert_frag (fragP
);
495 case rs_machine_dependent
:
496 md_convert_frag (stdoutput
, sec
, fragP
);
498 gas_assert (fragP
->fr_next
== NULL
499 || (fragP
->fr_next
->fr_address
- fragP
->fr_address
502 /* After md_convert_frag, we make the frag into a ".space 0".
503 md_convert_frag() should set up any fixSs and constants
508 #ifndef WORKING_DOT_WORD
511 struct broken_word
*lie
;
513 if (fragP
->fr_subtype
)
515 fragP
->fr_fix
+= md_short_jump_size
;
516 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
517 lie
&& lie
->dispfrag
== fragP
;
518 lie
= lie
->next_broken_word
)
520 fragP
->fr_fix
+= md_long_jump_size
;
528 BAD_CASE (fragP
->fr_type
);
532 md_frag_check (fragP
);
536 struct relax_seg_info
543 relax_seg (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, void *xxx
)
545 segment_info_type
*seginfo
= seg_info (sec
);
546 struct relax_seg_info
*info
= (struct relax_seg_info
*) xxx
;
548 if (seginfo
&& seginfo
->frchainP
549 && relax_segment (seginfo
->frchainP
->frch_root
, sec
, info
->pass
))
554 size_seg (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, void *xxx ATTRIBUTE_UNUSED
)
558 segment_info_type
*seginfo
;
560 valueT size
, newsize
;
562 subseg_change (sec
, 0);
564 seginfo
= seg_info (sec
);
565 if (seginfo
&& seginfo
->frchainP
)
567 for (fragp
= seginfo
->frchainP
->frch_root
; fragp
; fragp
= fragp
->fr_next
)
568 cvt_frag_to_fill (sec
, fragp
);
569 for (fragp
= seginfo
->frchainP
->frch_root
;
571 fragp
= fragp
->fr_next
)
572 /* Walk to last elt. */
574 size
= fragp
->fr_address
+ fragp
->fr_fix
;
579 flags
= bfd_section_flags (sec
);
580 if (size
== 0 && bfd_section_size (sec
) != 0 &&
581 (flags
& SEC_HAS_CONTENTS
) != 0)
584 if (size
> 0 && ! seginfo
->bss
)
585 flags
|= SEC_HAS_CONTENTS
;
587 x
= bfd_set_section_flags (sec
, flags
);
590 /* If permitted, allow the backend to pad out the section
591 to some alignment boundary. */
592 if (do_not_pad_sections_to_alignment
)
595 newsize
= md_section_align (sec
, size
);
596 x
= bfd_set_section_size (sec
, newsize
);
599 /* If the size had to be rounded up, add some padding in the last
601 gas_assert (newsize
>= size
);
604 fragS
*last
= seginfo
->frchainP
->frch_last
;
605 fragp
= seginfo
->frchainP
->frch_root
;
606 while (fragp
->fr_next
!= last
)
607 fragp
= fragp
->fr_next
;
608 last
->fr_address
= size
;
609 if ((newsize
- size
) % fragp
->fr_var
== 0)
610 fragp
->fr_offset
+= (newsize
- size
) / fragp
->fr_var
;
612 /* If we hit this abort, it's likely due to subsegs_finish not
613 providing sufficient alignment on the last frag, and the
614 machine dependent code using alignment frags with fr_var
619 #ifdef tc_frob_section
620 tc_frob_section (sec
);
622 #ifdef obj_frob_section
623 obj_frob_section (sec
);
629 dump_section_relocs (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, FILE *stream
)
631 segment_info_type
*seginfo
= seg_info (sec
);
632 fixS
*fixp
= seginfo
->fix_root
;
637 fprintf (stream
, "sec %s relocs:\n", sec
->name
);
640 symbolS
*s
= fixp
->fx_addsy
;
642 fprintf (stream
, " %08lx: type %d ", (unsigned long) fixp
,
643 (int) fixp
->fx_r_type
);
645 fprintf (stream
, "no sym\n");
648 print_symbol_value_1 (stream
, s
);
649 fprintf (stream
, "\n");
651 fixp
= fixp
->fx_next
;
655 #define dump_section_relocs(ABFD,SEC,STREAM) ((void) 0)
658 #ifndef EMIT_SECTION_SYMBOLS
659 #define EMIT_SECTION_SYMBOLS 1
662 /* Resolve U.A.OFFSET_SYM and U.A.SYM fields of RELOC_LIST entries,
663 and check for validity. Convert RELOC_LIST from using U.A fields
666 resolve_reloc_expr_symbols (void)
668 bfd_vma addr_mask
= 1;
669 struct reloc_list
*r
;
671 /* Avoid a shift by the width of type. */
672 addr_mask
<<= bfd_arch_bits_per_address (stdoutput
) - 1;
676 for (r
= reloc_list
; r
; r
= r
->next
)
678 reloc_howto_type
*howto
= r
->u
.a
.howto
;
681 bfd_vma offset
, addend
;
684 resolve_symbol_value (r
->u
.a
.offset_sym
);
685 symval
= symbol_get_value_expression (r
->u
.a
.offset_sym
);
689 if (symval
->X_op
== O_constant
)
690 sym
= r
->u
.a
.offset_sym
;
691 else if (symval
->X_op
== O_symbol
)
693 sym
= symval
->X_add_symbol
;
694 offset
= symval
->X_add_number
;
695 symval
= symbol_get_value_expression (symval
->X_add_symbol
);
698 || symval
->X_op
!= O_constant
699 || (sec
= S_GET_SEGMENT (sym
)) == NULL
700 || !SEG_NORMAL (sec
))
702 as_bad_where (r
->file
, r
->line
, _("invalid offset expression"));
706 offset
+= S_GET_VALUE (sym
);
709 addend
= r
->u
.a
.addend
;
710 if (r
->u
.a
.sym
!= NULL
)
712 resolve_symbol_value (r
->u
.a
.sym
);
713 symval
= symbol_get_value_expression (r
->u
.a
.sym
);
714 if (symval
->X_op
== O_constant
)
716 else if (symval
->X_op
== O_symbol
)
718 sym
= symval
->X_add_symbol
;
719 addend
+= symval
->X_add_number
;
720 symval
= symbol_get_value_expression (symval
->X_add_symbol
);
722 if (symval
->X_op
!= O_constant
)
724 as_bad_where (r
->file
, r
->line
, _("invalid reloc expression"));
727 else if (sym
!= NULL
&& sec
!= NULL
)
729 /* Convert relocs against local symbols to refer to the
730 corresponding section symbol plus offset instead. Keep
731 PC-relative relocs of the REL variety intact though to
732 prevent the offset from overflowing the relocated field,
733 unless it has enough bits to cover the whole address
736 && S_IS_DEFINED (sym
)
737 && !symbol_section_p (sym
)
739 || (howto
->partial_inplace
740 && (!howto
->pc_relative
741 || howto
->src_mask
== addr_mask
))))
743 asection
*symsec
= S_GET_SEGMENT (sym
);
744 if (!(((symsec
->flags
& SEC_MERGE
) != 0
746 || (symsec
->flags
& SEC_THREAD_LOCAL
) != 0))
748 addend
+= S_GET_VALUE (sym
);
749 sym
= section_symbol (symsec
);
752 symbol_mark_used_in_reloc (sym
);
757 if (abs_section_sym
== NULL
)
758 abs_section_sym
= section_symbol (absolute_section
);
759 sym
= abs_section_sym
;
763 r
->u
.b
.s
= symbol_get_bfdsym (sym
);
764 r
->u
.b
.r
.sym_ptr_ptr
= &r
->u
.b
.s
;
765 r
->u
.b
.r
.address
= offset
;
766 r
->u
.b
.r
.addend
= addend
;
767 r
->u
.b
.r
.howto
= howto
;
771 /* This pass over fixups decides whether symbols can be replaced with
775 adjust_reloc_syms (bfd
*abfd ATTRIBUTE_UNUSED
,
777 void *xxx ATTRIBUTE_UNUSED
)
779 segment_info_type
*seginfo
= seg_info (sec
);
785 dump_section_relocs (abfd
, sec
, stderr
);
787 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
791 else if (fixp
->fx_addsy
)
797 fprintf (stderr
, "\n\nadjusting fixup:\n");
801 sym
= fixp
->fx_addsy
;
803 /* All symbols should have already been resolved at this
804 point. It is possible to see unresolved expression
805 symbols, though, since they are not in the regular symbol
807 resolve_symbol_value (sym
);
809 if (fixp
->fx_subsy
!= NULL
)
810 resolve_symbol_value (fixp
->fx_subsy
);
812 /* If this symbol is equated to an undefined or common symbol,
813 convert the fixup to being against that symbol. */
814 while (symbol_equated_reloc_p (sym
)
815 || S_IS_WEAKREFR (sym
))
817 symbolS
*newsym
= symbol_get_value_expression (sym
)->X_add_symbol
;
820 fixp
->fx_offset
+= symbol_get_value_expression (sym
)->X_add_number
;
821 fixp
->fx_addsy
= newsym
;
825 if (symbol_mri_common_p (sym
))
827 fixp
->fx_offset
+= S_GET_VALUE (sym
);
828 fixp
->fx_addsy
= symbol_get_value_expression (sym
)->X_add_symbol
;
832 /* If the symbol is undefined, common, weak, or global (ELF
833 shared libs), we can't replace it with the section symbol. */
834 if (S_FORCE_RELOC (fixp
->fx_addsy
, 1))
837 /* Is there some other (target cpu dependent) reason we can't adjust
838 this one? (E.g. relocations involving function addresses on
840 #ifdef tc_fix_adjustable
841 if (! tc_fix_adjustable (fixp
))
845 /* Since we're reducing to section symbols, don't attempt to reduce
846 anything that's already using one. */
847 if (symbol_section_p (sym
))
849 /* Mark the section symbol used in relocation so that it will
850 be included in the symbol table. */
851 symbol_mark_used_in_reloc (sym
);
855 symsec
= S_GET_SEGMENT (sym
);
859 if (bfd_is_abs_section (symsec
)
860 || symsec
== reg_section
)
862 /* The fixup_segment routine normally will not use this
863 symbol in a relocation. */
867 /* Don't try to reduce relocs which refer to non-local symbols
868 in .linkonce sections. It can lead to confusion when a
869 debugging section refers to a .linkonce section. I hope
870 this will always be correct. */
871 if (symsec
!= sec
&& ! S_IS_LOCAL (sym
))
873 if ((symsec
->flags
& SEC_LINK_ONCE
) != 0
875 /* The GNU toolchain uses an extension for ELF: a
876 section beginning with the magic string
877 .gnu.linkonce is a linkonce section. */
878 && startswith (segment_name (symsec
), ".gnu.linkonce")))
882 /* Never adjust a reloc against local symbol in a merge section
883 with non-zero addend. */
884 if ((symsec
->flags
& SEC_MERGE
) != 0
885 && (fixp
->fx_offset
!= 0 || fixp
->fx_subsy
!= NULL
))
888 /* Never adjust a reloc against TLS local symbol. */
889 if ((symsec
->flags
& SEC_THREAD_LOCAL
) != 0)
892 /* We refetch the segment when calling section_symbol, rather
893 than using symsec, because S_GET_VALUE may wind up changing
894 the section when it calls resolve_symbol_value. */
895 fixp
->fx_offset
+= S_GET_VALUE (sym
);
896 fixp
->fx_addsy
= section_symbol (S_GET_SEGMENT (sym
));
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 ()));
1690 gas_assert (count
>= 0);
1691 if (fill_size
&& count
)
1694 if (fill_size
> sizeof (buf
))
1696 /* Do it the old way. Can this ever happen? */
1699 x
= bfd_set_section_contents (stdoutput
, sec
,
1702 (bfd_size_type
) fill_size
);
1704 as_fatal (ngettext ("can't fill %ld byte "
1705 "in section %s of %s: '%s'",
1706 "can't fill %ld bytes "
1707 "in section %s of %s: '%s'",
1710 bfd_section_name (sec
),
1711 bfd_get_filename (stdoutput
),
1712 bfd_errmsg (bfd_get_error ()));
1713 offset
+= fill_size
;
1718 /* Build a buffer full of fill objects and output it as
1719 often as necessary. This saves on the overhead of
1720 potentially lots of bfd_set_section_contents calls. */
1724 n_per_buf
= sizeof (buf
);
1725 memset (buf
, *fill_literal
, n_per_buf
);
1730 n_per_buf
= sizeof (buf
) / fill_size
;
1731 for (i
= n_per_buf
, bufp
= buf
; i
; i
--, bufp
+= fill_size
)
1732 memcpy (bufp
, fill_literal
, fill_size
);
1734 for (; count
> 0; count
-= n_per_buf
)
1736 n_per_buf
= n_per_buf
> count
? count
: n_per_buf
;
1737 x
= bfd_set_section_contents
1738 (stdoutput
, sec
, buf
, (file_ptr
) offset
,
1739 (bfd_size_type
) n_per_buf
* fill_size
);
1741 as_fatal (ngettext ("can't fill %ld byte "
1742 "in section %s of %s: '%s'",
1743 "can't fill %ld bytes "
1744 "in section %s of %s: '%s'",
1745 (long) (n_per_buf
* fill_size
)),
1746 (long) (n_per_buf
* fill_size
),
1747 bfd_section_name (sec
),
1748 bfd_get_filename (stdoutput
),
1749 bfd_errmsg (bfd_get_error ()));
1750 offset
+= n_per_buf
* fill_size
;
1758 merge_data_into_text (void)
1760 seg_info (text_section
)->frchainP
->frch_last
->fr_next
=
1761 seg_info (data_section
)->frchainP
->frch_root
;
1762 seg_info (text_section
)->frchainP
->frch_last
=
1763 seg_info (data_section
)->frchainP
->frch_last
;
1764 seg_info (data_section
)->frchainP
= 0;
1775 /* Count symbols. We can't rely on a count made by the loop in
1776 write_object_file, because *_frob_file may add a new symbol or
1777 two. Generate unused section symbols only if needed. */
1779 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
1780 if (!symbol_removed_p (symp
)
1781 && (bfd_keep_unused_section_symbols (stdoutput
)
1782 || !symbol_section_p (symp
)
1783 || symbol_used_in_reloc_p (symp
)))
1789 bfd_size_type amt
= (bfd_size_type
) nsyms
* sizeof (asymbol
*);
1791 asympp
= (asymbol
**) bfd_alloc (stdoutput
, amt
);
1792 symp
= symbol_rootP
;
1793 for (i
= 0; i
< nsyms
; symp
= symbol_next (symp
))
1794 if (!symbol_removed_p (symp
)
1795 && (bfd_keep_unused_section_symbols (stdoutput
)
1796 || !symbol_section_p (symp
)
1797 || symbol_used_in_reloc_p (symp
)))
1799 asympp
[i
] = symbol_get_bfdsym (symp
);
1800 if (asympp
[i
]->flags
!= BSF_SECTION_SYM
1801 || !(bfd_is_const_section (asympp
[i
]->section
)
1802 && asympp
[i
]->section
->symbol
== asympp
[i
]))
1803 asympp
[i
]->flags
|= BSF_KEEP
;
1804 symbol_mark_written (symp
);
1805 /* Include this section symbol in the symbol table. */
1806 if (symbol_section_p (symp
))
1807 asympp
[i
]->flags
|= BSF_SECTION_SYM_USED
;
1813 result
= bfd_set_symtab (stdoutput
, asympp
, nsyms
);
1814 gas_assert (result
);
1815 symbol_table_frozen
= 1;
1818 /* Finish the subsegments. After every sub-segment, we fake an
1819 ".align ...". This conforms to BSD4.2 brain-damage. We then fake
1820 ".fill 0" because that is the kind of frag that requires least
1821 thought. ".align" frags like to have a following frag since that
1822 makes calculating their intended length trivial. */
1824 #ifndef SUB_SEGMENT_ALIGN
1826 /* The last subsegment gets an alignment corresponding to the alignment
1827 of the section. This allows proper nop-filling at the end of
1828 code-bearing sections. */
1829 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \
1830 (!(FRCHAIN)->frch_next && subseg_text_p (SEG) \
1831 && !do_not_pad_sections_to_alignment \
1832 ? get_recorded_alignment (SEG) \
1835 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
1840 subsegs_finish_section (asection
*s
)
1842 struct frchain
*frchainP
;
1843 segment_info_type
*seginfo
= seg_info (s
);
1847 for (frchainP
= seginfo
->frchainP
;
1849 frchainP
= frchainP
->frch_next
)
1853 subseg_set (s
, frchainP
->frch_subseg
);
1855 /* This now gets called even if we had errors. In that case,
1856 any alignment is meaningless, and, moreover, will look weird
1857 if we are generating a listing. */
1859 do_not_pad_sections_to_alignment
= 1;
1861 alignment
= SUB_SEGMENT_ALIGN (now_seg
, frchainP
);
1862 if ((bfd_section_flags (now_seg
) & SEC_MERGE
)
1863 && now_seg
->entsize
)
1865 unsigned int entsize
= now_seg
->entsize
;
1868 while ((entsize
& 1) == 0)
1874 if (entalign
> alignment
)
1875 alignment
= entalign
;
1878 if (subseg_text_p (now_seg
))
1879 frag_align_code (alignment
, 0);
1881 frag_align (alignment
, 0, 0);
1883 /* frag_align will have left a new frag.
1884 Use this last frag for an empty ".fill".
1886 For this segment ...
1887 Create a last frag. Do not leave a "being filled in frag". */
1888 frag_wane (frag_now
);
1889 frag_now
->fr_fix
= 0;
1890 know (frag_now
->fr_next
== NULL
);
1895 subsegs_finish (void)
1899 for (s
= stdoutput
->sections
; s
; s
= s
->next
)
1900 subsegs_finish_section (s
);
1905 create_obj_attrs_section (void)
1912 size
= bfd_elf_obj_attr_size (stdoutput
);
1916 name
= get_elf_backend_data (stdoutput
)->obj_attrs_section
;
1918 name
= ".gnu.attributes";
1919 s
= subseg_new (name
, 0);
1920 elf_section_type (s
)
1921 = get_elf_backend_data (stdoutput
)->obj_attrs_section_type
;
1922 bfd_set_section_flags (s
, SEC_READONLY
| SEC_DATA
);
1924 p
= frag_more (size
);
1925 bfd_elf_set_obj_attr_contents (stdoutput
, (bfd_byte
*)p
, size
);
1927 subsegs_finish_section (s
);
1928 relax_segment (seg_info (s
)->frchainP
->frch_root
, s
, 0);
1929 size_seg (stdoutput
, s
, NULL
);
1932 /* Create a relocation against an entry in a GNU Build attribute section. */
1935 create_note_reloc (segT sec
,
1937 bfd_size_type note_offset
,
1938 bfd_size_type desc2_offset
,
1944 struct reloc_list
* reloc
;
1946 reloc
= XNEW (struct reloc_list
);
1948 /* We create a .b type reloc as resolve_reloc_expr_symbols() has already been called. */
1949 reloc
->u
.b
.sec
= sec
;
1950 reloc
->u
.b
.s
= symbol_get_bfdsym (sym
);
1951 reloc
->u
.b
.r
.sym_ptr_ptr
= & reloc
->u
.b
.s
;
1952 reloc
->u
.b
.r
.address
= note_offset
+ desc2_offset
;
1953 reloc
->u
.b
.r
.addend
= addend
;
1954 reloc
->u
.b
.r
.howto
= bfd_reloc_type_lookup (stdoutput
, reloc_type
);
1956 if (reloc
->u
.b
.r
.howto
== NULL
)
1958 as_bad (_("unable to create reloc for build note"));
1962 reloc
->file
= N_("<gnu build note>");
1965 reloc
->next
= reloc_list
;
1968 /* For REL relocs, store the addend in the section. */
1969 if (! sec
->use_rela_p
1970 /* The SH target is a special case that uses RELA relocs
1971 but still stores the addend in the word being relocated. */
1972 || strstr (bfd_get_target (stdoutput
), "-sh") != NULL
)
1976 /* Zero out the addend, since it is now stored in the note. */
1977 reloc
->u
.b
.r
.addend
= 0;
1979 if (target_big_endian
)
1981 for (i
= desc2_size
; addend
!= 0 && i
> 0; addend
>>= 8, i
--)
1982 note
[desc2_offset
+ i
- 1] = (addend
& 0xff);
1986 for (i
= 0; addend
!= 0 && i
< desc2_size
; addend
>>= 8, i
++)
1987 note
[desc2_offset
+ i
] = (addend
& 0xff);
1993 maybe_generate_build_notes (void)
2000 offsetT desc2_offset
;
2005 if (! flag_generate_build_notes
2006 || bfd_get_section_by_name (stdoutput
,
2007 GNU_BUILD_ATTRS_SECTION_NAME
) != NULL
)
2010 /* Create a GNU Build Attribute section. */
2011 sec
= subseg_new (GNU_BUILD_ATTRS_SECTION_NAME
, false);
2012 elf_section_type (sec
) = SHT_NOTE
;
2013 bfd_set_section_flags (sec
, (SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_DATA
2015 bfd_set_section_alignment (sec
, 2);
2017 /* Work out the size of the notes that we will create,
2018 and the relocation we should use. */
2019 if (bfd_arch_bits_per_address (stdoutput
) <= 32)
2022 desc_size
= 8; /* Two 4-byte offsets. */
2025 /* FIXME: The BFD backend for the CRX target does not support the
2026 BFD_RELOC_32, even though it really should. Likewise for the
2027 CR16 target. So we have special case code here... */
2028 if (strstr (bfd_get_target (stdoutput
), "-crx") != NULL
)
2029 desc_reloc
= BFD_RELOC_CRX_NUM32
;
2030 else if (strstr (bfd_get_target (stdoutput
), "-cr16") != NULL
)
2031 desc_reloc
= BFD_RELOC_CR16_NUM32
;
2033 desc_reloc
= BFD_RELOC_32
;
2038 desc_size
= 16; /* Two 8-byte offsets. */
2040 /* FIXME: The BFD backend for the IA64 target does not support the
2041 BFD_RELOC_64, even though it really should. The HPPA backend
2042 has a similar issue, although it does not support BFD_RELOCs at
2043 all! So we have special case code to handle these targets. */
2044 if (strstr (bfd_get_target (stdoutput
), "-ia64") != NULL
)
2045 desc_reloc
= target_big_endian
? BFD_RELOC_IA64_DIR32MSB
: BFD_RELOC_IA64_DIR32LSB
;
2046 else if (strstr (bfd_get_target (stdoutput
), "-hppa") != NULL
)
2047 desc_reloc
= 80; /* R_PARISC_DIR64. */
2049 desc_reloc
= BFD_RELOC_64
;
2052 /* We have to create a note for *each* code section.
2053 Linker garbage collection might discard some. */
2057 for (sym
= symbol_rootP
; sym
!= NULL
; sym
= symbol_next (sym
))
2058 if ((bsym
= symbol_get_bfdsym (sym
)) != NULL
2059 && bsym
->flags
& BSF_SECTION_SYM
2060 && bsym
->section
!= NULL
2061 /* Skip linkonce sections - we cannot use these section symbols as they may disappear. */
2062 && (bsym
->section
->flags
& (SEC_CODE
| SEC_LINK_ONCE
)) == SEC_CODE
2063 /* Not all linkonce sections are flagged... */
2064 && !startswith (S_GET_NAME (sym
), ".gnu.linkonce"))
2066 /* Create a version note. */
2068 note
= frag_more (note_size
);
2069 memset (note
, 0, note_size
);
2071 if (target_big_endian
)
2073 note
[3] = 8; /* strlen (name) + 1. */
2074 note
[7] = desc_size
; /* Two N-byte offsets. */
2075 note
[10] = NT_GNU_BUILD_ATTRIBUTE_OPEN
>> 8;
2076 note
[11] = NT_GNU_BUILD_ATTRIBUTE_OPEN
& 0xff;
2080 note
[0] = 8; /* strlen (name) + 1. */
2081 note
[4] = desc_size
; /* Two N-byte offsets. */
2082 note
[8] = NT_GNU_BUILD_ATTRIBUTE_OPEN
& 0xff;
2083 note
[9] = NT_GNU_BUILD_ATTRIBUTE_OPEN
>> 8;
2086 /* The a1 version number indicates that this note was
2087 generated by the assembler and not the gcc annobin plugin. */
2088 memcpy (note
+ 12, "GA$\x013a1", 8);
2090 /* Create a relocation to install the start address of the note... */
2091 create_note_reloc (sec
, sym
, total_size
, 20, desc_size
/ 2, desc_reloc
, 0, note
);
2093 /* ...and another one to install the end address. */
2094 create_note_reloc (sec
, sym
, total_size
, desc2_offset
,
2097 bfd_section_size (bsym
->section
),
2100 /* Mark the section symbol used in relocation so that it will be
2101 included in the symbol table. */
2102 symbol_mark_used_in_reloc (sym
);
2104 total_size
+= note_size
;
2105 /* FIXME: Maybe add a note recording the assembler command line and version ? */
2108 /* Install the note(s) into the section. */
2110 bfd_set_section_contents (stdoutput
, sec
, (bfd_byte
*) note
, 0, total_size
);
2111 subsegs_finish_section (sec
);
2112 relax_segment (seg_info (sec
)->frchainP
->frch_root
, sec
, 0);
2113 size_seg (stdoutput
, sec
, NULL
);
2115 #endif /* OBJ_ELF */
2117 /* Write the object file. */
2120 write_object_file (void)
2122 struct relax_seg_info rsi
;
2123 #ifndef WORKING_DOT_WORD
2124 fragS
*fragP
; /* Track along all frags. */
2129 #ifdef md_pre_output_hook
2133 #ifdef md_pre_relax_hook
2137 /* From now on, we don't care about sub-segments. Build one frag chain
2138 for each segment. Linked through fr_next. */
2140 /* Remove the sections created by gas for its own purposes. */
2144 bfd_section_list_remove (stdoutput
, reg_section
);
2145 bfd_section_list_remove (stdoutput
, expr_section
);
2146 stdoutput
->section_count
-= 2;
2148 bfd_map_over_sections (stdoutput
, renumber_sections
, &i
);
2151 bfd_map_over_sections (stdoutput
, chain_frchains_together
, (char *) 0);
2153 /* We have two segments. If user gave -R flag, then we must put the
2154 data frags into the text segment. Do this before relaxing so
2155 we know to take advantage of -R and make shorter addresses. */
2156 if (flag_readonly_data_in_text
)
2158 merge_data_into_text ();
2164 #ifndef WORKING_DOT_WORD
2165 /* We need to reset the markers in the broken word list and
2166 associated frags between calls to relax_segment (via
2167 relax_seg). Since the broken word list is global, we do it
2168 once per round, rather than locally in relax_segment for each
2170 struct broken_word
*brokp
;
2172 for (brokp
= broken_words
;
2173 brokp
!= (struct broken_word
*) NULL
;
2174 brokp
= brokp
->next_broken_word
)
2178 if (brokp
->dispfrag
!= (fragS
*) NULL
2179 && brokp
->dispfrag
->fr_type
== rs_broken_word
)
2180 brokp
->dispfrag
->fr_subtype
= 0;
2185 bfd_map_over_sections (stdoutput
, relax_seg
, &rsi
);
2191 /* Note - Most ports will use the default value of
2192 TC_FINALIZE_SYMS_BEFORE_SIZE_SEG, which 1. This will force
2193 local symbols to be resolved, removing their frag information.
2194 Some ports however, will not have finished relaxing all of
2195 their frags and will still need the local symbol frag
2196 information. These ports can set
2197 TC_FINALIZE_SYMS_BEFORE_SIZE_SEG to 0. */
2198 finalize_syms
= TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
;
2200 bfd_map_over_sections (stdoutput
, size_seg
, (char *) 0);
2202 /* Relaxation has completed. Freeze all syms. */
2205 dwarf2dbg_final_check ();
2207 #ifdef md_post_relax_hook
2213 create_obj_attrs_section ();
2216 #ifndef WORKING_DOT_WORD
2218 struct broken_word
*lie
;
2219 struct broken_word
**prevP
;
2221 prevP
= &broken_words
;
2222 for (lie
= broken_words
; lie
; lie
= lie
->next_broken_word
)
2227 subseg_change (lie
->seg
, lie
->subseg
);
2228 exp
.X_op
= O_subtract
;
2229 exp
.X_add_symbol
= lie
->add
;
2230 exp
.X_op_symbol
= lie
->sub
;
2231 exp
.X_add_number
= lie
->addnum
;
2232 #ifdef TC_CONS_FIX_NEW
2233 TC_CONS_FIX_NEW (lie
->frag
,
2234 lie
->word_goes_here
- lie
->frag
->fr_literal
,
2235 2, &exp
, TC_PARSE_CONS_RETURN_NONE
);
2237 fix_new_exp (lie
->frag
,
2238 lie
->word_goes_here
- lie
->frag
->fr_literal
,
2239 2, &exp
, 0, BFD_RELOC_16
);
2241 *prevP
= lie
->next_broken_word
;
2244 prevP
= &(lie
->next_broken_word
);
2246 for (lie
= broken_words
; lie
;)
2248 struct broken_word
*untruth
;
2250 addressT table_addr
;
2251 addressT from_addr
, to_addr
;
2254 subseg_change (lie
->seg
, lie
->subseg
);
2255 fragP
= lie
->dispfrag
;
2257 /* Find out how many broken_words go here. */
2260 untruth
&& untruth
->dispfrag
== fragP
;
2261 untruth
= untruth
->next_broken_word
)
2262 if (untruth
->added
== 1)
2265 table_ptr
= lie
->dispfrag
->fr_opcode
;
2266 table_addr
= (lie
->dispfrag
->fr_address
2267 + (table_ptr
- lie
->dispfrag
->fr_literal
));
2268 /* Create the jump around the long jumps. This is a short
2269 jump from table_ptr+0 to table_ptr+n*long_jump_size. */
2270 from_addr
= table_addr
;
2271 to_addr
= table_addr
+ md_short_jump_size
+ n
* md_long_jump_size
;
2272 md_create_short_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
,
2274 table_ptr
+= md_short_jump_size
;
2275 table_addr
+= md_short_jump_size
;
2278 lie
&& lie
->dispfrag
== fragP
;
2279 m
++, lie
= lie
->next_broken_word
)
2281 if (lie
->added
== 2)
2283 /* Patch the jump table. */
2284 for (untruth
= (struct broken_word
*) (fragP
->fr_symbol
);
2285 untruth
&& untruth
->dispfrag
== fragP
;
2286 untruth
= untruth
->next_broken_word
)
2288 if (untruth
->use_jump
== lie
)
2290 /* This is the offset from ??? to table_ptr+0.
2291 The target is the same for all users of this
2292 md_long_jump, but the "sub" bases (and hence the
2293 offsets) may be different. */
2294 addressT to_word
= table_addr
- S_GET_VALUE (untruth
->sub
);
2295 #ifdef TC_CHECK_ADJUSTED_BROKEN_DOT_WORD
2296 TC_CHECK_ADJUSTED_BROKEN_DOT_WORD (to_word
, untruth
);
2298 md_number_to_chars (untruth
->word_goes_here
, to_word
, 2);
2302 /* Install the long jump. */
2303 /* This is a long jump from table_ptr+0 to the final target. */
2304 from_addr
= table_addr
;
2305 to_addr
= S_GET_VALUE (lie
->add
) + lie
->addnum
;
2306 md_create_long_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
,
2308 table_ptr
+= md_long_jump_size
;
2309 table_addr
+= md_long_jump_size
;
2313 #endif /* not WORKING_DOT_WORD */
2315 /* Resolve symbol values. This needs to be done before processing
2321 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
2322 resolve_symbol_value (symp
);
2324 resolve_local_symbol_values ();
2325 resolve_reloc_expr_symbols ();
2329 maybe_generate_build_notes ();
2332 #ifdef tc_frob_file_before_adjust
2333 tc_frob_file_before_adjust ();
2335 #ifdef obj_frob_file_before_adjust
2336 obj_frob_file_before_adjust ();
2339 bfd_map_over_sections (stdoutput
, adjust_reloc_syms
, (char *) 0);
2341 #ifdef tc_frob_file_before_fix
2342 tc_frob_file_before_fix ();
2344 #ifdef obj_frob_file_before_fix
2345 obj_frob_file_before_fix ();
2348 bfd_map_over_sections (stdoutput
, fix_segment
, (char *) 0);
2350 /* Set up symbol table, and write it out. */
2354 bool skip_next_symbol
= false;
2356 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
2361 if (skip_next_symbol
)
2363 /* Don't do anything besides moving the value of the
2364 symbol from the GAS value-field to the BFD value-field. */
2365 symbol_get_bfdsym (symp
)->value
= S_GET_VALUE (symp
);
2366 skip_next_symbol
= false;
2370 if (symbol_mri_common_p (symp
))
2372 if (S_IS_EXTERNAL (symp
))
2373 as_bad (_("%s: global symbols not supported in common sections"),
2375 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
2379 name
= S_GET_NAME (symp
);
2383 decode_local_label_name ((char *) S_GET_NAME (symp
));
2384 /* They only differ if `name' is a fb or dollar local
2386 if (name2
!= name
&& ! S_IS_DEFINED (symp
))
2387 as_bad (_("local label `%s' is not defined"), name2
);
2390 /* Do it again, because adjust_reloc_syms might introduce
2391 more symbols. They'll probably only be section symbols,
2392 but they'll still need to have the values computed. */
2393 resolve_symbol_value (symp
);
2395 /* Skip symbols which were equated to undefined or common
2397 if (symbol_equated_reloc_p (symp
)
2398 || S_IS_WEAKREFR (symp
))
2400 const char *sname
= S_GET_NAME (symp
);
2402 if (S_IS_COMMON (symp
)
2403 && !TC_FAKE_LABEL (sname
)
2404 && !S_IS_WEAKREFR (symp
))
2406 expressionS
*e
= symbol_get_value_expression (symp
);
2408 as_bad (_("`%s' can't be equated to common symbol `%s'"),
2409 sname
, S_GET_NAME (e
->X_add_symbol
));
2411 if (S_GET_SEGMENT (symp
) == reg_section
)
2413 /* Report error only if we know the symbol name. */
2414 if (S_GET_NAME (symp
) != reg_section
->name
)
2415 as_bad (_("can't make global register symbol `%s'"),
2418 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
2422 #ifdef obj_frob_symbol
2423 obj_frob_symbol (symp
, punt
);
2425 #ifdef tc_frob_symbol
2426 if (! punt
|| symbol_used_in_reloc_p (symp
))
2427 tc_frob_symbol (symp
, punt
);
2430 /* If we don't want to keep this symbol, splice it out of
2431 the chain now. If EMIT_SECTION_SYMBOLS is 0, we never
2432 want section symbols. Otherwise, we skip local symbols
2433 and symbols that the frob_symbol macros told us to punt,
2434 but we keep such symbols if they are used in relocs. */
2435 if (symp
== abs_section_sym
2436 || (! EMIT_SECTION_SYMBOLS
2437 && symbol_section_p (symp
))
2438 /* Note that S_IS_EXTERNAL and S_IS_LOCAL are not always
2439 opposites. Sometimes the former checks flags and the
2440 latter examines the name... */
2441 || (!S_IS_EXTERNAL (symp
)
2442 && (punt
|| S_IS_LOCAL (symp
) ||
2443 (S_IS_WEAKREFD (symp
) && ! symbol_used_p (symp
)))
2444 && ! symbol_used_in_reloc_p (symp
)))
2446 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
2448 /* After symbol_remove, symbol_next(symp) still returns
2449 the one that came after it in the chain. So we don't
2450 need to do any extra cleanup work here. */
2454 /* Make sure we really got a value for the symbol. */
2455 if (! symbol_resolved_p (symp
))
2457 as_bad (_("can't resolve value for symbol `%s'"),
2459 symbol_mark_resolved (symp
);
2462 /* Set the value into the BFD symbol. Up til now the value
2463 has only been kept in the gas symbolS struct. */
2464 symbol_get_bfdsym (symp
)->value
= S_GET_VALUE (symp
);
2466 /* A warning construct is a warning symbol followed by the
2467 symbol warned about. Don't let anything object-format or
2468 target-specific muck with it; it's ready for output. */
2469 if (symbol_get_bfdsym (symp
)->flags
& BSF_WARNING
)
2470 skip_next_symbol
= true;
2474 /* Now do any format-specific adjustments to the symbol table, such
2475 as adding file symbols. */
2476 #ifdef tc_adjust_symtab
2477 tc_adjust_symtab ();
2479 #ifdef obj_adjust_symtab
2480 obj_adjust_symtab ();
2483 /* Stop if there is an error. */
2484 if (!flag_always_generate_output
&& had_errors ())
2487 /* Now that all the sizes are known, and contents correct, we can
2488 start writing to the file. */
2491 /* If *_frob_file changes the symbol value at this point, it is
2492 responsible for moving the changed value into symp->bsym->value
2493 as well. Hopefully all symbol value changing can be done in
2498 #ifdef obj_frob_file
2501 #ifdef obj_coff_generate_pdata
2502 obj_coff_generate_pdata ();
2505 bfd_map_over_sections (stdoutput
, write_relocs
, (char *) 0);
2507 #ifdef tc_frob_file_after_relocs
2508 tc_frob_file_after_relocs ();
2510 #ifdef obj_frob_file_after_relocs
2511 obj_frob_file_after_relocs ();
2514 #if defined OBJ_ELF || defined OBJ_MAYBE_ELF
2515 if (IS_ELF
&& flag_use_elf_stt_common
)
2516 stdoutput
->flags
|= BFD_CONVERT_ELF_COMMON
| BFD_USE_ELF_STT_COMMON
;
2519 /* Once all relocations have been written, we can compress the
2520 contents of the debug sections. This needs to be done before
2521 we start writing any sections, because it will affect the file
2522 layout, which is fixed once we start writing contents. */
2523 if (flag_compress_debug
!= COMPRESS_DEBUG_NONE
)
2525 flagword flags
= BFD_COMPRESS
;
2526 if (flag_compress_debug
== COMPRESS_DEBUG_GABI_ZLIB
)
2527 flags
= BFD_COMPRESS
| BFD_COMPRESS_GABI
;
2528 else if (flag_compress_debug
== COMPRESS_DEBUG_ZSTD
)
2529 flags
= BFD_COMPRESS
| BFD_COMPRESS_GABI
| BFD_COMPRESS_ZSTD
;
2530 stdoutput
->flags
|= flags
& bfd_applicable_file_flags (stdoutput
);
2531 if ((stdoutput
->flags
& BFD_COMPRESS
) != 0)
2532 bfd_map_over_sections (stdoutput
, compress_debug
, (char *) 0);
2535 bfd_map_over_sections (stdoutput
, write_contents
, (char *) 0);
2538 #ifdef TC_GENERIC_RELAX_TABLE
2539 #ifndef md_generic_table_relax_frag
2540 #define md_generic_table_relax_frag relax_frag
2543 /* Relax a fragment by scanning TC_GENERIC_RELAX_TABLE. */
2546 relax_frag (segT segment
, fragS
*fragP
, long stretch
)
2548 const relax_typeS
*this_type
;
2549 const relax_typeS
*start_type
;
2550 relax_substateT next_state
;
2551 relax_substateT this_state
;
2557 const relax_typeS
*table
;
2559 target
= fragP
->fr_offset
;
2560 address
= fragP
->fr_address
+ fragP
->fr_fix
;
2561 table
= TC_GENERIC_RELAX_TABLE
;
2562 this_state
= fragP
->fr_subtype
;
2563 start_type
= this_type
= table
+ this_state
;
2564 symbolP
= fragP
->fr_symbol
;
2570 sym_frag
= symbol_get_frag (symbolP
);
2572 #ifndef DIFF_EXPR_OK
2573 know (sym_frag
!= NULL
);
2575 know (S_GET_SEGMENT (symbolP
) != absolute_section
2576 || sym_frag
== &zero_address_frag
);
2577 target
+= S_GET_VALUE (symbolP
);
2579 /* If SYM_FRAG has yet to be reached on this pass, assume it
2580 will move by STRETCH just as we did, unless there is an
2581 alignment frag between here and SYM_FRAG. An alignment may
2582 well absorb any STRETCH, and we don't want to choose a larger
2583 branch insn by overestimating the needed reach of this
2584 branch. It isn't critical to calculate TARGET exactly; We
2585 know we'll be doing another pass if STRETCH is non-zero. */
2588 && sym_frag
->relax_marker
!= fragP
->relax_marker
2589 && S_GET_SEGMENT (symbolP
) == segment
)
2592 || sym_frag
->region
== fragP
->region
)
2594 /* If we get here we know we have a forward branch. This
2595 relax pass may have stretched previous instructions so
2596 far that omitting STRETCH would make the branch
2597 negative. Don't allow this in case the negative reach is
2598 large enough to require a larger branch instruction. */
2599 else if (target
< address
)
2604 aim
= target
- address
;
2605 #ifdef TC_PCREL_ADJUST
2606 /* Currently only the ns32k and arc needs this. */
2607 aim
+= TC_PCREL_ADJUST (fragP
);
2610 #ifdef md_prepare_relax_scan
2611 /* Formerly called M68K_AIM_KLUDGE. */
2612 md_prepare_relax_scan (fragP
, address
, aim
, this_state
, this_type
);
2617 /* Look backwards. */
2618 for (next_state
= this_type
->rlx_more
; next_state
;)
2619 if (aim
>= this_type
->rlx_backward
)
2623 /* Grow to next state. */
2624 this_state
= next_state
;
2625 this_type
= table
+ this_state
;
2626 next_state
= this_type
->rlx_more
;
2631 /* Look forwards. */
2632 for (next_state
= this_type
->rlx_more
; next_state
;)
2633 if (aim
<= this_type
->rlx_forward
)
2637 /* Grow to next state. */
2638 this_state
= next_state
;
2639 this_type
= table
+ this_state
;
2640 next_state
= this_type
->rlx_more
;
2644 growth
= this_type
->rlx_length
- start_type
->rlx_length
;
2646 fragP
->fr_subtype
= this_state
;
2650 #endif /* defined (TC_GENERIC_RELAX_TABLE) */
2652 /* Relax_align. Advance location counter to next address that has 'alignment'
2653 lowest order bits all 0s, return size of adjustment made. */
2654 static relax_addressT
2655 relax_align (relax_addressT address
, /* Address now. */
2656 int alignment
/* Alignment (binary). */)
2658 relax_addressT mask
;
2659 relax_addressT new_address
;
2661 mask
= ~((relax_addressT
) ~0 << alignment
);
2662 new_address
= (address
+ mask
) & (~mask
);
2663 #ifdef LINKER_RELAXING_SHRINKS_ONLY
2665 /* We must provide lots of padding, so the linker can discard it
2666 when needed. The linker will not add extra space, ever. */
2667 new_address
+= (1 << alignment
);
2669 return (new_address
- address
);
2672 /* Now we have a segment, not a crowd of sub-segments, we can make
2677 After this, all frags in this segment have addresses that are correct
2678 within the segment. Since segments live in different file addresses,
2679 these frag addresses may not be the same as final object-file
2683 relax_segment (struct frag
*segment_frag_root
, segT segment
, int pass
)
2685 unsigned long frag_count
;
2687 relax_addressT address
;
2691 /* In case md_estimate_size_before_relax() wants to make fixSs. */
2692 subseg_change (segment
, 0);
2694 /* For each frag in segment: count and store (a 1st guess of)
2698 for (frag_count
= 0, fragP
= segment_frag_root
;
2700 fragP
= fragP
->fr_next
, frag_count
++)
2702 fragP
->region
= region
;
2703 fragP
->relax_marker
= 0;
2704 fragP
->fr_address
= address
;
2705 address
+= fragP
->fr_fix
;
2707 switch (fragP
->fr_type
)
2710 address
+= fragP
->fr_offset
* fragP
->fr_var
;
2717 addressT offset
= relax_align (address
, (int) fragP
->fr_offset
);
2719 if (fragP
->fr_subtype
!= 0 && offset
> fragP
->fr_subtype
)
2722 if (offset
% fragP
->fr_var
!= 0)
2724 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
2725 ngettext ("alignment padding (%lu byte) "
2726 "not a multiple of %ld",
2727 "alignment padding (%lu bytes) "
2728 "not a multiple of %ld",
2729 (unsigned long) offset
),
2730 (unsigned long) offset
, (long) fragP
->fr_var
);
2731 offset
-= (offset
% fragP
->fr_var
);
2740 /* Assume .org is nugatory. It will grow with 1st relax. */
2748 case rs_machine_dependent
:
2749 /* If fr_symbol is an expression, this call to
2750 resolve_symbol_value sets up the correct segment, which will
2751 likely be needed in md_estimate_size_before_relax. */
2752 if (fragP
->fr_symbol
)
2753 resolve_symbol_value (fragP
->fr_symbol
);
2755 address
+= md_estimate_size_before_relax (fragP
, segment
);
2758 #ifndef WORKING_DOT_WORD
2759 /* Broken words don't concern us yet. */
2760 case rs_broken_word
:
2765 /* Initial guess is always 1; doing otherwise can result in
2766 stable solutions that are larger than the minimum. */
2767 address
+= fragP
->fr_offset
= 1;
2771 address
+= eh_frame_estimate_size_before_relax (fragP
);
2775 address
+= dwarf2dbg_estimate_size_before_relax (fragP
);
2779 /* Initial estimate can be set to atleast 1 byte. */
2780 address
+= sframe_estimate_size_before_relax (fragP
);
2784 BAD_CASE (fragP
->fr_type
);
2791 unsigned long max_iterations
;
2793 /* Cumulative address adjustment. */
2796 /* Have we made any adjustment this pass? We can't just test
2797 stretch because one piece of code may have grown and another
2801 /* Most horrible, but gcc may give us some exception data that
2802 is impossible to assemble, of the form
2806 .uleb128 end - start
2812 If the leb128 is two bytes in size, then end-start is 128*128,
2813 which requires a three byte leb128. If the leb128 is three
2814 bytes in size, then end-start is 128*128-1, which requires a
2815 two byte leb128. We work around this dilemma by inserting
2816 an extra 4 bytes of alignment just after the .align. This
2817 works because the data after the align is accessed relative to
2820 This counter is used in a tiny state machine to detect
2821 whether a leb128 followed by an align is impossible to
2823 int rs_leb128_fudge
= 0;
2825 /* We want to prevent going into an infinite loop where one frag grows
2826 depending upon the location of a symbol which is in turn moved by
2827 the growing frag. eg:
2833 So we dictate that this algorithm can be at most O2. */
2834 max_iterations
= frag_count
* frag_count
;
2835 /* Check for overflow. */
2836 if (max_iterations
< frag_count
)
2837 max_iterations
= frag_count
;
2845 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
2848 addressT was_address
;
2852 fragP
->relax_marker
^= 1;
2853 was_address
= fragP
->fr_address
;
2854 address
= fragP
->fr_address
+= stretch
;
2855 symbolP
= fragP
->fr_symbol
;
2856 offset
= fragP
->fr_offset
;
2858 switch (fragP
->fr_type
)
2860 case rs_fill
: /* .fill never relaxes. */
2864 #ifndef WORKING_DOT_WORD
2865 /* JF: This is RMS's idea. I do *NOT* want to be blamed
2866 for it I do not want to write it. I do not want to have
2867 anything to do with it. This is not the proper way to
2868 implement this misfeature. */
2869 case rs_broken_word
:
2871 struct broken_word
*lie
;
2872 struct broken_word
*untruth
;
2874 /* Yes this is ugly (storing the broken_word pointer
2875 in the symbol slot). Still, this whole chunk of
2876 code is ugly, and I don't feel like doing anything
2877 about it. Think of it as stubbornness in action. */
2879 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
2880 lie
&& lie
->dispfrag
== fragP
;
2881 lie
= lie
->next_broken_word
)
2887 offset
= (S_GET_VALUE (lie
->add
)
2889 - S_GET_VALUE (lie
->sub
));
2890 if (offset
<= -32768 || offset
>= 32767)
2892 if (flag_warn_displacement
)
2896 bfd_sprintf_vma (stdoutput
, buf
,
2897 (addressT
) lie
->addnum
);
2898 as_warn_where (fragP
->fr_file
, fragP
->fr_line
,
2899 _(".word %s-%s+%s didn't fit"),
2900 S_GET_NAME (lie
->add
),
2901 S_GET_NAME (lie
->sub
),
2904 if (fragP
->fr_subtype
== 0)
2906 fragP
->fr_subtype
++;
2907 growth
+= md_short_jump_size
;
2910 /* Redirect *all* words of this table with the same
2911 target, lest we have to handle the case where the
2912 same target but with a offset that fits on this
2913 round overflows at the next relaxation round. */
2914 for (untruth
= (struct broken_word
*) (fragP
->fr_symbol
);
2915 untruth
&& untruth
->dispfrag
== lie
->dispfrag
;
2916 untruth
= untruth
->next_broken_word
)
2917 if ((symbol_get_frag (untruth
->add
)
2918 == symbol_get_frag (lie
->add
))
2919 && (S_GET_VALUE (untruth
->add
)
2920 == S_GET_VALUE (lie
->add
)))
2923 untruth
->use_jump
= lie
;
2927 growth
+= md_long_jump_size
;
2932 } /* case rs_broken_word */
2938 addressT oldoff
, newoff
;
2940 oldoff
= relax_align (was_address
+ fragP
->fr_fix
,
2942 newoff
= relax_align (address
+ fragP
->fr_fix
,
2945 if (fragP
->fr_subtype
!= 0)
2947 if (oldoff
> fragP
->fr_subtype
)
2949 if (newoff
> fragP
->fr_subtype
)
2953 growth
= newoff
- oldoff
;
2955 /* If this align happens to follow a leb128 and
2956 we have determined that the leb128 is bouncing
2957 in size, then break the cycle by inserting an
2960 && (rs_leb128_fudge
& 16) != 0
2961 && (rs_leb128_fudge
& 15) >= 2)
2963 segment_info_type
*seginfo
= seg_info (segment
);
2964 struct obstack
*ob
= &seginfo
->frchainP
->frch_obstack
;
2967 newf
= frag_alloc (ob
);
2968 obstack_blank_fast (ob
, fragP
->fr_var
);
2969 obstack_finish (ob
);
2970 memcpy (newf
, fragP
, SIZEOF_STRUCT_FRAG
);
2971 memcpy (newf
->fr_literal
,
2972 fragP
->fr_literal
+ fragP
->fr_fix
,
2974 newf
->fr_type
= rs_fill
;
2975 newf
->fr_address
= address
+ fragP
->fr_fix
+ newoff
;
2977 newf
->fr_offset
= (((offsetT
) 1 << fragP
->fr_offset
)
2979 if (newf
->fr_offset
* newf
->fr_var
2980 != (offsetT
) 1 << fragP
->fr_offset
)
2982 newf
->fr_offset
= (offsetT
) 1 << fragP
->fr_offset
;
2985 /* Include size of new frag in GROWTH. */
2986 growth
+= newf
->fr_offset
* newf
->fr_var
;
2987 /* Adjust the new frag address for the amount
2988 we'll add when we process the new frag. */
2989 newf
->fr_address
-= stretch
+ growth
;
2990 newf
->relax_marker
^= 1;
2991 fragP
->fr_next
= newf
;
2993 as_warn (_("padding added"));
3001 offsetT target
= offset
;
3006 /* Convert from an actual address to an octet offset
3007 into the section. Here it is assumed that the
3008 section's VMA is zero, and can omit subtracting it
3009 from the symbol's value to get the address offset. */
3010 know (S_GET_SEGMENT (symbolP
)->vma
== 0);
3011 target
+= S_GET_VALUE (symbolP
) * OCTETS_PER_BYTE
;
3014 know (fragP
->fr_next
);
3015 after
= fragP
->fr_next
->fr_address
+ stretch
;
3016 growth
= target
- after
;
3018 /* Growth may be negative, but variable part of frag
3019 cannot have fewer than 0 chars. That is, we can't
3021 if ((offsetT
) (address
+ fragP
->fr_fix
) > target
)
3025 /* Don't error on first few frag relax passes.
3026 The symbol might be an expression involving
3027 symbol values from other sections. If those
3028 sections have not yet been processed their
3029 frags will all have zero addresses, so we
3030 will calculate incorrect values for them. The
3031 number of passes we allow before giving an
3032 error is somewhat arbitrary. It should be at
3033 least one, with larger values requiring
3034 increasingly contrived dependencies between
3035 frags to trigger a false error. */
3038 /* Force another pass. */
3043 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
3044 _("attempt to move .org backwards"));
3046 /* We've issued an error message. Change the
3047 frag to avoid cascading errors. */
3048 fragP
->fr_type
= rs_align
;
3049 fragP
->fr_subtype
= 0;
3050 fragP
->fr_offset
= 0;
3051 fragP
->fr_fix
= after
- address
;
3063 amount
= S_GET_VALUE (symbolP
);
3064 if (S_GET_SEGMENT (symbolP
) != absolute_section
3065 || S_IS_COMMON (symbolP
)
3066 || ! S_IS_DEFINED (symbolP
))
3068 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
3069 _(".space, .nops or .fill specifies non-absolute value"));
3070 /* Prevent repeat of this error message. */
3071 fragP
->fr_symbol
= 0;
3073 else if (amount
< 0)
3075 /* Don't error on first few frag relax passes.
3076 See rs_org comment for a longer explanation. */
3083 as_warn_where (fragP
->fr_file
, fragP
->fr_line
,
3084 _(".space, .nops or .fill with negative value, ignored"));
3085 fragP
->fr_symbol
= 0;
3088 growth
= (was_address
+ fragP
->fr_fix
+ amount
3089 - fragP
->fr_next
->fr_address
);
3093 case rs_machine_dependent
:
3094 #ifdef md_relax_frag
3095 growth
= md_relax_frag (segment
, fragP
, stretch
);
3097 #ifdef TC_GENERIC_RELAX_TABLE
3098 /* The default way to relax a frag is to look through
3099 TC_GENERIC_RELAX_TABLE. */
3100 growth
= md_generic_table_relax_frag (segment
, fragP
,
3102 #endif /* TC_GENERIC_RELAX_TABLE */
3111 value
= resolve_symbol_value (fragP
->fr_symbol
);
3112 size
= sizeof_leb128 (value
, fragP
->fr_subtype
);
3113 growth
= size
- fragP
->fr_offset
;
3114 fragP
->fr_offset
= size
;
3119 growth
= eh_frame_relax_frag (fragP
);
3123 growth
= dwarf2dbg_relax_frag (fragP
);
3127 growth
= sframe_relax_frag (fragP
);
3131 BAD_CASE (fragP
->fr_type
);
3138 if (fragP
->fr_type
== rs_leb128
)
3139 rs_leb128_fudge
+= 16;
3140 else if (fragP
->fr_type
== rs_align
3141 && (rs_leb128_fudge
& 16) != 0
3143 rs_leb128_fudge
+= 16;
3145 rs_leb128_fudge
= 0;
3150 && (rs_leb128_fudge
& 16) == 0
3151 && (rs_leb128_fudge
& -16) != 0)
3152 rs_leb128_fudge
+= 1;
3154 rs_leb128_fudge
= 0;
3156 /* Until nothing further to relax. */
3157 while (stretched
&& -- max_iterations
);
3160 as_fatal (_("Infinite loop encountered whilst attempting to compute the addresses of symbols in section %s"),
3161 segment_name (segment
));
3164 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
3165 if (fragP
->last_fr_address
!= fragP
->fr_address
)
3167 fragP
->last_fr_address
= fragP
->fr_address
;
3174 number_to_chars_bigendian (char *buf
, valueT val
, int n
)
3180 buf
[n
] = val
& 0xff;
3186 number_to_chars_littleendian (char *buf
, valueT val
, int n
)
3192 *buf
++ = val
& 0xff;
3198 write_print_statistics (FILE *file
)
3200 fprintf (file
, "fixups: %d\n", n_fixups
);
3203 /* For debugging. */
3204 extern int indent_level
;
3207 print_fixup (fixS
*fixp
)
3210 fprintf (stderr
, "fix %p %s:%d", fixp
, fixp
->fx_file
, fixp
->fx_line
);
3212 fprintf (stderr
, " pcrel");
3213 if (fixp
->fx_pcrel_adjust
)
3214 fprintf (stderr
, " pcrel_adjust=%d", fixp
->fx_pcrel_adjust
);
3216 fprintf (stderr
, " tcbit");
3218 fprintf (stderr
, " done");
3219 fprintf (stderr
, "\n size=%d frag=%p", fixp
->fx_size
, fixp
->fx_frag
);
3220 fprintf (stderr
, " where=%ld offset=%" PRIx64
" addnumber=%" PRIx64
,
3221 fixp
->fx_where
, (uint64_t) fixp
->fx_offset
,
3222 (uint64_t) fixp
->fx_addnumber
);
3223 fprintf (stderr
, "\n %s (%d)", bfd_get_reloc_code_name (fixp
->fx_r_type
),
3227 fprintf (stderr
, "\n +<");
3228 print_symbol_value_1 (stderr
, fixp
->fx_addsy
);
3229 fprintf (stderr
, ">");
3233 fprintf (stderr
, "\n -<");
3234 print_symbol_value_1 (stderr
, fixp
->fx_subsy
);
3235 fprintf (stderr
, ">");
3237 fprintf (stderr
, "\n");
3238 #ifdef TC_FIX_DATA_PRINT
3239 TC_FIX_DATA_PRINT (stderr
, fixp
);