Deleted Added
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
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#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);
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;
680 fragp->fr_offset += newsize - size;
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 }
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
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
1420#ifdef BFD_ASSEMBLER
1421#define SUB_SEGMENT_ALIGN(SEG) (0)
1422#else
1423#define SUB_SEGMENT_ALIGN(SEG) (2)
1424#endif
1425#endif
1426
1427void
1428subsegs_finish ()
1429{
1430 struct frchain *frchainP;
1431
1432 for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next)
1433 {
1434 int alignment;
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. */
1441 alignment = had_errors () ? 0 : SUB_SEGMENT_ALIGN (now_seg);
1442
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
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 ---