Deleted Added
full compact
write.c (94536) write.c (104834)
1/* write.c - emit .o file
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
1/* write.c - emit .o file
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001
3 1998, 1999, 2000, 2001, 2002
4 Free Software Foundation, Inc.
5
6 This file is part of GAS, the GNU Assembler.
7
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.

--- 44 unchanged lines hidden (view full) ---

56#define TC_FINALIZE_SYMS_BEFORE_SIZE_SEG 1
57#endif
58
59#ifndef MD_PCREL_FROM_SECTION
60#define MD_PCREL_FROM_SECTION(FIXP, SEC) md_pcrel_from(FIXP)
61#endif
62
63#ifndef WORKING_DOT_WORD
4 Free Software Foundation, Inc.
5
6 This file is part of GAS, the GNU Assembler.
7
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.

--- 44 unchanged lines hidden (view full) ---

56#define TC_FINALIZE_SYMS_BEFORE_SIZE_SEG 1
57#endif
58
59#ifndef MD_PCREL_FROM_SECTION
60#define MD_PCREL_FROM_SECTION(FIXP, SEC) md_pcrel_from(FIXP)
61#endif
62
63#ifndef WORKING_DOT_WORD
64extern CONST int md_short_jump_size;
65extern CONST int md_long_jump_size;
64extern const int md_short_jump_size;
65extern const int md_long_jump_size;
66#endif
67
68/* Used to control final evaluation of expressions. */
69int finalize_syms = 0;
70
71int symbol_table_frozen;
72void print_fixup PARAMS ((fixS *));
73

--- 63 unchanged lines hidden (view full) ---

137#if defined (BFD_ASSEMBLER) || (! defined (BFD) && ! defined (OBJ_AOUT))
138static void merge_data_into_text PARAMS ((void));
139#endif
140#if ! defined (BFD_ASSEMBLER) && ! defined (BFD)
141static void cvt_frag_to_fill PARAMS ((object_headers *, segT, fragS *));
142static void remove_subsegs PARAMS ((frchainS *, int, fragS **, fragS **));
143static void relax_and_size_all_segments PARAMS ((void));
144#endif
66#endif
67
68/* Used to control final evaluation of expressions. */
69int finalize_syms = 0;
70
71int symbol_table_frozen;
72void print_fixup PARAMS ((fixS *));
73

--- 63 unchanged lines hidden (view full) ---

137#if defined (BFD_ASSEMBLER) || (! defined (BFD) && ! defined (OBJ_AOUT))
138static void merge_data_into_text PARAMS ((void));
139#endif
140#if ! defined (BFD_ASSEMBLER) && ! defined (BFD)
141static void cvt_frag_to_fill PARAMS ((object_headers *, segT, fragS *));
142static void remove_subsegs PARAMS ((frchainS *, int, fragS **, fragS **));
143static void relax_and_size_all_segments PARAMS ((void));
144#endif
145#if defined (BFD_ASSEMBLER) && defined (OBJ_COFF) && defined (TE_GO32)
146static void set_segment_vma PARAMS ((bfd *, asection *, PTR));
147#endif
148
149/* Create a fixS in obstack 'notes'. */
150
151static fixS *
152fix_new_internal (frag, where, size, add_symbol, sub_symbol, offset, pcrel,
153 r_type)
154 fragS *frag; /* Which frag? */
155 int where; /* Where in that frag? */

--- 366 unchanged lines hidden (view full) ---

