Deleted Added
sdiff udiff text old ( 94536 ) new ( 104834 )
full compact
1/* write.c - emit .o file
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
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
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
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;
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;
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 ();
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 }
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
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
1426#ifdef BFD_ASSEMBLER
1427#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
1428#else
1429#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 2
1430#endif
1431#endif
1432#endif
1433
1434void
1435subsegs_finish ()
1436{
1437 struct frchain *frchainP;
1438
1439 for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next)
1440 {
1441 int alignment = 0;
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. */
1448 if (!had_errors ())
1449 alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
1450
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
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 ---