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 chain_frchains_together_1 (section
, seg_info (section
)->frchainP
);
225 remove_subsegs (head
, seg
, root
, last
)
231 *root
= head
->frch_root
;
232 *last
= chain_frchains_together_1 (seg
, head
);
240 cvt_frag_to_fill (x
, fragP
)
251 object_headers
*headers
= x
;
254 switch (fragP
->fr_type
)
259 HANDLE_ALIGN (fragP
);
261 fragP
->fr_type
= rs_fill
;
262 know (fragP
->fr_var
== 1);
263 know (fragP
->fr_next
!= NULL
);
265 fragP
->fr_offset
= (fragP
->fr_next
->fr_address
273 case rs_machine_dependent
:
275 md_convert_frag (stdoutput
, sec
, fragP
);
277 md_convert_frag (headers
, fragP
);
280 assert (fragP
->fr_next
== NULL
281 || (fragP
->fr_next
->fr_address
- fragP
->fr_address
285 * After md_convert_frag, we make the frag into a ".space 0".
286 * Md_convert_frag() should set up any fixSs and constants
292 #ifndef WORKING_DOT_WORD
295 struct broken_word
*lie
;
297 if (fragP
->fr_subtype
)
299 fragP
->fr_fix
+= md_short_jump_size
;
300 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
301 lie
&& lie
->dispfrag
== fragP
;
302 lie
= lie
->next_broken_word
)
304 fragP
->fr_fix
+= md_long_jump_size
;
312 BAD_CASE (fragP
->fr_type
);
319 relax_and_size_seg (abfd
, sec
, xxx
)
326 flags
= bfd_get_section_flags (abfd
, sec
);
328 if (flags
& SEC_ALLOC
)
331 segment_info_type
*seginfo
;
333 unsigned long size
, newsize
;
335 seginfo
= (segment_info_type
*) bfd_get_section_userdata (abfd
, sec
);
336 relax_segment (seginfo
->frchainP
->frch_root
, sec
);
337 for (fragp
= seginfo
->frchainP
->frch_root
; fragp
; fragp
= fragp
->fr_next
)
338 cvt_frag_to_fill (sec
, fragp
);
339 for (fragp
= seginfo
->frchainP
->frch_root
;
341 fragp
= fragp
->fr_next
)
342 /* walk to last elt */;
343 size
= fragp
->fr_address
;
346 flags
|= SEC_HAS_CONTENTS
;
347 /* @@ This is just an approximation. */
348 if (seginfo
->fix_root
)
350 x
= bfd_set_section_flags (abfd
, sec
, flags
);
353 size
= md_section_align (sec
, size
);
354 x
= bfd_set_section_size (abfd
, sec
, size
);
357 /* If the size had to be rounded up, add some padding in the last
359 newsize
= bfd_get_section_size_before_reloc (sec
);
360 assert (newsize
>= size
);
363 fragS
*last
= seginfo
->frchainP
->frch_last
;
364 fragp
= seginfo
->frchainP
->frch_root
;
365 while (fragp
->fr_next
!= last
)
366 fragp
= fragp
->fr_next
;
367 last
->fr_address
= size
;
368 fragp
->fr_offset
+= newsize
- size
;
371 #ifdef tc_frob_section
372 tc_frob_section (sec
);
374 #ifdef obj_frob_section
375 obj_frob_section (sec
);
380 write_contents (abfd
, sec
, xxx
)
385 segment_info_type
*seginfo
= seg_info (sec
);
386 unsigned long offset
= 0;
392 if (! (bfd_get_section_flags (abfd
, sec
) & SEC_LOAD
))
395 fixup_segment (seginfo
->fix_root
, sec
);
397 for (i
= 0, fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
400 symbolS
*sym
= fixp
->fx_addsy
;
401 asection
*sec
= sym
->bsym
->section
;
402 if (sec
== &bfd_und_section
403 || sec
== &bfd_abs_section
404 || sec
== &bfd_com_section
)
406 if (sym
->bsym
== sec
->symbol
)
408 /* If the section symbol isn't going to be output, the relocs
409 at least should still work. If not, figure out what to do
410 when we run into that case. */
411 fixp
->fx_offset
+= S_GET_VALUE (sym
);
412 fixp
->fx_addsy
= symbol_find (sec
->name
);
415 fixp
->fx_addsy
= symbol_make (sec
->name
);
416 fixp
->fx_addsy
->bsym
= sec
->symbol
;
420 /* Force calculations (size, vma) to get done. */
421 bfd_set_section_contents (stdoutput
, sec
, "", 0, 0);
423 /* Set up reloc information as well. */
425 for (fixp
= seginfo
->fix_root
; fixp
; fixp
= fixp
->fx_next
)
427 relocs
= (arelent
**) bfd_alloc_by_size_t (stdoutput
,
428 n
* sizeof (arelent
*));
430 for (frags
= seginfo
->frchainP
->frch_root
, fixp
= seginfo
->fix_root
, i
= 0;
432 frags
= frags
->fr_next
)
435 unsigned long fill_size
;
439 assert (frags
->fr_type
== rs_fill
);
441 && fixp
->fx_frag
== frags
)
444 extern arelent
*tc_gen_reloc ();
446 static bfd_reloc_status_type s
;
448 if (fixp
->fx_addsy
== 0)
450 /* @@ Need some other flag to indicate which have already
455 reloc
= tc_gen_reloc (sec
, fixp
);
461 data
= frags
->fr_literal
+ fixp
->fx_where
;
462 if (fixp
->fx_where
+ 4 > frags
->fr_fix
+ frags
->fr_offset
)
464 s
= bfd_perform_relocation (stdoutput
, reloc
, data
- reloc
->address
,
471 printf ("bad s value\n");
476 fixp
= fixp
->fx_next
;
480 x
= bfd_set_section_contents (stdoutput
, sec
,
481 frags
->fr_literal
, offset
,
484 offset
+= frags
->fr_fix
;
486 fill_literal
= frags
->fr_literal
+ frags
->fr_fix
;
487 fill_size
= frags
->fr_var
;
488 count
= frags
->fr_offset
;
490 if (fill_size
&& count
)
493 x
= bfd_set_section_contents (stdoutput
, sec
,
494 fill_literal
, offset
, fill_size
);
499 /* Did we miss any relocs? */
504 bfd_set_reloc (stdoutput
, sec
, relocs
, n
);
511 register struct frchain
*frchainP
; /* Track along all frchains. */
512 register fragS
*fragP
; /* Track along all frags. */
513 register struct frchain
*next_frchainP
;
514 register fragS
**prev_fragPP
;
516 long object_file_size
;
518 /* Do we really want to write it? */
521 n_warns
= had_warnings ();
522 n_errs
= had_errors ();
523 /* The -Z flag indicates that an object file should be generated,
524 regardless of warnings and errors. */
527 if (n_warns
|| n_errs
)
528 as_warn ("%d error%s, %d warning%s, generating bad object file.\n",
529 n_errs
, n_errs
== 1 ? "" : "s",
530 n_warns
, n_warns
== 1 ? "" : "s");
535 as_fatal ("%d error%s, %d warning%s, no object file generated.\n",
536 n_errs
, n_errs
== 1 ? "" : "s",
537 n_warns
, n_warns
== 1 ? "" : "s");
543 * Under VMS we try to be compatible with VAX-11 "C". Thus, we
544 * call a routine to check for the definition of the procedure
545 * "_main", and if so -- fix it up so that it can be program
548 VMS_Check_For_Main ();
551 /* After every sub-segment, we fake an ".align ...". This conforms to
552 BSD4.2 brane-damage. We then fake ".fill 0" because that is the kind of
553 frag that requires least thought. ".align" frags like to have a
554 following frag since that makes calculating their intended length
557 @@ Is this really necessary?? */
558 #ifndef SUB_SEGMENT_ALIGN
560 #define SUB_SEGMENT_ALIGN (0)
562 #define SUB_SEGMENT_ALIGN (2)
565 for (frchainP
= frchain_root
; frchainP
; frchainP
= frchainP
->frch_next
)
568 subseg_set (frchainP
->frch_seg
, frchainP
->frch_subseg
);
570 subseg_new (frchainP
->frch_seg
, frchainP
->frch_subseg
);
572 frag_align (SUB_SEGMENT_ALIGN
, NOP_OPCODE
);
573 /* frag_align will have left a new frag.
574 Use this last frag for an empty ".fill".
577 Create a last frag. Do not leave a "being filled in frag". */
578 frag_wane (frag_now
);
579 frag_now
->fr_fix
= 0;
580 know (frag_now
->fr_next
== NULL
);
581 /* know( frags . obstack_c_base == frags . obstack_c_next_free ); */
582 /* Above shows we haven't left a half-completed object on obstack. */
585 /* From now on, we don't care about sub-segments. Build one frag chain
586 for each segment. Linked thru fr_next. */
589 /* Remove the sections created by gas for its own purposes. */
591 asection
**seclist
, *sec
;
592 seclist
= &stdoutput
->sections
;
593 while (seclist
&& *seclist
)
596 while (sec
== big_section
597 || sec
== reg_section
598 || sec
== pass1_section
599 || sec
== diff_section
600 || sec
== absent_section
)
604 stdoutput
->section_count
--;
609 seclist
= &(*seclist
)->next
;
613 bfd_map_over_sections (stdoutput
, chain_frchains_together
, (char *) 0);
615 remove_subsegs (frchain_root
, SEG_TEXT
, &text_frag_root
, &text_last_frag
);
616 remove_subsegs (data0_frchainP
, SEG_DATA
, &data_frag_root
, &data_last_frag
);
617 remove_subsegs (bss0_frchainP
, SEG_BSS
, &bss_frag_root
, &bss_last_frag
);
620 /* We have two segments. If user gave -R flag, then we must put the
621 data frags into the text segment. Do this before relaxing so
622 we know to take advantage of -R and make shorter addresses. */
623 #if !defined (OBJ_AOUT) || defined (BFD_ASSEMBLER)
627 seg_info (text_section
)->frchainP
->frch_last
->fr_next
=
628 seg_info (data_section
)->frchainP
->frch_root
;
629 seg_info (text_section
)->frchainP
->frch_last
=
630 seg_info (data_section
)->frchainP
->frch_last
;
631 seg_info (data_section
)->frchainP
= 0;
635 text_last_frag
->fr_next
= data_frag_root
;
636 text_last_frag
= data_last_frag
;
637 data_last_frag
= NULL
;
638 data_frag_root
= NULL
;
641 for (tmp
= text_fix_root
; tmp
->fx_next
; tmp
= tmp
->fx_next
);;
642 tmp
->fx_next
= data_fix_root
;
643 text_fix_tail
= data_fix_tail
;
646 text_fix_root
= data_fix_root
;
647 data_fix_root
= NULL
;
653 bfd_map_over_sections (stdoutput
, relax_and_size_seg
, (char *) 0);
655 relax_segment (text_frag_root
, SEG_TEXT
);
656 relax_segment (data_frag_root
, SEG_DATA
);
657 relax_segment (bss_frag_root
, SEG_BSS
);
659 * Now the addresses of frags are correct within the segment.
662 know (text_last_frag
->fr_type
== rs_fill
&& text_last_frag
->fr_offset
== 0);
663 H_SET_TEXT_SIZE (&headers
, text_last_frag
->fr_address
);
664 text_last_frag
->fr_address
= H_GET_TEXT_SIZE (&headers
);
667 * Join the 2 segments into 1 huge segment.
668 * To do this, re-compute every rn_address in the SEG_DATA frags.
669 * Then join the data frags after the text frags.
671 * Determine a_data [length of data segment].
675 register relax_addressT slide
;
677 know ((text_last_frag
->fr_type
== rs_fill
) && (text_last_frag
->fr_offset
== 0));
679 H_SET_DATA_SIZE (&headers
, data_last_frag
->fr_address
);
680 data_last_frag
->fr_address
= H_GET_DATA_SIZE (&headers
);
681 slide
= H_GET_TEXT_SIZE (&headers
); /* & in file of the data segment. */
683 #define RoundUp(N,S) (((N)+(S)-1)&-(S))
684 /* For b.out: If the data section has a strict alignment
685 requirement, its load address in the .o file will be
686 rounded up from the size of the text section. These
687 two values are *not* the same! Similarly for the bss
689 slide
= RoundUp (slide
, 1 << section_alignment
[SEG_DATA
]);
692 for (fragP
= data_frag_root
; fragP
; fragP
= fragP
->fr_next
)
694 fragP
->fr_address
+= slide
;
695 } /* for each data frag */
697 know (text_last_frag
!= 0);
698 text_last_frag
->fr_next
= data_frag_root
;
702 H_SET_DATA_SIZE (&headers
, 0);
706 /* See above comments on b.out data section address. */
709 if (data_last_frag
== 0)
710 bss_vma
= H_GET_TEXT_SIZE (&headers
);
712 bss_vma
= data_last_frag
->fr_address
;
713 bss_vma
= RoundUp (bss_vma
, 1 << section_alignment
[SEG_BSS
]);
714 bss_address_frag
.fr_address
= bss_vma
;
716 #else /* ! OBJ_BOUT */
717 bss_address_frag
.fr_address
= (H_GET_TEXT_SIZE (&headers
) +
718 H_GET_DATA_SIZE (&headers
));
721 /* Slide all the frags */
724 relax_addressT slide
= bss_address_frag
.fr_address
;
726 for (fragP
= bss_frag_root
; fragP
; fragP
= fragP
->fr_next
)
728 fragP
->fr_address
+= slide
;
729 } /* for each bss frag */
732 #endif /* ! OBJ_BOUT */
735 H_SET_BSS_SIZE (&headers
,
736 bss_last_frag
->fr_address
- bss_frag_root
->fr_address
);
738 H_SET_BSS_SIZE (&headers
, 0);
739 #endif /* BFD_ASSEMBLER */
741 #ifndef BFD_ASSEMBLER
744 * Crawl the symbol chain.
746 * For each symbol whose value depends on a frag, take the address of
747 * that frag and subsume it into the value of the symbol.
748 * After this, there is just one way to lookup a symbol value.
749 * Values are left in their final state for object file emission.
750 * We adjust the values of 'L' local symbols, even if we do
751 * not intend to emit them to the object file, because their values
752 * are needed for fix-ups.
754 * Unless we saw a -L flag, remove all symbols that begin with 'L'
755 * from the symbol chain. (They are still pointed to by the fixes.)
757 * Count the remaining symbols.
758 * Assign a symbol number to each symbol.
759 * Count the number of string-table chars we will emit.
760 * Put this info into the headers as appropriate.
763 know (zero_address_frag
.fr_address
== 0);
764 string_byte_count
= sizeof (string_byte_count
);
766 obj_crawl_symbol_chain (&headers
);
768 if (string_byte_count
== sizeof (string_byte_count
))
769 string_byte_count
= 0;
771 H_SET_STRING_SIZE (&headers
, string_byte_count
);
774 * Addresses of frags now reflect addresses we use in the object file.
775 * Symbol values are correct.
776 * Scan the frags, converting any ".org"s and ".align"s to ".fill"s.
777 * Also converting any machine-dependent frags using md_convert_frag();
779 subseg_change (SEG_TEXT
, 0);
781 for (fragP
= text_frag_root
; fragP
; fragP
= fragP
->fr_next
)
783 cvt_frag_to_fill (&headers
, fragP
);
785 /* Some assert macros don't work with # directives mixed in. */
787 if (!(fragP
->fr_next
== NULL
789 || fragP
->fr_next
== data_frag_root
791 || ((fragP
->fr_next
->fr_address
- fragP
->fr_address
)
792 == (fragP
->fr_fix
+ fragP
->fr_offset
* fragP
->fr_var
))))
796 #endif /* ! BFD_ASSEMBLER */
798 #ifndef WORKING_DOT_WORD
800 struct broken_word
*lie
;
801 struct broken_word
**prevP
;
803 prevP
= &broken_words
;
804 for (lie
= broken_words
; lie
; lie
= lie
->next_broken_word
)
808 fix_new (lie
->frag
, lie
->word_goes_here
- lie
->frag
->fr_literal
,
809 2, lie
->add
, lie
->sub
, lie
->addnum
, 0, BFD_RELOC_NONE
);
811 #if defined(TC_SPARC) || defined(TC_A29K) || defined(NEED_FX_R_TYPE)
812 fix_new (lie
->frag
, lie
->word_goes_here
- lie
->frag
->fr_literal
,
814 lie
->sub
, lie
->addnum
,
818 fix_new_ns32k (lie
->frag
,
819 lie
->word_goes_here
- lie
->frag
->fr_literal
,
826 fix_new (lie
->frag
, lie
->word_goes_here
- lie
->frag
->fr_literal
,
828 lie
->sub
, lie
->addnum
,
830 #endif /* TC_NS32K */
831 #endif /* TC_SPARC|TC_A29K|NEED_FX_R_TYPE */
832 #endif /* BFD_ASSEMBLER */
833 *prevP
= lie
->next_broken_word
;
836 prevP
= &(lie
->next_broken_word
);
838 for (lie
= broken_words
; lie
;)
840 struct broken_word
*untruth
;
843 long from_addr
, to_addr
;
846 fragP
= lie
->dispfrag
;
848 /* Find out how many broken_words go here. */
850 for (untruth
= lie
; untruth
&& untruth
->dispfrag
== fragP
; untruth
= untruth
->next_broken_word
)
851 if (untruth
->added
== 1)
854 table_ptr
= lie
->dispfrag
->fr_opcode
;
855 table_addr
= lie
->dispfrag
->fr_address
+ (table_ptr
- lie
->dispfrag
->fr_literal
);
856 /* Create the jump around the long jumps. This is a short
857 jump from table_ptr+0 to table_ptr+n*long_jump_size. */
858 from_addr
= table_addr
;
859 to_addr
= table_addr
+ md_short_jump_size
+ n
* md_long_jump_size
;
860 md_create_short_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
, lie
->add
);
861 table_ptr
+= md_short_jump_size
;
862 table_addr
+= md_short_jump_size
;
864 for (m
= 0; lie
&& lie
->dispfrag
== fragP
; m
++, lie
= lie
->next_broken_word
)
868 /* Patch the jump table */
869 /* This is the offset from ??? to table_ptr+0 */
871 - S_GET_VALUE (lie
->sub
);
872 md_number_to_chars (lie
->word_goes_here
, to_addr
, 2);
873 for (untruth
= lie
->next_broken_word
; untruth
&& untruth
->dispfrag
== fragP
; untruth
= untruth
->next_broken_word
)
875 if (untruth
->use_jump
== lie
)
876 md_number_to_chars (untruth
->word_goes_here
, to_addr
, 2);
879 /* Install the long jump */
880 /* this is a long jump from table_ptr+0 to the final target */
881 from_addr
= table_addr
;
882 to_addr
= S_GET_VALUE (lie
->add
) + lie
->addnum
;
883 md_create_long_jump (table_ptr
, from_addr
, to_addr
, lie
->dispfrag
, lie
->add
);
884 table_ptr
+= md_long_jump_size
;
885 table_addr
+= md_long_jump_size
;
889 #endif /* not WORKING_DOT_WORD */
891 #ifndef BFD_ASSEMBLER
895 * Scan every FixS performing fixups. We had to wait until now to do
896 * this because md_convert_frag() may have made some fixSs.
900 subseg_change (SEG_TEXT
, 0);
901 trsize
= md_reloc_size
* fixup_segment (text_fix_root
,
903 subseg_change (SEG_DATA
, 0);
904 drsize
= md_reloc_size
* fixup_segment (data_fix_root
,
906 H_SET_RELOCATION_SIZE (&headers
, trsize
, drsize
);
908 /* FIXME move this stuff into the pre-write-hook */
909 H_SET_MAGIC_NUMBER (&headers
, magic_number_for_object_file
);
910 H_SET_ENTRY_POINT (&headers
, 0);
912 obj_pre_write_hook (&headers
); /* extra coff stuff */
914 object_file_size
= H_GET_FILE_SIZE (&headers
);
915 next_object_file_charP
= the_object_file
= xmalloc (object_file_size
);
917 output_file_create (out_file_name
);
919 obj_header_append (&next_object_file_charP
, &headers
);
921 know ((next_object_file_charP
- the_object_file
) == H_GET_HEADER_SIZE (&headers
));
926 for (fragP
= text_frag_root
; fragP
; fragP
= fragP
->fr_next
)
929 register char *fill_literal
;
930 register long fill_size
;
932 know (fragP
->fr_type
== rs_fill
);
933 append (&next_object_file_charP
, fragP
->fr_literal
, (unsigned long) fragP
->fr_fix
);
934 fill_literal
= fragP
->fr_literal
+ fragP
->fr_fix
;
935 fill_size
= fragP
->fr_var
;
936 know (fragP
->fr_offset
>= 0);
938 for (count
= fragP
->fr_offset
; count
; count
--)
940 append (&next_object_file_charP
, fill_literal
, (unsigned long) fill_size
);
943 } /* for each code frag. */
945 know ((next_object_file_charP
- the_object_file
) == (H_GET_HEADER_SIZE (&headers
) + H_GET_TEXT_SIZE (&headers
) + H_GET_DATA_SIZE (&headers
)));
950 obj_emit_relocations (&next_object_file_charP
, text_fix_root
, (relax_addressT
) 0);
951 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
)));
953 /* Make addresses in data relocation directives relative to beginning of
954 * first data fragment, not end of last text fragment: alignment of the
955 * start of the data segment may place a gap between the segments.
957 obj_emit_relocations (&next_object_file_charP
, data_fix_root
, data0_frchainP
->frch_root
->fr_address
);
959 obj_emit_relocations (&next_object_file_charP
, data_fix_root
, text_last_frag
->fr_address
);
962 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
)));
965 * Emit line number entries.
967 OBJ_EMIT_LINENO (&next_object_file_charP
, lineno_rootP
, the_object_file
);
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
) + H_GET_LINENO_SIZE (&headers
)));
973 obj_emit_symbols (&next_object_file_charP
, symbol_rootP
);
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
) + H_GET_SYMBOL_TABLE_SIZE (&headers
)));
980 if (string_byte_count
> 0)
982 obj_emit_strings (&next_object_file_charP
);
983 } /* only if we have a string table */
986 bfd_seek (stdoutput
, 0, 0);
987 bfd_write (the_object_file
, 1, object_file_size
, stdoutput
);
990 /* Write the data to the file */
991 output_file_append (the_object_file
, object_file_size
, out_file_name
);
994 output_file_close (out_file_name
);
995 } /* non vms output */
998 * Now do the VMS-dependent part of writing the object file
1000 VMS_write_object_file (H_GET_TEXT_SIZE (&headers
),
1001 H_GET_DATA_SIZE (&headers
),
1002 H_GET_BSS_SIZE (&headers
),
1003 text_frag_root
, data_frag_root
);
1005 #else /* BFD_ASSEMBLER */
1006 #ifdef obj_frob_file
1010 /* Set up symbol table, and write it out. */
1016 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
1018 S_SET_VALUE (symp
, S_GET_VALUE (symp
) + symp
->sy_frag
->fr_address
);
1019 /* So far, common symbols have been treated like undefined symbols.
1020 Put them in the common section now. */
1021 if (S_IS_DEFINED (symp
) == 0
1022 && S_GET_VALUE (symp
) != 0)
1023 S_SET_SEGMENT (symp
, &bfd_com_section
);
1025 printf ("symbol `%s'\n\t@%x: value=%d type=%d forward=%x seg=%s\n",
1026 S_GET_NAME (symp
), symp
,
1028 S_GET_DATA_TYPE (symp
),
1030 segment_name (symp
->bsym
->section
));
1034 #ifdef obj_frob_symbol
1035 obj_frob_symbol (symp
, punt
);
1039 #ifdef tc_frob_symbol
1040 tc_frob_symbol (symp
, punt
);
1045 /* If we don't want to keep this symbol, splice it out of the
1047 if (S_IS_LOCAL (symp
))
1049 symbolS
*prev
, *next
;
1051 prev
= symbol_previous (symp
);
1052 next
= symbol_next (symp
);
1054 /* debugging: verify consistency */
1056 symbolS
*p
= symp
, *n
= symp
;
1057 while (symbol_previous (p
))
1058 p
= symbol_previous (p
);
1059 while (symbol_next (n
))
1060 n
= symbol_next (n
);
1061 verify_symbol_chain (p
, n
);
1066 symbol_next (prev
) = next
;
1072 symbol_previous (next
) = prev
;
1074 symbol_lastP
= prev
;
1076 /* debugging: verify consistency */
1078 symbolS
*p
= symp
, *n
= symp
;
1079 while (symbol_previous (p
))
1080 p
= symbol_previous (p
);
1081 while (symbol_next (n
))
1082 n
= symbol_next (n
);
1083 verify_symbol_chain (p
, n
);
1096 asympp
= (asymbol
**) bfd_alloc (stdoutput
, n
* sizeof (asymbol
*));
1097 symp
= symbol_rootP
;
1098 for (i
= 0; i
< n
; i
++, symp
= symbol_next (symp
))
1100 asympp
[i
] = symp
->bsym
;
1103 result
= bfd_set_symtab (stdoutput
, asympp
, n
);
1104 assert (result
== true);
1108 /* Now that all the sizes are known, and contents correct, we can
1109 start writing the file. */
1110 bfd_map_over_sections (stdoutput
, write_contents
, (char *) 0);
1112 output_file_close (out_file_name
);
1113 #endif /* BFD_ASSEMBLER */
1120 * Now we have a segment, not a crowd of sub-segments, we can make fr_address
1125 * After this, all frags in this segment have addresses that are correct
1126 * within the segment. Since segments live in different file addresses,
1127 * these frag addresses may not be the same as final object-file addresses.
1136 for (; f1
; f1
= f1
->fr_next
)
1137 if (f1
->fr_next
== f2
)
1142 /* Relax_align. Advance location counter to next address that has 'alignment'
1143 lowest order bits all 0s. */
1145 /* How many addresses does the .align take? */
1146 static relax_addressT
1147 relax_align (address
, alignment
)
1148 register relax_addressT address
; /* Address now. */
1149 register long alignment
; /* Alignment (binary). */
1151 relax_addressT mask
;
1152 relax_addressT new_address
;
1154 mask
= ~((~0) << alignment
);
1155 new_address
= (address
+ mask
) & (~mask
);
1157 /* We must provide lots of padding, so the linker can discard it
1158 when needed. The linker will not add extra space, ever. */
1159 new_address
+= (1 << alignment
);
1160 return (new_address
- address
);
1164 relax_segment (segment_frag_root
, segment
)
1165 struct frag
*segment_frag_root
;
1168 register struct frag
*fragP
;
1169 register relax_addressT address
;
1170 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
1171 know (segment
== SEG_DATA
|| segment
== SEG_TEXT
|| segment
== SEG_BSS
);
1173 /* In case md_estimate_size_before_relax() wants to make fixSs. */
1174 subseg_change (segment
, 0);
1176 /* For each frag in segment: count and store (a 1st guess of)
1179 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
1181 fragP
->fr_address
= address
;
1182 address
+= fragP
->fr_fix
;
1184 switch (fragP
->fr_type
)
1187 address
+= fragP
->fr_offset
* fragP
->fr_var
;
1191 address
+= relax_align (address
, fragP
->fr_offset
);
1195 /* Assume .org is nugatory. It will grow with 1st relax. */
1198 case rs_machine_dependent
:
1199 address
+= md_estimate_size_before_relax (fragP
, segment
);
1202 #ifndef WORKING_DOT_WORD
1203 /* Broken words don't concern us yet */
1204 case rs_broken_word
:
1209 BAD_CASE (fragP
->fr_type
);
1211 } /* switch(fr_type) */
1212 } /* for each frag in the segment */
1216 long stretch
; /* May be any size, 0 or negative. */
1217 /* Cumulative number of addresses we have */
1218 /* relaxed this pass. */
1219 /* We may have relaxed more than one address. */
1220 long stretched
; /* Have we stretched on this pass? */
1221 /* This is 'cuz stretch may be zero, when, in fact some piece of code
1222 grew, and another shrank. If a branch instruction doesn't fit anymore,
1223 we could be scrod. */
1227 stretch
= stretched
= 0;
1228 for (fragP
= segment_frag_root
; fragP
; fragP
= fragP
->fr_next
)
1231 unsigned long was_address
;
1238 was_address
= fragP
->fr_address
;
1239 address
= fragP
->fr_address
+= stretch
;
1240 symbolP
= fragP
->fr_symbol
;
1241 offset
= fragP
->fr_offset
;
1243 switch (fragP
->fr_type
)
1245 case rs_fill
: /* .fill never relaxes. */
1249 #ifndef WORKING_DOT_WORD
1250 /* JF: This is RMS's idea. I do *NOT* want to be blamed
1251 for it I do not want to write it. I do not want to have
1252 anything to do with it. This is not the proper way to
1253 implement this misfeature. */
1254 case rs_broken_word
:
1256 struct broken_word
*lie
;
1257 struct broken_word
*untruth
;
1259 /* Yes this is ugly (storing the broken_word pointer
1260 in the symbol slot). Still, this whole chunk of
1261 code is ugly, and I don't feel like doing anything
1262 about it. Think of it as stubbornness in action. */
1264 for (lie
= (struct broken_word
*) (fragP
->fr_symbol
);
1265 lie
&& lie
->dispfrag
== fragP
;
1266 lie
= lie
->next_broken_word
)
1272 offset
= (lie
->add
->sy_frag
->fr_address
1273 + S_GET_VALUE (lie
->add
)
1275 - (lie
->sub
->sy_frag
->fr_address
1276 + S_GET_VALUE (lie
->sub
)));
1277 if (offset
<= -32768 || offset
>= 32767)
1280 as_warn (".word %s-%s+%ld didn't fit",
1281 S_GET_NAME (lie
->add
),
1282 S_GET_NAME (lie
->sub
),
1285 if (fragP
->fr_subtype
== 0)
1287 fragP
->fr_subtype
++;
1288 growth
+= md_short_jump_size
;
1290 for (untruth
= lie
->next_broken_word
;
1291 untruth
&& untruth
->dispfrag
== lie
->dispfrag
;
1292 untruth
= untruth
->next_broken_word
)
1293 if ((untruth
->add
->sy_frag
== lie
->add
->sy_frag
)
1294 && S_GET_VALUE (untruth
->add
) == S_GET_VALUE (lie
->add
))
1297 untruth
->use_jump
= lie
;
1299 growth
+= md_long_jump_size
;
1304 } /* case rs_broken_word */
1307 growth
= (relax_align ((relax_addressT
) (address
1310 - relax_align ((relax_addressT
) (was_address
1320 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
1321 know ((S_GET_SEGMENT (symbolP
) == SEG_ABSOLUTE
)
1322 || (S_GET_SEGMENT (symbolP
) == SEG_DATA
)
1323 || (S_GET_SEGMENT (symbolP
) == SEG_TEXT
)
1324 || S_GET_SEGMENT (symbolP
) == SEG_BSS
);
1325 know (symbolP
->sy_frag
);
1326 know (!(S_GET_SEGMENT (symbolP
) == SEG_ABSOLUTE
)
1327 || (symbolP
->sy_frag
== &zero_address_frag
));
1329 target
+= S_GET_VALUE (symbolP
)
1330 + symbolP
->sy_frag
->fr_address
;
1331 } /* if we have a symbol */
1333 know (fragP
->fr_next
);
1334 after
= fragP
->fr_next
->fr_address
;
1335 growth
= ((target
- after
) > 0) ? (target
- after
) : 0;
1336 /* Growth may be negative, but variable part of frag
1337 cannot have fewer than 0 chars. That is, we can't
1340 growth
-= stretch
; /* This is an absolute growth factor */
1343 case rs_machine_dependent
:
1345 const relax_typeS
*this_type
;
1346 const relax_typeS
*start_type
;
1347 relax_substateT next_state
;
1348 relax_substateT this_state
;
1350 this_state
= fragP
->fr_subtype
;
1351 start_type
= this_type
= md_relax_table
+ this_state
;
1356 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
1357 know ((S_GET_SEGMENT (symbolP
) == SEG_ABSOLUTE
)
1358 || (S_GET_SEGMENT (symbolP
) == SEG_DATA
)
1359 || (S_GET_SEGMENT (symbolP
) == SEG_BSS
)
1360 || (S_GET_SEGMENT (symbolP
) == SEG_TEXT
));
1362 know (symbolP
->sy_frag
);
1363 know (!(S_GET_SEGMENT (symbolP
) == absolute_section
)
1364 || symbolP
->sy_frag
== &zero_address_frag
);
1366 S_GET_VALUE (symbolP
)
1367 + symbolP
->sy_frag
->fr_address
;
1369 /* If frag has yet to be reached on this pass,
1370 assume it will move by STRETCH just as we did.
1371 If this is not so, it will be because some frag
1372 between grows, and that will force another pass. */
1374 /* JF was just address */
1375 /* JF also added is_dnrange hack */
1376 /* There's gotta be a better/faster/etc way
1378 /* gnu@cygnus.com: I changed this from > to >=
1379 because I ran into a zero-length frag (fr_fix=0)
1380 which was created when the obstack needed a new
1381 chunk JUST AFTER the opcode of a branch. Since
1382 fr_fix is zero, fr_address of this frag is the same
1383 as fr_address of the next frag. This
1384 zero-length frag was variable and jumped to .+2
1385 (in the next frag), but since the > comparison
1386 below failed (the two were =, not >), "stretch"
1387 was not added to the target. Stretch was 178, so
1388 the offset appeared to be .-176 instead, which did
1389 not fit into a byte branch, so the assembler
1390 relaxed the branch to a word. This didn't compare
1391 with what happened when the same source file was
1392 assembled on other machines, which is how I found it.
1393 You might want to think about what other places have
1394 trouble with zero length frags... */
1396 if (symbolP
->sy_frag
->fr_address
>= was_address
1397 && is_dnrange (fragP
, symbolP
->sy_frag
))
1401 } /* if there's a symbol attached */
1403 aim
= target
- address
- fragP
->fr_fix
;
1404 /* The displacement is affected by the instruction size
1405 for the 32k architecture. I think we ought to be able
1406 to add fragP->fr_pcrel_adjust in all cases (it should be
1407 zero if not used), but just in case it breaks something
1408 else we'll put this inside #ifdef NS32K ... #endif */
1410 aim
+= fragP
->fr_pcrel_adjust
;
1411 #endif /* TC_NS32K */
1415 /* Look backwards. */
1416 for (next_state
= this_type
->rlx_more
; next_state
;)
1417 if (aim
>= this_type
->rlx_backward
)
1421 /* Grow to next state. */
1422 this_state
= next_state
;
1423 this_type
= md_relax_table
+ this_state
;
1424 next_state
= this_type
->rlx_more
;
1429 #ifdef M68K_AIM_KLUDGE
1430 M68K_AIM_KLUDGE (aim
, this_state
, this_type
);
1432 /* Look forwards. */
1433 for (next_state
= this_type
->rlx_more
; next_state
;)
1434 if (aim
<= this_type
->rlx_forward
)
1438 /* Grow to next state. */
1439 this_state
= next_state
;
1440 this_type
= md_relax_table
+ this_state
;
1441 next_state
= this_type
->rlx_more
;
1445 growth
= this_type
->rlx_length
- start_type
->rlx_length
;
1447 fragP
->fr_subtype
= this_state
;
1452 BAD_CASE (fragP
->fr_type
);
1460 } /* For each frag in the segment. */
1462 while (stretched
); /* Until nothing further to relax. */
1466 * We now have valid fr_address'es for each frag.
1470 * All fr_address's are correct, relative to their own segment.
1471 * We have made all the fixS we will ever make.
1473 } /* relax_segment() */
1477 Go through all the fixS's in a segment and see which ones can be
1478 handled now. (These consist of fixS where we have since discovered
1479 the value of a symbol, or the address of the frag involved.)
1480 For each one, call md_apply_fix to put the fix into the frag data.
1482 Result is a count of how many relocation structs will be needed to
1483 handle the remaining fixS's that we couldn't completely handle here.
1484 These will be output later by emit_relocations(). */
1487 fixup_segment (fixP
, this_segment_type
)
1488 register fixS
*fixP
;
1489 segT this_segment_type
; /* N_TYPE bits for segment. */
1491 register long seg_reloc_count
;
1492 register symbolS
*add_symbolP
;
1493 register symbolS
*sub_symbolP
;
1496 register char *place
;
1497 register long where
;
1498 register char pcrel
;
1499 register fragS
*fragP
;
1500 register segT add_symbol_segment
= absolute_section
;
1502 seg_reloc_count
= 0;
1503 /* If the linker is doing the relaxing, we must not do any fixups */
1505 for (; fixP
; fixP
= fixP
->fx_next
)
1508 for (; fixP
; fixP
= fixP
->fx_next
)
1510 fragP
= fixP
->fx_frag
;
1512 where
= fixP
->fx_where
;
1513 place
= fragP
->fr_literal
+ where
;
1514 size
= fixP
->fx_size
;
1515 add_symbolP
= fixP
->fx_addsy
;
1517 if (fixP
->fx_callj
&& TC_S_IS_CALLNAME (add_symbolP
))
1519 /* Relocation should be done via the associated 'bal'
1520 entry point symbol. */
1522 if (!TC_S_IS_BALNAME (tc_get_bal_of_call (add_symbolP
)))
1524 as_bad ("No 'bal' entry point for leafproc %s",
1525 S_GET_NAME (add_symbolP
));
1528 fixP
->fx_addsy
= add_symbolP
= tc_get_bal_of_call (add_symbolP
);
1531 sub_symbolP
= fixP
->fx_subsy
;
1532 add_number
= fixP
->fx_offset
;
1533 pcrel
= fixP
->fx_pcrel
;
1536 add_symbol_segment
= S_GET_SEGMENT (add_symbolP
);
1543 if (S_GET_SEGMENT (sub_symbolP
) != absolute_section
)
1544 as_bad ("Negative of non-absolute symbol %s",
1545 S_GET_NAME (sub_symbolP
));
1547 add_number
-= S_GET_VALUE (sub_symbolP
);
1549 else if ((S_GET_SEGMENT (sub_symbolP
) == add_symbol_segment
)
1550 && (SEG_NORMAL (add_symbol_segment
)
1551 || (add_symbol_segment
== absolute_section
)))
1553 /* Difference of 2 symbols from same segment.
1554 Can't make difference of 2 undefineds: 'value' means
1555 something different for N_UNDF. */
1557 /* Makes no sense to use the difference of 2 arbitrary symbols
1558 as the target of a call instruction. */
1561 as_bad ("callj to difference of 2 symbols");
1563 #endif /* TC_I960 */
1564 add_number
+= S_GET_VALUE (add_symbolP
) -
1565 S_GET_VALUE (sub_symbolP
);
1568 fixP
->fx_addsy
= NULL
;
1572 /* Different segments in subtraction. */
1573 know (!(S_IS_EXTERNAL (sub_symbolP
)
1574 && (S_GET_SEGMENT (sub_symbolP
) == absolute_section
)));
1576 if ((S_GET_SEGMENT (sub_symbolP
) == absolute_section
))
1578 add_number
-= S_GET_VALUE (sub_symbolP
);
1582 as_bad ("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
1583 segment_name (S_GET_SEGMENT (sub_symbolP
)),
1584 S_GET_NAME (sub_symbolP
), fragP
->fr_address
+ where
);
1587 } /* if sub_symbolP */
1591 if (add_symbol_segment
== this_segment_type
&& pcrel
)
1594 * This fixup was made when the symbol's segment was
1595 * SEG_UNKNOWN, but it is now in the local segment.
1596 * So we know how to do the address without relocation.
1599 /* reloc_callj() may replace a 'call' with a 'calls' or a
1600 'bal', in which cases it modifies *fixP as appropriate.
1601 In the case of a 'calls', no further work is required,
1602 and *fixP has been set up to make the rest of the code
1605 #endif /* TC_I960 */
1607 add_number
+= S_GET_VALUE (add_symbolP
);
1608 add_number
-= md_pcrel_from (fixP
);
1609 pcrel
= 0; /* Lie. Don't want further pcrel processing. */
1610 fixP
->fx_addsy
= NULL
; /* No relocations please. */
1614 if (add_symbol_segment
== absolute_section
)
1617 /* See comment about reloc_callj() above. */
1619 #endif /* TC_I960 */
1620 add_number
+= S_GET_VALUE (add_symbolP
);
1621 fixP
->fx_addsy
= NULL
;
1624 else if (add_symbol_segment
== undefined_section
1625 #ifdef BFD_ASSEMBLER
1626 || add_symbol_segment
== &bfd_com_section
1631 if ((int) fixP
->fx_bit_fixP
== 13)
1633 /* This is a COBR instruction. They have only a
1634 * 13-bit displacement and are only to be used
1635 * for local branches: flag as error, don't generate
1638 as_bad ("can't use COBR format with external label");
1639 fixP
->fx_addsy
= NULL
; /* No relocations please. */
1642 #endif /* TC_I960 */
1646 if (S_IS_COMMON (add_symbolP
))
1647 add_number
+= S_GET_VALUE (add_symbolP
);
1648 #endif /* TE_I386AIX */
1649 #endif /* OBJ_COFF */
1655 add_number
+= S_GET_VALUE (add_symbolP
);
1657 } /* if not in local seg */
1658 } /* if there was a + symbol */
1662 add_number
-= md_pcrel_from (fixP
);
1663 if (add_symbolP
== 0)
1665 fixP
->fx_addsy
= &abs_symbol
;
1667 } /* if there's an add_symbol */
1670 if (!fixP
->fx_bit_fixP
)
1673 (add_number
& ~0xFF)
1674 && ((add_number
& ~0xFF) != (-1 & ~0xFF)))
1676 && (add_number
& ~0xFFFF)
1677 && ((add_number
& ~0xFFFF) != (-1 & ~0xFFFF))))
1679 as_bad ("Value of %d too large for field of %d bytes at 0x%x",
1680 add_number
, size
, fragP
->fr_address
+ where
);
1681 } /* generic error checking */
1682 #ifdef WARN_SIGNED_OVERFLOW_WORD
1683 /* Warn if a .word value is too large when treated as a signed
1684 number. We already know it is not too negative. This is to
1685 catch over-large switches generated by gcc on the 68k. */
1688 && add_number
> 0x7fff)
1689 as_bad ("Signed .word overflow; switch may be too large; %d at 0x%x",
1690 add_number
, fragP
->fr_address
+ where
);
1692 } /* not a bit fix */
1694 #ifdef BFD_ASSEMBLER
1695 md_apply_fix (fixP
, &add_number
);
1697 md_apply_fix (fixP
, add_number
);
1699 } /* For each fixS in this segment. */
1706 /* two relocs per callj under coff. */
1707 for (fixP
= topP
; fixP
; fixP
= fixP
->fx_next
)
1709 if (fixP
->fx_callj
&& fixP
->fx_addsy
!= 0)
1712 } /* if callj and not already fixed. */
1713 } /* for each fix */
1715 #endif /* TC_I960 */
1717 #endif /* OBJ_COFF */
1718 return (seg_reloc_count
);
1719 } /* fixup_segment() */
1721 /* end of write.c */