522 fragP->fr_offset = (fragP->fr_next->fr_address
523 - fragP->fr_address
524 - fragP->fr_fix) / fragP->fr_var;
525 if (fragP->fr_offset < 0)
526 {
527 as_bad_where (fragP->fr_file, fragP->fr_line,
528 _("attempt to .org/.space backwards? (%ld)"),
529 (long) fragP->fr_offset);
145
146/* Create a fixS in obstack 'notes'. */
147
148static fixS *
149fix_new_internal (frag, where, size, add_symbol, sub_symbol, offset, pcrel,
150 r_type)
151 fragS *frag; /* Which frag? */
152 int where; /* Where in that frag? */

--- 366 unchanged lines hidden (view full) ---

519 fragP->fr_offset = (fragP->fr_next->fr_address
520 - fragP->fr_address
521 - fragP->fr_fix) / fragP->fr_var;
522 if (fragP->fr_offset < 0)
523 {
524 as_bad_where (fragP->fr_file, fragP->fr_line,
525 _("attempt to .org/.space backwards? (%ld)"),
526 (long) fragP->fr_offset);
527 fragP->fr_offset = 0;
530 }
531 fragP->fr_type = rs_fill;
532 break;
533
534 case rs_fill:
535 break;
536
537 case rs_leb128:

--- 134 unchanged lines hidden (view full) ---

672 assert (newsize >= size);
673 if (size != newsize)
674 {
675 fragS *last = seginfo->frchainP->frch_last;
676 fragp = seginfo->frchainP->frch_root;
677 while (fragp->fr_next != last)
678 fragp = fragp->fr_next;
679 last->fr_address = size;
528 }
529 fragP->fr_type = rs_fill;
530 break;
531
532 case rs_fill:
533 break;
534
535 case rs_leb128:

--- 134 unchanged lines hidden (view full) ---

670 assert (newsize >= size);
671 if (size != newsize)
672 {
673 fragS *last = seginfo->frchainP->frch_last;
674 fragp = seginfo->frchainP->frch_root;
675 while (fragp->fr_next != last)
676 fragp = fragp->fr_next;
677 last->fr_address = size;
680 fragp->fr_offset += newsize - size;
678 if ((newsize - size) % fragp->fr_var == 0)
679 fragp->fr_offset += (newsize - size) / fragp->fr_var;
680 else
681 /* If we hit this abort, it's likely due to subsegs_finish not
682 providing sufficient alignment on the last frag, and the
683 machine dependent code using alignment frags with fr_var
684 greater than 1. */
685 abort ();
681 }
682
683#ifdef tc_frob_section
684 tc_frob_section (sec);
685#endif
686#ifdef obj_frob_section
687 obj_frob_section (sec);
688#endif

--- 187 unchanged lines hidden (view full) ---

876
877 /* Never adjust a reloc against local symbol in a merge section
878 with non-zero addend. */
879 if ((symsec->flags & SEC_MERGE) && fixp->fx_offset)
880 {
881 symbol_mark_used_in_reloc (fixp->fx_addsy);
882 goto done;
883 }
686 }
687
688#ifdef tc_frob_section
689 tc_frob_section (sec);
690#endif
691#ifdef obj_frob_section
692 obj_frob_section (sec);
693#endif

--- 187 unchanged lines hidden (view full) ---

