1 /* write.c - emit .o file
2 Copyright (C) 1986, 1987, 1990, 1991, 1992, 1993 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 2, 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
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* This thing should be set up to do byteordering correctly. But... */
25 #include "output-file.h"
27 /* The NOP_OPCODE is for the alignment fill value. Fill it with a nop
28 instruction so that the disassembler does not choke on it. */
30 #define NOP_OPCODE 0x00
33 #ifndef WORKING_DOT_WORD
34 extern CONST
int md_short_jump_size
;
35 extern CONST
int md_long_jump_size
;
41 struct frag
*text_frag_root
;
42 struct frag
*data_frag_root
;
43 struct frag
*bss_frag_root
;
45 struct frag
*text_last_frag
; /* Last frag in segment. */
46 struct frag
*data_last_frag
; /* Last frag in segment. */
47 static struct frag
*bss_last_frag
; /* Last frag in segment. */
50 static object_headers headers
;
52 long string_byte_count
;
54 static char *the_object_file
;
56 char *next_object_file_charP
; /* Tracks object file bytes. */
59 int magic_number_for_object_file
= DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE
;
62 #endif /* BFD_ASSEMBLER */
64 static long fixup_segment
PARAMS ((fixS
* fixP
, segT this_segment_type
));
65 static relax_addressT relax_align
PARAMS ((relax_addressT addr
, long align
));
66 void relax_segment
PARAMS ((struct frag
* seg_frag_root
, segT seg_type
));
71 * Create a fixS in obstack 'notes'.
74 fix_new (frag
, where
, size
, add_symbol
, sub_symbol
, offset
, pcrel
, r_type
)
75 fragS
*frag
; /* Which frag? */
76 int where
; /* Where in that frag? */
77 short int size
; /* 1, 2, or 4 usually. */
78 symbolS
*add_symbol
; /* X_add_symbol. */
79 symbolS
*sub_symbol
; /* X_subtract_symbol. */
80 long offset
; /* X_add_number. */
81 int pcrel
; /* TRUE if PC-relative relocation. */
83 bfd_reloc_code_real_type r_type
; /* Relocation type */
85 int r_type
; /* Relocation type */
90 fixP
= (fixS
*) obstack_alloc (¬es
, sizeof (fixS
));
93 fixP
->fx_where
= where
;
95 fixP
->fx_addsy
= add_symbol
;
96 fixP
->fx_subsy
= sub_symbol
;
97 fixP
->fx_offset
= offset
;
98 fixP
->fx_pcrel
= pcrel
;
99 #if defined(NEED_FX_R_TYPE) || defined (BFD_ASSEMBLER)
100 fixP
->fx_r_type
= r_type
;
102 fixP
->fx_im_disp
= 0;
103 fixP
->fx_pcrel_adjust
= 0;
104 fixP
->fx_bit_fixP
= 0;
105 fixP
->fx_addnumber
= 0;
114 /* Usually, we want relocs sorted numerically, but while
115 comparing to older versions of gas that have relocs
116 reverse sorted, it is convenient to have this compile
117 time option. xoxorich. */
122 fixS
**seg_fix_rootP
= & (seg_info (now_seg
)->fix_root
);
123 fixS
**seg_fix_tailP
= & (seg_info (now_seg
)->fix_tail
);
126 #ifdef REVERSE_SORT_RELOCS
128 fixP
->fx_next
= *seg_fix_rootP
;
129 *seg_fix_rootP
= fixP
;
131 #else /* REVERSE_SORT_RELOCS */
133 fixP
->fx_next
= NULL
;
136 (*seg_fix_tailP
)->fx_next
= fixP
;
138 *seg_fix_rootP
= fixP
;
139 *seg_fix_tailP
= fixP
;
141 #endif /* REVERSE_SORT_RELOCS */
148 /* Append a string onto another string, bumping the pointer along. */
150 append (charPP
, fromP
, length
)
153 unsigned long length
;
155 /* Don't trust memcpy() of 0 chars. */
159 memcpy (*charPP
, fromP
, (int) length
);
163 #ifndef BFD_ASSEMBLER
164 int section_alignment
[SEG_MAXIMUM_ORDINAL
];
168 * This routine records the largest alignment seen for each segment.
169 * If the beginning of the segment is aligned on the worst-case
170 * boundary, all of the other alignments within it will work. At
171 * least one object format really uses this info.
174 record_alignment (seg
, align
)
175 /* Segment to which alignment pertains */
177 /* Alignment, as a power of 2 (e.g., 1 => 2-byte boundary, 2 => 4-byte
182 if (align
> bfd_get_section_alignment (stdoutput
, seg
))
183 bfd_set_section_alignment (stdoutput
, seg
, align
);
185 if (align
> section_alignment
[(int) seg
])
186 section_alignment
[(int) seg
] = align
;
190 #if defined (BFD_ASSEMBLER) || ! defined (BFD)
193 chain_frchains_together_1 (section
, frchp
)
195 struct frchain
*frchp
;
197 fragS dummy
, *prev_frag
= &dummy
;
198 for (; frchp
&& frchp
->frch_seg
== section
; frchp
= frchp
->frch_next
)
200 prev_frag
->fr_next
= frchp
->frch_root
;
201 prev_frag
= frchp
->frch_last
;
203 prev_frag
->fr_next
= 0;
212 chain_frchains_together (abfd
, section
, xxx
)
213 bfd
*abfd
; /* unused */
215 char *xxx
; /* unused */
217 segment_info_type
*info
;
219 /* BFD may have introduced its own sections without using
220 subseg_new, so it is possible that seg_info is NULL. */
221 info
= seg_info (section
);
222 if (info
!= (segment_info_type
*) NULL
)
223 chain_frchains_together_1 (section
, info
->frchainP
);
231 remove_subsegs (head
, seg
, root
, last
)
237 *root
= head
->frch_root
;
238 *last
= chain_frchains_together_1 (seg
, head
);
246 cvt_frag_to_fill (x
, fragP
)
257 object_headers
*headers
= x
;
260 switch (fragP
->fr_type
)
265 HANDLE_ALIGN (fragP
);
267 fragP
->fr_type
= rs_fill
;
268 know (fragP
->fr_var
== 1);
269 know (fragP
->fr_next
!= NULL
);
271 fragP
->fr_offset
= (fragP
->fr_next
->fr_address
279 case rs_machine_dependent
:
281 md_convert_frag (stdoutput
, sec
, fragP
);
283 md_convert_frag (headers
, fragP
);
286 assert (fragP
->fr_next
== NULL \
287 || (fragP
->fr_next
->fr_address
- fragP
->fr_address \
291 * After md_convert_frag, we make the frag into a ".space 0".
292 * Md_convert_frag() should set up any fixSs and constants
298 #ifndef WORKING_DOT_WORD
301 struct broken_word
*lie
;
303 if (fragP
->fr_subtype
)
305 fragP
->fr_fix
+= md_short_jump_size
;
306 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
307 lie
&& lie
->dispfrag
== fragP
;
308 lie
= lie
->next_broken_word
)
310 fragP
->fr_fix
+= md_long_jump_size
;
318 BAD_CASE (fragP
->fr_type
);
325 relax_and_size_seg (abfd
, sec
, xxx
)
332 flags
= bfd_get_section_flags (abfd
, sec
);
334 if (flags
& SEC_ALLOC
)
337 segment_info_type
*seginfo
;
339 unsigned long size
, newsize
;
341 seginfo
= (segment_info_type
*) bfd_get_section_userdata (abfd
, sec
);
342 relax_segment (seginfo
->frchainP
->frch_root
, sec
);
343 for (fragp
= seginfo
->frchainP
->frch_root
; fragp
; fragp
= fragp
->fr_next
)
344 cvt_frag_to_fill (sec
, fragp
);
345 for (fragp
= seginfo
->frchainP
->frch_root
;
347 fragp
= fragp
->fr_next
)
348 /* walk to last elt */;
349 size
= fragp
->fr_address
;
352 flags
|= SEC_HAS_CONTENTS
;
353 /* @@ This is just an approximation. */
354 if (seginfo
->fix_root
)
356 x
= bfd_set_section_flags (abfd
, sec
, flags
);
359 size
= md_section_align (sec
, size
);
360 x
= bfd_set_section_size (abfd
, sec
, size
);
363 /* If the size had to be rounded up, add some padding in the last
365 newsize
= bfd_get_section_size_before_reloc (sec
);
366 assert (newsize
>= size
);
369 fragS
*last
= seginfo
->frchainP
->frch_last
;
370 fragp
= seginfo
->frchainP
->frch_root
;
371 while (fragp
->fr_next
!= last
)
372 fragp
= fragp
->fr_next
;
373 last
->fr_address
= size
;
374 fragp
->fr_offset
+= newsize
- size
;
377 #ifdef tc_frob_section
378 tc_frob_section (sec
);
380 #ifdef obj_frob_section
381 obj_frob_section (sec
);
386 write_contents (abfd
, sec
, xxx
)
391 segment_info_type
*seginfo
= seg_info (sec
);
392 unsigned long offset
= 0;
398 if (! (bfd_get_section_flags (abfd
, sec
) & SEC_LOAD
))
401 fixup_segment (seginfo
->fix_root
, sec
);
403 for (i
= 0, fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
406 symbolS
*sym
= fixp
->fx_addsy
;
407 asection
*sec
= sym
->bsym
->section
;
408 if (sec
== &bfd_und_section
409 || sec
== &bfd_abs_section
410 || sec
== &bfd_com_section
)
412 if (sym
->bsym
== sec
->symbol
)
414 /* If the section symbol isn't going to be output, the relocs
415 at least should still work. If not, figure out what to do
416 when we run into that case. */
417 fixp
->fx_offset
+= S_GET_VALUE (sym
);
418 fixp
->fx_addsy
= symbol_find (sec
->name
);
421 fixp
->fx_addsy
= symbol_make (sec
->name
);
422 fixp
->fx_addsy
->bsym
= sec
->symbol
;
426 /* Force calculations (size, vma) to get done. */
427 bfd_set_section_contents (stdoutput
, sec
, "", 0, 0);
429 /* Set up reloc information as well. */
431 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
433 relocs
= (arelent
**) bfd_alloc_by_size_t (stdoutput
,
434 n
* sizeof (arelent
*));
436 for (frags
= seginfo
->frchainP
->frch_root
, fixp
= seginfo
->fix_root
, i
= 0;
438 frags
= frags
->fr_next
)
441 unsigned long fill_size
;
445 assert (frags
->fr_type
== rs_fill
);
447 && fixp
->fx_frag
== frags
)
450 extern arelent
*tc_gen_reloc ();
452 static bfd_reloc_status_type s
;
454 if (fixp
->fx_addsy
== 0)
456 /* @@ Need some other flag to indicate which have already
461 reloc
= tc_gen_reloc (sec
, fixp
);
467 data
= frags
->fr_literal
+ fixp
->fx_where
;
468 if (fixp
->fx_where
+ 4 > frags
->fr_fix
+ frags
->fr_offset
)
470 s
= bfd_perform_relocation (stdoutput
, reloc
, data
- reloc
->address
,
477 printf ("bad s value\n");
482 fixp
= fixp
->fx_next
;
486 x
= bfd_set_section_contents (stdoutput
, sec
,
487 frags
->fr_literal
, offset
,
490 offset
+= frags
->fr_fix
;
492 fill_literal
= frags
->fr_literal
+ frags
->fr_fix
;
493 fill_size
= frags
->fr_var
;
494 count
= frags
->fr_offset
;
496 if (fill_size
&& count
)
499 x
= bfd_set_section_contents (stdoutput
, sec
,
500 fill_literal
, offset
, fill_size
);
505 /* Did we miss any relocs? */
510 bfd_set_reloc (stdoutput
, sec
, relocs
, n
);
517 register struct frchain
*frchainP
; /* Track along all frchains. */
518 register fragS
*fragP
; /* Track along all frags. */
519 register struct frchain
*next_frchainP
;
520 register fragS
**prev_fragPP
;
522 long object_file_size
;
524 /* Do we really want to write it? */
527 n_warns
= had_warnings ();
528 n_errs
= had_errors ();
529 /* The -Z flag indicates that an object file should be generated,
530 regardless of warnings and errors. */
533 if (n_warns
|| n_errs
)
534 as_warn ("%d error%s, %d warning%s, generating bad object file.\n",
535 n_errs
, n_errs
== 1 ? "" : "s",
536 n_warns
, n_warns
== 1 ? "" : "s");
541 as_fatal ("%d error%s, %d warning%s, no object file generated.\n",
542 n_errs
, n_errs
== 1 ? "" : "s",
543 n_warns
, n_warns
== 1 ? "" : "s");
549 * Under VMS we try to be compatible with VAX-11 "C". Thus, we
550 * call a routine to check for the definition of the procedure
551 * "_main", and if so -- fix it up so that it can be program
554 VMS_Check_For_Main ();
557 /* After every sub-segment, we fake an ".align ...". This conforms to
558 BSD4.2 brane-damage. We then fake ".fill 0" because that is the kind of
559 frag that requires least thought. ".align" frags like to have a
560 following frag since that makes calculating their intended length
563 @@ Is this really necessary?? */
564 #ifndef SUB_SEGMENT_ALIGN
566 #define SUB_SEGMENT_ALIGN(SEG) (0)
568 #define SUB_SEGMENT_ALIGN(SEG) (2)
571 for (frchainP
= frchain_root
; frchainP
; frchainP
= frchainP
->frch_next
)
574 subseg_set (frchainP
->frch_seg
, frchainP
->frch_subseg
);
576 subseg_new (frchainP
->frch_seg
, frchainP
->frch_subseg
);
578 frag_align (SUB_SEGMENT_ALIGN (now_seg
), NOP_OPCODE
);
579 /* frag_align will have left a new frag.
580 Use this last frag for an empty ".fill".
583 Create a last frag. Do not leave a "being filled in frag". */
584 frag_wane (frag_now
);
585 frag_now
->fr_fix
= 0;
586 know (frag_now
->fr_next
== NULL
);
587 /* know( frags . obstack_c_base == frags . obstack_c_next_free ); */
588 /* Above shows we haven't left a half-completed object on obstack. */
591 /* From now on, we don't care about sub-segments. Build one frag chain
592 for each segment. Linked thru fr_next. */
595 /* Remove the sections created by gas for its own purposes. */
597 asection
**seclist
, *sec
;
598 seclist
= &stdoutput
->sections
;
599 while (seclist
&& *seclist
)
602 while (sec
== big_section
603 || sec
== reg_section
604 || sec
== pass1_section
605 || sec
== diff_section
606 || sec
== absent_section
)
610 stdoutput
->section_count
--;
615 seclist
= &(*seclist
)->next
;
619 bfd_map_over_sections (stdoutput
, chain_frchains_together
, (char *) 0);
621 remove_subsegs (frchain_root
, SEG_TEXT
, &text_frag_root
, &text_last_frag
);
622 remove_subsegs (data0_frchainP
, SEG_DATA
, &data_frag_root
, &data_last_frag
);
623 remove_subsegs (bss0_frchainP
, SEG_BSS
, &bss_frag_root
, &bss_last_frag
);
626 /* We have two segments. If user gave -R flag, then we must put the
627 data frags into the text segment. Do this before relaxing so
628 we know to take advantage of -R and make shorter addresses. */
629 #if !defined (OBJ_AOUT) || defined (BFD_ASSEMBLER)
633 seg_info (text_section
)->frchainP
->frch_last
->fr_next
=
634 seg_info (data_section
)->frchainP
->frch_root
;
635 seg_info (text_section
)->frchainP
->frch_last
=
636 seg_info (data_section
)->frchainP
->frch_last
;
637 seg_info (data_section
)->frchainP
= 0;
641 text_last_frag
->fr_next
= data_frag_root
;
642 text_last_frag
= data_last_frag
;
643 data_last_frag
= NULL
;
644 data_frag_root
= NULL
;
647 for (tmp
= text_fix_root
; tmp
->fx_next
; tmp
= tmp
->fx_next
);;
648 tmp
->fx_next
= data_fix_root
;
649 text_fix_tail
= data_fix_tail
;
652 text_fix_root
= data_fix_root
;
653 data_fix_root
= NULL
;
659 bfd_map_over_sections (stdoutput
, relax_and_size_seg
, (char *) 0);
661 relax_segment (text_frag_root
, SEG_TEXT
);
662 relax_segment (data_frag_root
, SEG_DATA
);
663 relax_segment (bss_frag_root
, SEG_BSS
);
665 * Now the addresses of frags are correct within the segment.
668 know (text_last_frag
->fr_type
== rs_fill
&& text_last_frag
->fr_offset
== 0);
669 H_SET_TEXT_SIZE (&headers
, text_last_frag
->fr_address
);
670 text_last_frag
->fr_address
= H_GET_TEXT_SIZE (&headers
);
673 * Join the 2 segments into 1 huge segment.
674 * To do this, re-compute every rn_address in the SEG_DATA frags.
675 * Then join the data frags after the text frags.
677 * Determine a_data [length of data segment].
681 register relax_addressT slide
;
683 know ((text_last_frag
->fr_type
== rs_fill
) && (text_last_frag
->fr_offset
== 0));
685 H_SET_DATA_SIZE (&headers
, data_last_frag
->fr_address
);
686 data_last_frag
->fr_address
= H_GET_DATA_SIZE (&headers
);
687 slide
= H_GET_TEXT_SIZE (&headers
); /* & in file of the data segment. */
689 #define RoundUp(N,S) (((N)+(S)-1)&-(S))
690 /* For b.out: If the data section has a strict alignment
691 requirement, its load address in the .o file will be
692 rounded up from the size of the text section. These
693 two values are *not* the same! Similarly for the bss
695 slide
= RoundUp (slide
, 1 << section_alignment
[SEG_DATA
]);
698 for (fragP
= data_frag_root
; fragP
; fragP
= fragP
->fr_next
)
700 fragP
->fr_address
+= slide
;
701 } /* for each data frag */
703 know (text_last_frag
!= 0);
704 text_last_frag
->fr_next
= data_frag_root
;
708 H_SET_DATA_SIZE (&headers
, 0);
712 /* See above comments on b.out data section address. */
715 if (data_last_frag
== 0)
716 bss_vma
= H_GET_TEXT_SIZE (&headers
);
718 bss_vma
= data_last_frag
->fr_address
;
719 bss_vma
= RoundUp (bss_vma
, 1 << section_alignment
[SEG_BSS
]);
720 bss_address_frag
.fr_address
= bss_vma
;
722 #else /* ! OBJ_BOUT */
723 bss_address_frag
.fr_address
= (H_GET_TEXT_SIZE (&headers
) +
724 H_GET_DATA_SIZE (&headers
));
727 /* Slide all the frags */
730 relax_addressT slide
= bss_address_frag
.fr_address
;
732 for (fragP
= bss_frag_root
; fragP
; fragP
= fragP
->fr_next
)
734 fragP
->fr_address
+= slide
;
735 } /* for each bss frag */
738 #endif /* ! OBJ_BOUT */
741 H_SET_BSS_SIZE (&headers
,
742 bss_last_frag
->fr_address
- bss_frag_root
->fr_address
);
744 H_SET_BSS_SIZE (&headers
, 0);
745 #endif /* BFD_ASSEMBLER */
747 #ifndef BFD_ASSEMBLER
750 * Crawl the symbol chain.
752 * For each symbol whose value depends on a frag, take the address of
753 * that frag and subsume it into the value of the symbol.
754 * After this, there is just one way to lookup a symbol value.
755 * Values are left in their final state for object file emission.
756 * We adjust the values of 'L' local symbols, even if we do
757 * not intend to emit them to the object file, because their values
758 * are needed for fix-ups.
760 * Unless we saw a -L flag, remove all symbols that begin with 'L'
761 * from the symbol chain. (They are still pointed to by the fixes.)
763 * Count the remaining symbols.
764 * Assign a symbol number to each symbol.
765 * Count the number of string-table chars we will emit.
766 * Put this info into the headers as appropriate.
769 know (zero_address_frag
.fr_address
== 0);
770 string_byte_count
= sizeof (string_byte_count
);
772 obj_crawl_symbol_chain (&headers
);
774 if (string_byte_count
== sizeof (string_byte_count
))
775 string_byte_count
= 0;
777 H_SET_STRING_SIZE (&headers
, string_byte_count
);
780 * Addresses of frags now reflect addresses we use in the object file.
781 * Symbol values are correct.
782 * Scan the frags, converting any ".org"s and ".align"s to ".fill"s.
783 * Also converting any machine-dependent frags using md_convert_frag();
785 subseg_change (SEG_TEXT
, 0);
787 for (fragP
= text_frag_root
; fragP
; fragP
= fragP
->fr_next
)
789 cvt_frag_to_fill (&headers
, fragP
);
791 /* Some assert macros don't work with # directives mixed in. */
793 if (!(fragP
->fr_next
== NULL
795 || fragP
->fr_next
== data_frag_root
797 || ((fragP
->fr_next
->fr_address
- fragP
->fr_address
)
798 == (fragP
->fr_fix
+ fragP
->fr_offset
* fragP
->fr_var
))))
802 #endif /* ! BFD_ASSEMBLER */
804 #ifndef WORKING_DOT_WORD
806 struct broken_word
*lie
;
807 struct broken_word
**prevP
;
809 prevP
= &broken_words
;
810 for (lie
= broken_words
; lie
; lie
= lie
->next_broken_word
)
814 fix_new (lie
->frag
, lie
->word_goes_here
- lie
->frag
->fr_literal
,
815 2, lie
->add
, lie
->sub
, lie
->addnum
, 0, BFD_RELOC_NONE
);
817 #if defined(TC_SPARC) || defined(TC_A29K) || defined(NEED_FX_R_TYPE)
818 fix_new (lie
->frag
, lie
->word_goes_here
- lie
->frag
->fr_literal
,
820 lie
->sub
, lie
->addnum
,
824 fix_new_ns32k (lie
->frag
,
825 lie
->word_goes_here
- lie
->frag
->fr_literal
,
832 fix_new (lie
->frag
, lie
->word_goes_here
- lie
->frag
->fr_literal
,
834 lie
->sub
, lie
->addnum
,
836 #endif /* TC_NS32K */
837 #endif /* TC_SPARC|TC_A29K|NEED_FX_R_TYPE */
838 #endif /* BFD_ASSEMBLER */
839 *prevP
= lie
->next_broken_word
;
842 prevP
= &(lie
->next_broken_word
);
844 for (lie
= broken_words
; lie
;)
846 struct broken_word
*untruth
;
849 long from_addr
, to_addr
;
852 fragP
= lie
->dispfrag
;
854 /* Find out how many broken_words go here. */
856 for (untruth
= lie
; untruth
&& untruth
->dispfrag
== fragP
; untruth
= untruth
->next_broken_word
)
857 if (untruth
->added
== 1)
860 table_ptr
= lie
->dispfrag
->fr_opcode
;
861 table_addr
= lie
->dispfrag
->fr_address
+ (table_ptr
- lie
->dispfrag
->fr_literal
);
862 /* Create the jump around the long jumps. This is a short
863 jump from table_ptr+0 to table_ptr+n*long_jump_size. */
864 from_addr
= table_addr
;
865 to_addr
= table_addr
+ md_short_jump_size
+ n
* md_long_jump_size
;
866 md_create_short_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
, lie
->add
);
867 table_ptr
+= md_short_jump_size
;
868 table_addr
+= md_short_jump_size
;
870 for (m
= 0; lie
&& lie
->dispfrag
== fragP
; m
++, lie
= lie
->next_broken_word
)
874 /* Patch the jump table */
875 /* This is the offset from ??? to table_ptr+0 */
877 - S_GET_VALUE (lie
->sub
);
878 md_number_to_chars (lie
->word_goes_here
, to_addr
, 2);
879 for (untruth
= lie
->next_broken_word
; untruth
&& untruth
->dispfrag
== fragP
; untruth
= untruth
->next_broken_word
)
881 if (untruth
->use_jump
== lie
)
882 md_number_to_chars (untruth
->word_goes_here
, to_addr
, 2);
885 /* Install the long jump */
886 /* this is a long jump from table_ptr+0 to the final target */
887 from_addr
= table_addr
;
888 to_addr
= S_GET_VALUE (lie
->add
) + lie
->addnum
;
889 md_create_long_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
, lie
->add
);
890 table_ptr
+= md_long_jump_size
;
891 table_addr
+= md_long_jump_size
;
895 #endif /* not WORKING_DOT_WORD */
897 #ifndef BFD_ASSEMBLER
901 * Scan every FixS performing fixups. We had to wait until now to do
902 * this because md_convert_frag() may have made some fixSs.
906 subseg_change (SEG_TEXT
, 0);
907 trsize
= md_reloc_size
* fixup_segment (text_fix_root
,
909 subseg_change (SEG_DATA
, 0);
910 drsize
= md_reloc_size
* fixup_segment (data_fix_root
,
912 H_SET_RELOCATION_SIZE (&headers
, trsize
, drsize
);
914 /* FIXME move this stuff into the pre-write-hook */
915 H_SET_MAGIC_NUMBER (&headers
, magic_number_for_object_file
);
916 H_SET_ENTRY_POINT (&headers
, 0);
918 obj_pre_write_hook (&headers
); /* extra coff stuff */
920 object_file_size
= H_GET_FILE_SIZE (&headers
);
921 next_object_file_charP
= the_object_file
= xmalloc (object_file_size
);
923 output_file_create (out_file_name
);
925 obj_header_append (&next_object_file_charP
, &headers
);
927 know ((next_object_file_charP
- the_object_file
) == H_GET_HEADER_SIZE (&headers
));
932 for (fragP
= text_frag_root
; fragP
; fragP
= fragP
->fr_next
)
935 register char *fill_literal
;
936 register long fill_size
;
938 know (fragP
->fr_type
== rs_fill
);
939 append (&next_object_file_charP
, fragP
->fr_literal
, (unsigned long) fragP
->fr_fix
);
940 fill_literal
= fragP
->fr_literal
+ fragP
->fr_fix
;
941 fill_size
= fragP
->fr_var
;
942 know (fragP
->fr_offset
>= 0);
944 for (count
= fragP
->fr_offset
; count
; count
--)
946 append (&next_object_file_charP
, fill_literal
, (unsigned long) fill_size
);
949 } /* for each code frag. */
951 know ((next_object_file_charP
- the_object_file
) == (H_GET_HEADER_SIZE (&headers
) + H_GET_TEXT_SIZE (&headers
) + H_GET_DATA_SIZE (&headers
)));
956 obj_emit_relocations (&next_object_file_charP
, text_fix_root
, (relax_addressT
) 0);
957 know ((next_object_file_charP
- the_object_file
) == (H_GET_HEADER_SIZE (&headers
) + H_GET_TEXT_SIZE (&headers
) + H_GET_DATA_SIZE (&headers
) + H_GET_TEXT_RELOCATION_SIZE (&headers
)));
959 /* Make addresses in data relocation directives relative to beginning of
960 * first data fragment, not end of last text fragment: alignment of the
961 * start of the data segment may place a gap between the segments.
963 obj_emit_relocations (&next_object_file_charP
, data_fix_root
, data0_frchainP
->frch_root
->fr_address
);
965 obj_emit_relocations (&next_object_file_charP
, data_fix_root
, text_last_frag
->fr_address
);
968 know ((next_object_file_charP
- the_object_file
) == (H_GET_HEADER_SIZE (&headers
) + H_GET_TEXT_SIZE (&headers
) + H_GET_DATA_SIZE (&headers
) + H_GET_TEXT_RELOCATION_SIZE (&headers
) + H_GET_DATA_RELOCATION_SIZE (&headers
)));
971 * Emit line number entries.
973 OBJ_EMIT_LINENO (&next_object_file_charP
, lineno_rootP
, the_object_file
);
974 know ((next_object_file_charP
- the_object_file
) == (H_GET_HEADER_SIZE (&headers
) + H_GET_TEXT_SIZE (&headers
) + H_GET_DATA_SIZE (&headers
) + H_GET_TEXT_RELOCATION_SIZE (&headers
) + H_GET_DATA_RELOCATION_SIZE (&headers
) + H_GET_LINENO_SIZE (&headers
)));
979 obj_emit_symbols (&next_object_file_charP
, symbol_rootP
);
980 know ((next_object_file_charP
- the_object_file
) == (H_GET_HEADER_SIZE (&headers
) + H_GET_TEXT_SIZE (&headers
) + H_GET_DATA_SIZE (&headers
) + H_GET_TEXT_RELOCATION_SIZE (&headers
) + H_GET_DATA_RELOCATION_SIZE (&headers
) + H_GET_LINENO_SIZE (&headers
) + H_GET_SYMBOL_TABLE_SIZE (&headers
)));
986 if (string_byte_count
> 0)
988 obj_emit_strings (&next_object_file_charP
);
989 } /* only if we have a string table */
992 bfd_seek (stdoutput
, 0, 0);
993 bfd_write (the_object_file
, 1, object_file_size
, stdoutput
);
996 /* Write the data to the file */
997 output_file_append (the_object_file
, object_file_size
, out_file_name
);
1000 output_file_close (out_file_name
);
1001 } /* non vms output */
1004 * Now do the VMS-dependent part of writing the object file
1006 VMS_write_object_file (H_GET_TEXT_SIZE (&headers
),
1007 H_GET_DATA_SIZE (&headers
),
1008 H_GET_BSS_SIZE (&headers
),
1009 text_frag_root
, data_frag_root
);
1011 #else /* BFD_ASSEMBLER */
1013 /* Set up symbol table, and write it out. */
1019 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
1021 S_SET_VALUE (symp
, S_GET_VALUE (symp
) + symp
->sy_frag
->fr_address
);
1022 /* So far, common symbols have been treated like undefined symbols.
1023 Put them in the common section now. */
1024 if (S_IS_DEFINED (symp
) == 0
1025 && S_GET_VALUE (symp
) != 0)
1026 S_SET_SEGMENT (symp
, &bfd_com_section
);
1028 printf ("symbol `%s'\n\t@%x: value=%d type=%d forward=%x seg=%s\n",
1029 S_GET_NAME (symp
), symp
,
1031 S_GET_DATA_TYPE (symp
),
1033 segment_name (symp
->bsym
->section
));
1037 #ifdef obj_frob_symbol
1038 obj_frob_symbol (symp
, punt
);
1042 #ifdef tc_frob_symbol
1043 tc_frob_symbol (symp
, punt
);
1048 /* If we don't want to keep this symbol, splice it out of the
1050 if (S_IS_LOCAL (symp
))
1052 symbolS
*prev
, *next
;
1054 prev
= symbol_previous (symp
);
1055 next
= symbol_next (symp
);
1057 /* debugging: verify consistency */
1059 symbolS
*p
= symp
, *n
= symp
;
1060 while (symbol_previous (p
))
1061 p
= symbol_previous (p
);
1062 while (symbol_next (n
))
1063 n
= symbol_next (n
);
1064 verify_symbol_chain (p
, n
);
1069 symbol_next (prev
) = next
;
1075 symbol_previous (next
) = prev
;
1077 symbol_lastP
= prev
;
1079 /* debugging: verify consistency */
1081 symbolS
*p
= symp
, *n
= symp
;
1082 while (symbol_previous (p
))
1083 p
= symbol_previous (p
);
1084 while (symbol_next (n
))
1085 n
= symbol_next (n
);
1086 verify_symbol_chain (p
, n
);
1099 asympp
= (asymbol
**) bfd_alloc (stdoutput
, n
* sizeof (asymbol
*));
1100 symp
= symbol_rootP
;
1101 for (i
= 0; i
< n
; i
++, symp
= symbol_next (symp
))
1103 asympp
[i
] = symp
->bsym
;
1106 result
= bfd_set_symtab (stdoutput
, asympp
, n
);
1107 assert (result
== true);
1111 #ifdef obj_frob_file
1115 /* Now that all the sizes are known, and contents correct, we can
1116 start writing the file. */
1117 bfd_map_over_sections (stdoutput
, write_contents
, (char *) 0);
1119 output_file_close (out_file_name
);
1120 #endif /* BFD_ASSEMBLER */
1127 * Now we have a segment, not a crowd of sub-segments, we can make fr_address
1132 * After this, all frags in this segment have addresses that are correct
1133 * within the segment. Since segments live in different file addresses,
1134 * these frag addresses may not be the same as final object-file addresses.
1143 for (; f1
; f1
= f1
->fr_next
)
1144 if (f1
->fr_next
== f2
)
1149 /* Relax_align. Advance location counter to next address that has 'alignment'
1150 lowest order bits all 0s. */
1152 /* How many addresses does the .align take? */
1153 static relax_addressT
1154 relax_align (address
, alignment
)
1155 register relax_addressT address
; /* Address now. */
1156 register long alignment
; /* Alignment (binary). */
1158 relax_addressT mask
;
1159 relax_addressT new_address
;
1161 mask
= ~((~0) << alignment
);
1162 new_address
= (address
+ mask
) & (~mask
);
1164 /* We must provide lots of padding, so the linker can discard it
1165 when needed. The linker will not add extra space, ever. */
1166 new_address
+= (1 << alignment
);
1167 return (new_address
- address
);
1171 relax_segment (segment_frag_root
, segment
)
1172 struct frag
*segment_frag_root
;
1175 register struct frag
*fragP
;
1176 register relax_addressT address
;
1177 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
1178 know (segment
== SEG_DATA
|| segment
== SEG_TEXT
|| segment
== SEG_BSS
);
1180 /* In case md_estimate_size_before_relax() wants to make fixSs. */
1181 subseg_change (segment
, 0);
1183 /* For each frag in segment: count and store (a 1st guess of)
1186 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
1188 fragP
->fr_address
= address
;
1189 address
+= fragP
->fr_fix
;
1191 switch (fragP
->fr_type
)
1194 address
+= fragP
->fr_offset
* fragP
->fr_var
;
1198 address
+= relax_align (address
, fragP
->fr_offset
);
1202 /* Assume .org is nugatory. It will grow with 1st relax. */
1205 case rs_machine_dependent
:
1206 address
+= md_estimate_size_before_relax (fragP
, segment
);
1209 #ifndef WORKING_DOT_WORD
1210 /* Broken words don't concern us yet */
1211 case rs_broken_word
:
1216 BAD_CASE (fragP
->fr_type
);
1218 } /* switch(fr_type) */
1219 } /* for each frag in the segment */
1223 long stretch
; /* May be any size, 0 or negative. */
1224 /* Cumulative number of addresses we have */
1225 /* relaxed this pass. */
1226 /* We may have relaxed more than one address. */
1227 long stretched
; /* Have we stretched on this pass? */
1228 /* This is 'cuz stretch may be zero, when, in fact some piece of code
1229 grew, and another shrank. If a branch instruction doesn't fit anymore,
1230 we could be scrod. */
1234 stretch
= stretched
= 0;
1235 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
1238 unsigned long was_address
;
1245 was_address
= fragP
->fr_address
;
1246 address
= fragP
->fr_address
+= stretch
;
1247 symbolP
= fragP
->fr_symbol
;
1248 offset
= fragP
->fr_offset
;
1250 switch (fragP
->fr_type
)
1252 case rs_fill
: /* .fill never relaxes. */
1256 #ifndef WORKING_DOT_WORD
1257 /* JF: This is RMS's idea. I do *NOT* want to be blamed
1258 for it I do not want to write it. I do not want to have
1259 anything to do with it. This is not the proper way to
1260 implement this misfeature. */
1261 case rs_broken_word
:
1263 struct broken_word
*lie
;
1264 struct broken_word
*untruth
;
1266 /* Yes this is ugly (storing the broken_word pointer
1267 in the symbol slot). Still, this whole chunk of
1268 code is ugly, and I don't feel like doing anything
1269 about it. Think of it as stubbornness in action. */
1271 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
1272 lie
&& lie
->dispfrag
== fragP
;
1273 lie
= lie
->next_broken_word
)
1279 offset
= (lie
->add
->sy_frag
->fr_address
1280 + S_GET_VALUE (lie
->add
)
1282 - (lie
->sub
->sy_frag
->fr_address
1283 + S_GET_VALUE (lie
->sub
)));
1284 if (offset
<= -32768 || offset
>= 32767)
1287 as_warn (".word %s-%s+%ld didn't fit",
1288 S_GET_NAME (lie
->add
),
1289 S_GET_NAME (lie
->sub
),
1292 if (fragP
->fr_subtype
== 0)
1294 fragP
->fr_subtype
++;
1295 growth
+= md_short_jump_size
;
1297 for (untruth
= lie
->next_broken_word
;
1298 untruth
&& untruth
->dispfrag
== lie
->dispfrag
;
1299 untruth
= untruth
->next_broken_word
)
1300 if ((untruth
->add
->sy_frag
== lie
->add
->sy_frag
)
1301 && S_GET_VALUE (untruth
->add
) == S_GET_VALUE (lie
->add
))
1304 untruth
->use_jump
= lie
;
1306 growth
+= md_long_jump_size
;
1311 } /* case rs_broken_word */
1314 growth
= (relax_align ((relax_addressT
) (address
1317 - relax_align ((relax_addressT
) (was_address
1327 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
1328 know ((S_GET_SEGMENT (symbolP
) == SEG_ABSOLUTE
)
1329 || (S_GET_SEGMENT (symbolP
) == SEG_DATA
)
1330 || (S_GET_SEGMENT (symbolP
) == SEG_TEXT
)
1331 || S_GET_SEGMENT (symbolP
) == SEG_BSS
);
1332 know (symbolP
->sy_frag
);
1333 know (!(S_GET_SEGMENT (symbolP
) == SEG_ABSOLUTE
)
1334 || (symbolP
->sy_frag
== &zero_address_frag
));
1336 target
+= S_GET_VALUE (symbolP
)
1337 + symbolP
->sy_frag
->fr_address
;
1338 } /* if we have a symbol */
1340 know (fragP
->fr_next
);
1341 after
= fragP
->fr_next
->fr_address
;
1342 growth
= ((target
- after
) > 0) ? (target
- after
) : 0;
1343 /* Growth may be negative, but variable part of frag
1344 cannot have fewer than 0 chars. That is, we can't
1347 growth
-= stretch
; /* This is an absolute growth factor */
1350 case rs_machine_dependent
:
1352 const relax_typeS
*this_type
;
1353 const relax_typeS
*start_type
;
1354 relax_substateT next_state
;
1355 relax_substateT this_state
;
1357 this_state
= fragP
->fr_subtype
;
1358 start_type
= this_type
= md_relax_table
+ this_state
;
1363 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
1364 know ((S_GET_SEGMENT (symbolP
) == SEG_ABSOLUTE
)
1365 || (S_GET_SEGMENT (symbolP
) == SEG_DATA
)
1366 || (S_GET_SEGMENT (symbolP
) == SEG_BSS
)
1367 || (S_GET_SEGMENT (symbolP
) == SEG_TEXT
));
1369 know (symbolP
->sy_frag
);
1370 know (!(S_GET_SEGMENT (symbolP
) == absolute_section
)
1371 || symbolP
->sy_frag
== &zero_address_frag
);
1373 S_GET_VALUE (symbolP
)
1374 + symbolP
->sy_frag
->fr_address
;
1376 /* If frag has yet to be reached on this pass,
1377 assume it will move by STRETCH just as we did.
1378 If this is not so, it will be because some frag
1379 between grows, and that will force another pass. */
1381 /* JF was just address */
1382 /* JF also added is_dnrange hack */
1383 /* There's gotta be a better/faster/etc way
1385 /* gnu@cygnus.com: I changed this from > to >=
1386 because I ran into a zero-length frag (fr_fix=0)
1387 which was created when the obstack needed a new
1388 chunk JUST AFTER the opcode of a branch. Since
1389 fr_fix is zero, fr_address of this frag is the same
1390 as fr_address of the next frag. This
1391 zero-length frag was variable and jumped to .+2
1392 (in the next frag), but since the > comparison
1393 below failed (the two were =, not >), "stretch"
1394 was not added to the target. Stretch was 178, so
1395 the offset appeared to be .-176 instead, which did
1396 not fit into a byte branch, so the assembler
1397 relaxed the branch to a word. This didn't compare
1398 with what happened when the same source file was
1399 assembled on other machines, which is how I found it.
1400 You might want to think about what other places have
1401 trouble with zero length frags... */
1403 if (symbolP
->sy_frag
->fr_address
>= was_address
1404 && is_dnrange (fragP
, symbolP
->sy_frag
))
1408 } /* if there's a symbol attached */
1410 aim
= target
- address
- fragP
->fr_fix
;
1411 /* The displacement is affected by the instruction size
1412 for the 32k architecture. I think we ought to be able
1413 to add fragP->fr_pcrel_adjust in all cases (it should be
1414 zero if not used), but just in case it breaks something
1415 else we'll put this inside #ifdef NS32K ... #endif */
1417 aim
+= fragP
->fr_pcrel_adjust
;
1418 #endif /* TC_NS32K */
1422 /* Look backwards. */
1423 for (next_state
= this_type
->rlx_more
; next_state
;)
1424 if (aim
>= this_type
->rlx_backward
)
1428 /* Grow to next state. */
1429 this_state
= next_state
;
1430 this_type
= md_relax_table
+ this_state
;
1431 next_state
= this_type
->rlx_more
;
1436 #ifdef M68K_AIM_KLUDGE
1437 M68K_AIM_KLUDGE (aim
, this_state
, this_type
);
1439 /* Look forwards. */
1440 for (next_state
= this_type
->rlx_more
; next_state
;)
1441 if (aim
<= this_type
->rlx_forward
)
1445 /* Grow to next state. */
1446 this_state
= next_state
;
1447 this_type
= md_relax_table
+ this_state
;
1448 next_state
= this_type
->rlx_more
;
1452 growth
= this_type
->rlx_length
- start_type
->rlx_length
;
1454 fragP
->fr_subtype
= this_state
;
1459 BAD_CASE (fragP
->fr_type
);
1467 } /* For each frag in the segment. */
1469 while (stretched
); /* Until nothing further to relax. */
1473 * We now have valid fr_address'es for each frag.
1477 * All fr_address's are correct, relative to their own segment.
1478 * We have made all the fixS we will ever make.
1480 } /* relax_segment() */
1484 Go through all the fixS's in a segment and see which ones can be
1485 handled now. (These consist of fixS where we have since discovered
1486 the value of a symbol, or the address of the frag involved.)
1487 For each one, call md_apply_fix to put the fix into the frag data.
1489 Result is a count of how many relocation structs will be needed to
1490 handle the remaining fixS's that we couldn't completely handle here.
1491 These will be output later by emit_relocations(). */
1494 fixup_segment (fixP
, this_segment_type
)
1495 register fixS
*fixP
;
1496 segT this_segment_type
; /* N_TYPE bits for segment. */
1498 register long seg_reloc_count
;
1499 register symbolS
*add_symbolP
;
1500 register symbolS
*sub_symbolP
;
1503 register char *place
;
1504 register long where
;
1505 register char pcrel
;
1506 register fragS
*fragP
;
1507 register segT add_symbol_segment
= absolute_section
;
1509 seg_reloc_count
= 0;
1510 /* If the linker is doing the relaxing, we must not do any fixups */
1512 for (; fixP
; fixP
= fixP
->fx_next
)
1515 for (; fixP
; fixP
= fixP
->fx_next
)
1517 fragP
= fixP
->fx_frag
;
1519 where
= fixP
->fx_where
;
1520 place
= fragP
->fr_literal
+ where
;
1521 size
= fixP
->fx_size
;
1522 add_symbolP
= fixP
->fx_addsy
;
1524 if (fixP
->fx_callj
&& TC_S_IS_CALLNAME (add_symbolP
))
1526 /* Relocation should be done via the associated 'bal'
1527 entry point symbol. */
1529 if (!TC_S_IS_BALNAME (tc_get_bal_of_call (add_symbolP
)))
1531 as_bad ("No 'bal' entry point for leafproc %s",
1532 S_GET_NAME (add_symbolP
));
1535 fixP
->fx_addsy
= add_symbolP
= tc_get_bal_of_call (add_symbolP
);
1538 sub_symbolP
= fixP
->fx_subsy
;
1539 add_number
= fixP
->fx_offset
;
1540 pcrel
= fixP
->fx_pcrel
;
1543 add_symbol_segment
= S_GET_SEGMENT (add_symbolP
);
1550 if (S_GET_SEGMENT (sub_symbolP
) != absolute_section
)
1551 as_bad ("Negative of non-absolute symbol %s",
1552 S_GET_NAME (sub_symbolP
));
1554 add_number
-= S_GET_VALUE (sub_symbolP
);
1556 else if ((S_GET_SEGMENT (sub_symbolP
) == add_symbol_segment
)
1557 && (SEG_NORMAL (add_symbol_segment
)
1558 || (add_symbol_segment
== absolute_section
)))
1560 /* Difference of 2 symbols from same segment.
1561 Can't make difference of 2 undefineds: 'value' means
1562 something different for N_UNDF. */
1564 /* Makes no sense to use the difference of 2 arbitrary symbols
1565 as the target of a call instruction. */
1568 as_bad ("callj to difference of 2 symbols");
1570 #endif /* TC_I960 */
1571 add_number
+= S_GET_VALUE (add_symbolP
) -
1572 S_GET_VALUE (sub_symbolP
);
1575 fixP
->fx_addsy
= NULL
;
1579 /* Different segments in subtraction. */
1580 know (!(S_IS_EXTERNAL (sub_symbolP
)
1581 && (S_GET_SEGMENT (sub_symbolP
) == absolute_section
)));
1583 if ((S_GET_SEGMENT (sub_symbolP
) == absolute_section
))
1585 add_number
-= S_GET_VALUE (sub_symbolP
);
1589 as_bad ("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
1590 segment_name (S_GET_SEGMENT (sub_symbolP
)),
1591 S_GET_NAME (sub_symbolP
), fragP
->fr_address
+ where
);
1594 } /* if sub_symbolP */
1598 if (add_symbol_segment
== this_segment_type
&& pcrel
)
1601 * This fixup was made when the symbol's segment was
1602 * SEG_UNKNOWN, but it is now in the local segment.
1603 * So we know how to do the address without relocation.
1606 /* reloc_callj() may replace a 'call' with a 'calls' or a
1607 'bal', in which cases it modifies *fixP as appropriate.
1608 In the case of a 'calls', no further work is required,
1609 and *fixP has been set up to make the rest of the code
1612 #endif /* TC_I960 */
1614 add_number
+= S_GET_VALUE (add_symbolP
);
1615 add_number
-= md_pcrel_from (fixP
);
1616 pcrel
= 0; /* Lie. Don't want further pcrel processing. */
1617 fixP
->fx_addsy
= NULL
; /* No relocations please. */
1621 if (add_symbol_segment
== absolute_section
)
1624 /* See comment about reloc_callj() above. */
1626 #endif /* TC_I960 */
1627 add_number
+= S_GET_VALUE (add_symbolP
);
1628 fixP
->fx_addsy
= NULL
;
1631 else if (add_symbol_segment
== undefined_section
1632 #ifdef BFD_ASSEMBLER
1633 || add_symbol_segment
== &bfd_com_section
1638 if ((int) fixP
->fx_bit_fixP
== 13)
1640 /* This is a COBR instruction. They have only a
1641 * 13-bit displacement and are only to be used
1642 * for local branches: flag as error, don't generate
1645 as_bad ("can't use COBR format with external label");
1646 fixP
->fx_addsy
= NULL
; /* No relocations please. */
1649 #endif /* TC_I960 */
1653 if (S_IS_COMMON (add_symbolP
))
1654 add_number
+= S_GET_VALUE (add_symbolP
);
1655 #endif /* TE_I386AIX */
1656 #endif /* OBJ_COFF */
1662 add_number
+= S_GET_VALUE (add_symbolP
);
1664 } /* if not in local seg */
1665 } /* if there was a + symbol */
1669 add_number
-= md_pcrel_from (fixP
);
1670 if (add_symbolP
== 0)
1672 fixP
->fx_addsy
= &abs_symbol
;
1674 } /* if there's an add_symbol */
1677 if (!fixP
->fx_bit_fixP
)
1680 (add_number
& ~0xFF)
1681 && ((add_number
& ~0xFF) != (-1 & ~0xFF)))
1683 && (add_number
& ~0xFFFF)
1684 && ((add_number
& ~0xFFFF) != (-1 & ~0xFFFF))))
1686 as_bad ("Value of %d too large for field of %d bytes at 0x%x",
1687 add_number
, size
, fragP
->fr_address
+ where
);
1688 } /* generic error checking */
1689 #ifdef WARN_SIGNED_OVERFLOW_WORD
1690 /* Warn if a .word value is too large when treated as a signed
1691 number. We already know it is not too negative. This is to
1692 catch over-large switches generated by gcc on the 68k. */
1695 && add_number
> 0x7fff)
1696 as_bad ("Signed .word overflow; switch may be too large; %d at 0x%x",
1697 add_number
, fragP
->fr_address
+ where
);
1699 } /* not a bit fix */
1701 #ifdef BFD_ASSEMBLER
1702 md_apply_fix (fixP
, &add_number
);
1704 md_apply_fix (fixP
, add_number
);
1706 } /* For each fixS in this segment. */
1713 /* two relocs per callj under coff. */
1714 for (fixP
= topP
; fixP
; fixP
= fixP
->fx_next
)
1716 if (fixP
->fx_callj
&& fixP
->fx_addsy
!= 0)
1719 } /* if callj and not already fixed. */
1720 } /* for each fix */
1722 #endif /* TC_I960 */
1724 #endif /* OBJ_COFF */
1725 return (seg_reloc_count
);
1726 } /* fixup_segment() */
1728 /* end of write.c */