881
882 /* Never adjust a reloc against local symbol in a merge section
883 with non-zero addend. */
884 if ((symsec->flags & SEC_MERGE) && fixp->fx_offset)
885 {
886 symbol_mark_used_in_reloc (fixp->fx_addsy);
887 goto done;
888 }
889
890 /* Never adjust a reloc against TLS local symbol. */
891 if (symsec->flags & SEC_THREAD_LOCAL)
892 {
893 symbol_mark_used_in_reloc (fixp->fx_addsy);
894 goto done;
895 }
884#endif
885
886 /* Is there some other reason we can't adjust this one? (E.g.,
887 call/bal links in i960-bout symbols.) */
888#ifdef obj_fix_adjustable
889 if (! obj_fix_adjustable (fixp))
890 {
891 symbol_mark_used_in_reloc (fixp->fx_addsy);

--- 499 unchanged lines hidden (view full) ---

1391 else
1392 asympp = 0;
1393 result = bfd_set_symtab (stdoutput, asympp, nsyms);
1394 assert (result == true);
1395 symbol_table_frozen = 1;
1396}
1397#endif
1398
896#endif
897
898 /* Is there some other reason we can't adjust this one? (E.g.,
899 call/bal links in i960-bout symbols.) */
900#ifdef obj_fix_adjustable
901 if (! obj_fix_adjustable (fixp))
902 {
903 symbol_mark_used_in_reloc (fixp->fx_addsy);

--- 499 unchanged lines hidden (view full) ---

1403 else
1404 asympp = 0;
1405 result = bfd_set_symtab (stdoutput, asympp, nsyms);
1406 assert (result == true);
1407 symbol_table_frozen = 1;
1408}
1409#endif
1410
1399#if defined (BFD_ASSEMBLER) && defined (OBJ_COFF) && defined (TE_GO32)
1400static void
1401set_segment_vma (abfd, sec, xxx)
1402 bfd *abfd;
1403 asection *sec;
1404 PTR xxx ATTRIBUTE_UNUSED;
1405{
1406 static bfd_vma addr = 0;
1407
1408 bfd_set_section_vma (abfd, sec, addr);
1409 addr += bfd_section_size (abfd, sec);
1410}
1411#endif /* BFD_ASSEMBLER && OBJ_COFF && !TE_PE */
1412
1413/* Finish the subsegments. After every sub-segment, we fake an
1414 ".align ...". This conforms to BSD4.2 brane-damage. We then fake
1415 ".fill 0" because that is the kind of frag that requires least
1416 thought. ".align" frags like to have a following frag since that
1417 makes calculating their intended length trivial. */
1418
1419#ifndef SUB_SEGMENT_ALIGN
1411/* Finish the subsegments. After every sub-segment, we fake an
1412 ".align ...". This conforms to BSD4.2 brane-damage. We then fake
1413 ".fill 0" because that is the kind of frag that requires least
1414 thought. ".align" frags like to have a following frag since that
1415 makes calculating their intended length trivial. */
1416
1417#ifndef SUB_SEGMENT_ALIGN
1418#ifdef HANDLE_ALIGN
1419/* The last subsegment gets an aligment corresponding to the alignment
1420 of the section. This allows proper nop-filling at the end of
1421 code-bearing sections. */
1422#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \
1423 (!(FRCHAIN)->frch_next || (FRCHAIN)->frch_next->frch_seg != (SEG) \
1424 ? get_recorded_alignment (SEG) : 0)
1425#else
1420#ifdef BFD_ASSEMBLER
1426#ifdef BFD_ASSEMBLER
1421#define SUB_SEGMENT_ALIGN(SEG) (0)
1427#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
1422#else
1428#else
1423#define SUB_SEGMENT_ALIGN(SEG) (2)
1429#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 2
1424#endif
1425#endif
1430#endif
1431#endif
1432#endif
1426
1427void
1428subsegs_finish ()
1429{
1430 struct frchain *frchainP;
1431
1432 for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next)
1433 {
1433
1434void
1435subsegs_finish ()
1436{
1437 struct frchain *frchainP;
1438
1439 for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next)
1440 {
1434 int alignment;
1441 int alignment = 0;
1435
1436 subseg_set (frchainP->frch_seg, frchainP->frch_subseg);
1437
1438 /* This now gets called even if we had errors. In that case,
1439 any alignment is meaningless, and, moreover, will look weird
1440 if we are generating a listing. */
1442
1443 subseg_set (frchainP->frch_seg, frchainP->frch_subseg);
1444
1445 /* This now gets called even if we had errors. In that case,
1446 any alignment is meaningless, and, moreover, will look weird
1447 if we are generating a listing. */
1441 alignment = had_errors () ? 0 : SUB_SEGMENT_ALIGN (now_seg);
1448 if (!had_errors ())
1449 alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
1442
1450
1443 /* The last subsegment gets an aligment corresponding to the
1444 alignment of the section. This allows proper nop-filling
1445 at the end of code-bearing sections. */
1446 if (!frchainP->frch_next || frchainP->frch_next->frch_seg != now_seg)
1447 alignment = get_recorded_alignment (now_seg);
1448
1449 if (subseg_text_p (now_seg))
1450 frag_align_code (alignment, 0);
1451 else
1452 frag_align (alignment, 0, 0);
1453
1454 /* frag_align will have left a new frag.
1455 Use this last frag for an empty ".fill".
1456

--- 128 unchanged lines hidden (view full) ---

1585 bfd_map_over_sections (stdoutput, size_seg, (char *) 0);
1586#else
1587 relax_and_size_all_segments ();
1588#endif /* BFD_ASSEMBLER */
1589
1590 /* Relaxation has completed. Freeze all syms. */
1591 finalize_syms = 1;
1592
1451 if (subseg_text_p (now_seg))
1452 frag_align_code (alignment, 0);
1453 else
1454 frag_align (alignment, 0, 0);
1455
1456 /* frag_align will have left a new frag.
1457 Use this last frag for an empty ".fill".
1458

--- 128 unchanged lines hidden (view full) ---

1587 bfd_map_over_sections (stdoutput, size_seg, (char *) 0);
1588#else
1589 relax_and_size_all_segments ();
1590#endif /* BFD_ASSEMBLER */
1591
1592 /* Relaxation has completed. Freeze all syms. */
1593 finalize_syms = 1;
1594
1593#if defined (BFD_ASSEMBLER) && defined (OBJ_COFF) && defined (TE_GO32)
1594 /* Now that the segments have their final sizes, run through the
1595 sections and set their vma and lma. !BFD gas sets them, and BFD gas
1596 should too. Currently, only DJGPP uses this code, but other
1597 COFF targets may need to execute this too. */
1598 bfd_map_over_sections (stdoutput, set_segment_vma, (char *) 0);
1599#endif
1600
1601#ifndef BFD_ASSEMBLER
1602 /* Crawl the symbol chain.
1603
1604 For each symbol whose value depends on a frag, take the address of
1605 that frag and subsume it into the value of the symbol.
1606 After this, there is just one way to lookup a symbol value.
1607 Values are left in their final state for object file emission.
1608 We adjust the values of 'L' local symbols, even if we do

--- 1401 unchanged lines hidden ---
1595#ifndef BFD_ASSEMBLER
1596 /* Crawl the symbol chain.
1597
1598 For each symbol whose value depends on a frag, take the address of
1599 that frag and subsume it into the value of the symbol.
1600 After this, there is just one way to lookup a symbol value.
1601 Values are left in their final state for object file emission.
1602 We adjust the values of 'L' local symbols, even if we do

--- 1401 unchanged lines hidden ---