* gdb.threads/bp_in_thread.exp: New testcase.
[deliverable/binutils-gdb.git] / gas / write.c
index b4cc7e090b05a43dadde81548461cfbcc9ae1da1..a713a9d3981162556b1487e2d24201a6c8c68ef3 100644 (file)
@@ -1,6 +1,6 @@
 /* write.c - emit .o file
    Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002
+   1998, 1999, 2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -34,7 +34,7 @@
 
 #ifndef TC_FORCE_RELOCATION
 #define TC_FORCE_RELOCATION(FIX)               \
-  (S_FORCE_RELOC ((FIX)->fx_addsy))
+  (generic_force_reloc (FIX))
 #endif
 
 #ifndef TC_FORCE_RELOCATION_ABS
 #endif
 
 #ifndef TC_FORCE_RELOCATION_SUB_ABS
-#define TC_FORCE_RELOCATION_SUB_ABS(FIX)       \
-  (S_FORCE_RELOC ((FIX)->fx_subsy))
+#define TC_FORCE_RELOCATION_SUB_ABS(FIX)       0
 #endif
 
 #ifndef TC_FORCE_RELOCATION_SUB_LOCAL
 #ifdef DIFF_EXPR_OK
-#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX)     \
-  (S_FORCE_RELOC ((FIX)->fx_subsy))
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX)     0
 #else
-#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) 1
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX)     1
 #endif
 #endif
 
@@ -114,10 +112,10 @@ symbolS *abs_section_sym;
 /* Remember the value of dot when parsing expressions.  */
 addressT dot_value;
 
-void print_fixup PARAMS ((fixS *));
+void print_fixup (fixS *);
 
 #ifdef BFD_ASSEMBLER
-static void renumber_sections PARAMS ((bfd *, asection *, PTR));
+static void renumber_sections (bfd *, asection *, PTR);
 
 /* We generally attach relocs to frag chains.  However, after we have
    chained these all together into a segment, any relocs we add after
@@ -159,48 +157,46 @@ static int n_fixups;
 #define RELOC_ENUM int
 #endif
 
-static fixS *fix_new_internal PARAMS ((fragS *, int where, int size,
-                                      symbolS *add, symbolS *sub,
-                                      offsetT offset, int pcrel,
-                                      RELOC_ENUM r_type));
+static fixS *fix_new_internal (fragS *, int where, int size,
+                              symbolS *add, symbolS *sub,
+                              offsetT offset, int pcrel,
+                              RELOC_ENUM r_type);
 #if defined (BFD_ASSEMBLER) || (!defined (BFD) && !defined (OBJ_VMS))
-static long fixup_segment PARAMS ((fixS *, segT));
+static long fixup_segment (fixS *, segT);
 #endif
-static relax_addressT relax_align PARAMS ((relax_addressT addr, int align));
+static relax_addressT relax_align (relax_addressT addr, int align);
 #if defined (BFD_ASSEMBLER) || ! defined (BFD)
-static fragS *chain_frchains_together_1 PARAMS ((segT, struct frchain *));
+static fragS *chain_frchains_together_1 (segT, struct frchain *);
 #endif
 #ifdef BFD_ASSEMBLER
-static void chain_frchains_together PARAMS ((bfd *, segT, PTR));
-static void cvt_frag_to_fill PARAMS ((segT, fragS *));
-static void adjust_reloc_syms PARAMS ((bfd *, asection *, PTR));
-static void fix_segment PARAMS ((bfd *, asection *, PTR));
-static void write_relocs PARAMS ((bfd *, asection *, PTR));
-static void write_contents PARAMS ((bfd *, asection *, PTR));
-static void set_symtab PARAMS ((void));
+static void chain_frchains_together (bfd *, segT, PTR);
+static void cvt_frag_to_fill (segT, fragS *);
+static void adjust_reloc_syms (bfd *, asection *, PTR);
+static void fix_segment (bfd *, asection *, PTR);
+static void write_relocs (bfd *, asection *, PTR);
+static void write_contents (bfd *, asection *, PTR);
+static void set_symtab (void);
 #endif
 #if defined (BFD_ASSEMBLER) || (! defined (BFD) && ! defined (OBJ_AOUT))
-static void merge_data_into_text PARAMS ((void));
+static void merge_data_into_text (void);
 #endif
 #if ! defined (BFD_ASSEMBLER) && ! defined (BFD)
-static void cvt_frag_to_fill PARAMS ((object_headers *, segT, fragS *));
-static void remove_subsegs PARAMS ((frchainS *, int, fragS **, fragS **));
-static void relax_and_size_all_segments PARAMS ((void));
+static void cvt_frag_to_fill (object_headers *, segT, fragS *);
+static void remove_subsegs (frchainS *, int, fragS **, fragS **);
+static void relax_and_size_all_segments (void);
 #endif
 
 /* Create a fixS in obstack 'notes'.  */
 
 static fixS *
-fix_new_internal (frag, where, size, add_symbol, sub_symbol, offset, pcrel,
-                 r_type)
-     fragS *frag;              /* Which frag?  */
-     int where;                        /* Where in that frag?  */
-     int size;                 /* 1, 2, or 4 usually.  */
-     symbolS *add_symbol;      /* X_add_symbol.  */
-     symbolS *sub_symbol;      /* X_op_symbol.  */
-     offsetT offset;           /* X_add_number.  */
-     int pcrel;                        /* TRUE if PC-relative relocation.  */
-     RELOC_ENUM r_type ATTRIBUTE_UNUSED; /* Relocation type.  */
+fix_new_internal (fragS *frag,         /* Which frag?  */
+                 int where,            /* Where in that frag?  */
+                 int size,             /* 1, 2, or 4 usually.  */
+                 symbolS *add_symbol,  /* X_add_symbol.  */
+                 symbolS *sub_symbol,  /* X_op_symbol.  */
+                 offsetT offset,       /* X_add_number.  */
+                 int pcrel,            /* TRUE if PC-relative relocation.  */
+                 RELOC_ENUM r_type ATTRIBUTE_UNUSED /* Relocation type.  */)
 {
   fixS *fixP;
 
@@ -285,14 +281,13 @@ fix_new_internal (frag, where, size, add_symbol, sub_symbol, offset, pcrel,
 /* Create a fixup relative to a symbol (plus a constant).  */
 
 fixS *
-fix_new (frag, where, size, add_symbol, offset, pcrel, r_type)
-     fragS *frag;              /* Which frag?  */
-     int where;                        /* Where in that frag?  */
-     int size;                 /* 1, 2, or 4 usually.  */
-     symbolS *add_symbol;      /* X_add_symbol.  */
-     offsetT offset;           /* X_add_number.  */
-     int pcrel;                        /* TRUE if PC-relative relocation.  */
-     RELOC_ENUM r_type;                /* Relocation type.  */
+fix_new (fragS *frag,          /* Which frag?  */
+        int where,                     /* Where in that frag?  */
+        int size,                      /* 1, 2, or 4 usually.  */
+        symbolS *add_symbol,   /* X_add_symbol.  */
+        offsetT offset,                /* X_add_number.  */
+        int pcrel,                     /* TRUE if PC-relative relocation.  */
+        RELOC_ENUM r_type              /* Relocation type.  */)
 {
   return fix_new_internal (frag, where, size, add_symbol,
                           (symbolS *) NULL, offset, pcrel, r_type);
@@ -303,13 +298,12 @@ fix_new (frag, where, size, add_symbol, offset, pcrel, r_type)
    file formats support anyhow.  */
 
 fixS *
-fix_new_exp (frag, where, size, exp, pcrel, r_type)
-     fragS *frag;              /* Which frag?  */
-     int where;                        /* Where in that frag?  */
-     int size;                 /* 1, 2, or 4 usually.  */
-     expressionS *exp;         /* Expression.  */
-     int pcrel;                        /* TRUE if PC-relative relocation.  */
-     RELOC_ENUM r_type;                /* Relocation type.  */
+fix_new_exp (fragS *frag,              /* Which frag?  */
+            int where,                 /* Where in that frag?  */
+            int size,                  /* 1, 2, or 4 usually.  */
+            expressionS *exp,          /* Expression.  */
+            int pcrel,                 /* TRUE if PC-relative relocation.  */
+            RELOC_ENUM r_type          /* Relocation type.  */)
 {
   symbolS *add = NULL;
   symbolS *sub = NULL;
@@ -376,12 +370,21 @@ fix_new_exp (frag, where, size, exp, pcrel, r_type)
   return fix_new_internal (frag, where, size, add, sub, off, pcrel, r_type);
 }
 
+/* Generic function to determine whether a fixup requires a relocation.  */
+int
+generic_force_reloc (fixS *fix)
+{
+#ifdef BFD_ASSEMBLER
+  if (fix->fx_r_type == BFD_RELOC_VTABLE_INHERIT
+      || fix->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
+    return 1;
+#endif
+  return S_FORCE_RELOC (fix->fx_addsy, fix->fx_subsy == NULL);
+}
+
 /* Append a string onto another string, bumping the pointer along.  */
 void
-append (charPP, fromP, length)
-     char **charPP;
-     char *fromP;
-     unsigned long length;
+append (char **charPP, char *fromP, unsigned long length)
 {
   /* Don't trust memcpy() of 0 chars.  */
   if (length == 0)
@@ -401,12 +404,11 @@ int section_alignment[SEG_MAXIMUM_ORDINAL];
    least one object format really uses this info.  */
 
 void
-record_alignment (seg, align)
-     /* Segment to which alignment pertains.  */
-     segT seg;
-     /* Alignment, as a power of 2 (e.g., 1 => 2-byte boundary, 2 => 4-byte
-       boundary, etc.)  */
-     int align;
+record_alignment (/* Segment to which alignment pertains.  */
+                 segT seg,
+                 /* Alignment, as a power of 2 (e.g., 1 => 2-byte
+                    boundary, 2 => 4-byte boundary, etc.)  */
+                 int align)
 {
   if (seg == absolute_section)
     return;
@@ -420,8 +422,7 @@ record_alignment (seg, align)
 }
 
 int
-get_recorded_alignment (seg)
-     segT seg;
+get_recorded_alignment (segT seg)
 {
   if (seg == absolute_section)
     return 0;
@@ -437,10 +438,7 @@ get_recorded_alignment (seg)
 /* Reset the section indices after removing the gas created sections.  */
 
 static void
-renumber_sections (abfd, sec, countparg)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     PTR countparg;
+renumber_sections (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, PTR countparg)
 {
   int *countp = (int *) countparg;
 
@@ -453,9 +451,7 @@ renumber_sections (abfd, sec, countparg)
 #if defined (BFD_ASSEMBLER) || ! defined (BFD)
 
 static fragS *
-chain_frchains_together_1 (section, frchp)
-     segT section;
-     struct frchain *frchp;
+chain_frchains_together_1 (segT section, struct frchain *frchp)
 {
   fragS dummy, *prev_frag = &dummy;
 #ifdef BFD_ASSEMBLER
@@ -488,10 +484,9 @@ chain_frchains_together_1 (section, frchp)
 #ifdef BFD_ASSEMBLER
 
 static void
-chain_frchains_together (abfd, section, xxx)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     segT section;
-     PTR xxx ATTRIBUTE_UNUSED;
+chain_frchains_together (bfd *abfd ATTRIBUTE_UNUSED,
+                        segT section,
+                        PTR xxx ATTRIBUTE_UNUSED)
 {
   segment_info_type *info;
 
@@ -512,11 +507,7 @@ chain_frchains_together (abfd, section, xxx)
 #if !defined (BFD) && !defined (BFD_ASSEMBLER)
 
 static void
-remove_subsegs (head, seg, root, last)
-     frchainS *head;
-     int seg;
-     fragS **root;
-     fragS **last;
+remove_subsegs (frchainS *head, int seg, fragS **root, fragS **last)
 {
   *root = head->frch_root;
   *last = chain_frchains_together_1 (seg, head);
@@ -528,15 +519,10 @@ remove_subsegs (head, seg, root, last)
 
 #ifdef BFD_ASSEMBLER
 static void
-cvt_frag_to_fill (sec, fragP)
-     segT sec ATTRIBUTE_UNUSED;
-     fragS *fragP;
+cvt_frag_to_fill (segT sec ATTRIBUTE_UNUSED, fragS *fragP)
 #else
 static void
-cvt_frag_to_fill (headersP, sec, fragP)
-     object_headers *headersP;
-     segT sec;
-     fragS *fragP;
+cvt_frag_to_fill (object_headers *headersP, segT sec, fragS *fragP)
 #endif
 {
   switch (fragP->fr_type)
@@ -630,17 +616,18 @@ cvt_frag_to_fill (headersP, sec, fragP)
       BAD_CASE (fragP->fr_type);
       break;
     }
+#ifdef md_frag_check
+  md_frag_check (fragP);
+#endif
 }
 
 #endif /* defined (BFD_ASSEMBLER) || !defined (BFD)  */
 
 #ifdef BFD_ASSEMBLER
-static void relax_seg PARAMS ((bfd *, asection *, PTR));
+static void relax_seg (bfd *, asection *, PTR);
+
 static void
-relax_seg (abfd, sec, xxx)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     PTR xxx;
+relax_seg (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, PTR xxx)
 {
   segment_info_type *seginfo = seg_info (sec);
 
@@ -652,12 +639,10 @@ relax_seg (abfd, sec, xxx)
     }
 }
 
-static void size_seg PARAMS ((bfd *, asection *, PTR));
+static void size_seg (bfd *, asection *, PTR);
+
 static void
-size_seg (abfd, sec, xxx)
-     bfd *abfd;
-     asection *sec;
-     PTR xxx ATTRIBUTE_UNUSED;
+size_seg (bfd *abfd, asection *sec, PTR xxx ATTRIBUTE_UNUSED)
 {
   flagword flags;
   fragS *fragp;
@@ -693,11 +678,11 @@ size_seg (abfd, sec, xxx)
   else
     flags &= ~SEC_RELOC;
   x = bfd_set_section_flags (abfd, sec, flags);
-  assert (x == true);
+  assert (x);
 
   newsize = md_section_align (sec, size);
   x = bfd_set_section_size (abfd, sec, newsize);
-  assert (x == true);
+  assert (x);
 
   /* If the size had to be rounded up, add some padding in the last
      non-empty frag.  */
@@ -770,10 +755,9 @@ dump_section_relocs (abfd, sec, stream_)
    section symbols.  */
 
 static void
-adjust_reloc_syms (abfd, sec, xxx)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     PTR xxx ATTRIBUTE_UNUSED;
+adjust_reloc_syms (bfd *abfd ATTRIBUTE_UNUSED,
+                  asection *sec,
+                  PTR xxx ATTRIBUTE_UNUSED)
 {
   segment_info_type *seginfo = seg_info (sec);
   fixS *fixp;
@@ -825,7 +809,7 @@ adjust_reloc_syms (abfd, sec, xxx)
 
        /* If the symbol is undefined, common, weak, or global (ELF
           shared libs), we can't replace it with the section symbol.  */
-       if (S_FORCE_RELOC (fixp->fx_addsy))
+       if (S_FORCE_RELOC (fixp->fx_addsy, 1))
          continue;
 
        /* Is there some other (target cpu dependent) reason we can't adjust
@@ -870,7 +854,8 @@ adjust_reloc_syms (abfd, sec, xxx)
 
        /* Never adjust a reloc against local symbol in a merge section
           with non-zero addend.  */
-       if ((symsec->flags & SEC_MERGE) != 0 && fixp->fx_offset != 0)
+       if ((symsec->flags & SEC_MERGE) != 0
+           && (fixp->fx_offset != 0 || fixp->fx_subsy != NULL))
          continue;
 
        /* Never adjust a reloc against TLS local symbol.  */
@@ -892,10 +877,9 @@ adjust_reloc_syms (abfd, sec, xxx)
 }
 
 static void
-fix_segment (abfd, sec, xxx)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     PTR xxx ATTRIBUTE_UNUSED;
+fix_segment (bfd *abfd ATTRIBUTE_UNUSED,
+            asection *sec,
+            PTR xxx ATTRIBUTE_UNUSED)
 {
   segment_info_type *seginfo = seg_info (sec);
 
@@ -903,10 +887,7 @@ fix_segment (abfd, sec, xxx)
 }
 
 static void
-write_relocs (abfd, sec, xxx)
-     bfd *abfd;
-     asection *sec;
-     PTR xxx ATTRIBUTE_UNUSED;
+write_relocs (bfd *abfd, asection *sec, PTR xxx ATTRIBUTE_UNUSED)
 {
   segment_info_type *seginfo = seg_info (sec);
   unsigned int i;
@@ -926,8 +907,7 @@ write_relocs (abfd, sec, xxx)
 
 #ifndef RELOC_EXPANSION_POSSIBLE
   /* Set up reloc information as well.  */
-  relocs = (arelent **) xmalloc (n * sizeof (arelent *));
-  memset ((char *) relocs, 0, n * sizeof (arelent *));
+  relocs = (arelent **) xcalloc (n, sizeof (arelent *));
 
   i = 0;
   for (fixp = seginfo->fix_root; fixp != (fixS *) NULL; fixp = fixp->fx_next)
@@ -999,13 +979,12 @@ write_relocs (abfd, sec, xxx)
 #else
   n = n * MAX_RELOC_EXPANSION;
   /* Set up reloc information as well.  */
-  relocs = (arelent **) xmalloc (n * sizeof (arelent *));
+  relocs = (arelent **) xcalloc (n, sizeof (arelent *));
 
   i = 0;
   for (fixp = seginfo->fix_root; fixp != (fixS *) NULL; fixp = fixp->fx_next)
     {
       arelent **reloc;
-      char *data;
       bfd_reloc_status_type s;
       symbolS *sym;
       int j;
@@ -1041,7 +1020,6 @@ write_relocs (abfd, sec, xxx)
          relocs[i++] = reloc[j];
          assert (i <= n);
        }
-      data = fixp->fx_frag->fr_literal + fixp->fx_where;
       if (fixp->fx_where + fixp->fx_size
          > fixp->fx_frag->fr_fix + fixp->fx_frag->fr_offset)
        as_bad_where (fixp->fx_file, fixp->fx_line,
@@ -1120,13 +1098,12 @@ write_relocs (abfd, sec, xxx)
 }
 
 static void
-write_contents (abfd, sec, xxx)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     PTR xxx ATTRIBUTE_UNUSED;
+write_contents (bfd *abfd ATTRIBUTE_UNUSED,
+               asection *sec,
+               PTR xxx ATTRIBUTE_UNUSED)
 {
   segment_info_type *seginfo = seg_info (sec);
-  unsigned long offset = 0;
+  addressT offset = 0;
   fragS *f;
 
   /* Write out the frags.  */
@@ -1139,9 +1116,9 @@ write_contents (abfd, sec, xxx)
        f = f->fr_next)
     {
       int x;
-      unsigned long fill_size;
+      addressT fill_size;
       char *fill_literal;
-      long count;
+      offsetT count;
 
       assert (f->fr_type == rs_fill);
       if (f->fr_fix)
@@ -1149,7 +1126,7 @@ write_contents (abfd, sec, xxx)
          x = bfd_set_section_contents (stdoutput, sec,
                                        f->fr_literal, (file_ptr) offset,
                                        (bfd_size_type) f->fr_fix);
-         if (x == false)
+         if (!x)
            {
              bfd_perror (stdoutput->filename);
              as_perror (_("FATAL: Can't write %s"), stdoutput->filename);
@@ -1173,7 +1150,7 @@ write_contents (abfd, sec, xxx)
                                                fill_literal,
                                                (file_ptr) offset,
                                                (bfd_size_type) fill_size);
-                 if (x == false)
+                 if (!x)
                    {
                      bfd_perror (stdoutput->filename);
                      as_perror (_("FATAL: Can't write %s"),
@@ -1207,7 +1184,7 @@ write_contents (abfd, sec, xxx)
                  x = bfd_set_section_contents
                    (stdoutput, sec, buf, (file_ptr) offset,
                     (bfd_size_type) n_per_buf * fill_size);
-                 if (x != true)
+                 if (!x)
                    as_fatal (_("cannot write to output file"));
                  offset += n_per_buf * fill_size;
                }
@@ -1219,7 +1196,7 @@ write_contents (abfd, sec, xxx)
 
 #if defined(BFD_ASSEMBLER) || (!defined (BFD) && !defined(OBJ_AOUT))
 static void
-merge_data_into_text ()
+merge_data_into_text (void)
 {
 #if defined(BFD_ASSEMBLER) || defined(MANY_SEGMENTS)
   seg_info (text_section)->frchainP->frch_last->fr_next =
@@ -1301,7 +1278,7 @@ relax_and_size_all_segments ()
 #ifdef OBJ_BOUT
   /* See above comments on b.out data section address.  */
   {
-    long bss_vma;
+    addressT bss_vma;
     if (data_last_frag == 0)
       bss_vma = H_GET_TEXT_SIZE (&headers);
     else
@@ -1336,13 +1313,13 @@ relax_and_size_all_segments ()
 
 #ifdef BFD_ASSEMBLER
 static void
-set_symtab ()
+set_symtab (void)
 {
   int nsyms;
   asymbol **asympp;
   symbolS *symp;
-  boolean result;
-  extern PTR bfd_alloc PARAMS ((bfd *, bfd_size_type));
+  bfd_boolean result;
+  extern PTR bfd_alloc (bfd *, bfd_size_type);
 
   /* Count symbols.  We can't rely on a count made by the loop in
      write_object_file, because *_frob_file may add a new symbol or
@@ -1367,7 +1344,7 @@ set_symtab ()
   else
     asympp = 0;
   result = bfd_set_symtab (stdoutput, asympp, nsyms);
-  assert (result == true);
+  assert (result);
   symbol_table_frozen = 1;
 }
 #endif
@@ -1380,7 +1357,7 @@ set_symtab ()
 
 #ifndef SUB_SEGMENT_ALIGN
 #ifdef HANDLE_ALIGN
-/* The last subsegment gets an aligment corresponding to the alignment
+/* The last subsegment gets an alignment corresponding to the alignment
    of the section.  This allows proper nop-filling at the end of
    code-bearing sections.  */
 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN)                                        \
@@ -1396,7 +1373,7 @@ set_symtab ()
 #endif
 
 void
-subsegs_finish ()
+subsegs_finish (void)
 {
   struct frchain *frchainP;
 
@@ -1410,7 +1387,25 @@ subsegs_finish ()
          any alignment is meaningless, and, moreover, will look weird
          if we are generating a listing.  */
       if (!had_errors ())
-       alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
+       {
+         alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
+#ifdef BFD_ASSEMBLER
+         if ((bfd_get_section_flags (now_seg->owner, now_seg) & SEC_MERGE)
+             && now_seg->entsize)
+           {
+             unsigned int entsize = now_seg->entsize;
+             int entalign = 0;
+
+             while ((entsize & 1) == 0)
+               {
+                 ++entalign;
+                 entsize >>= 1;
+               }
+             if (entalign > alignment)
+               alignment = entalign;
+           }
+#endif
+       }
 
       if (subseg_text_p (now_seg))
        frag_align_code (alignment, 0);
@@ -1431,7 +1426,7 @@ subsegs_finish ()
 /* Write the object file.  */
 
 void
-write_object_file ()
+write_object_file (void)
 {
 #if ! defined (BFD_ASSEMBLER) || ! defined (WORKING_DOT_WORD)
   fragS *fragP;                        /* Track along all frags.  */
@@ -1556,6 +1551,10 @@ write_object_file ()
   /* Relaxation has completed.  Freeze all syms.  */
   finalize_syms = 1;
 
+#ifdef md_post_relax_hook
+  md_post_relax_hook;
+#endif
+
 #ifndef BFD_ASSEMBLER
   /* Crawl the symbol chain.
 
@@ -1607,7 +1606,7 @@ write_object_file ()
 #ifdef OBJ_BOUT
            || fragP->fr_next == data_frag_root
 #endif
-           || ((fragP->fr_next->fr_address - fragP->fr_address)
+           || ((offsetT) (fragP->fr_next->fr_address - fragP->fr_address)
                == (fragP->fr_fix + fragP->fr_offset * fragP->fr_var))))
        abort ();
 #endif
@@ -2030,16 +2029,13 @@ write_object_file ()
 /* Relax a fragment by scanning TC_GENERIC_RELAX_TABLE.  */
 
 long
-relax_frag (segment, fragP, stretch)
-     segT segment;
-     fragS *fragP;
-     long stretch;
+relax_frag (segT segment, fragS *fragP, long stretch)
 {
   const relax_typeS *this_type;
   const relax_typeS *start_type;
   relax_substateT next_state;
   relax_substateT this_state;
-  long growth;
+  offsetT growth;
   offsetT aim;
   addressT target;
   addressT address;
@@ -2140,9 +2136,8 @@ relax_frag (segment, fragP, stretch)
 /* Relax_align. Advance location counter to next address that has 'alignment'
    lowest order bits all 0s, return size of adjustment made.  */
 static relax_addressT
-relax_align (address, alignment)
-     register relax_addressT address;  /* Address now.  */
-     register int alignment;   /* Alignment (binary).  */
+relax_align (register relax_addressT address,  /* Address now.  */
+            register int alignment     /* Alignment (binary).  */)
 {
   relax_addressT mask;
   relax_addressT new_address;
@@ -2169,9 +2164,7 @@ relax_align (address, alignment)
    addresses.  */
 
 int
-relax_segment (segment_frag_root, segment)
-     struct frag *segment_frag_root;
-     segT segment;
+relax_segment (struct frag *segment_frag_root, segT segment)
 {
   register struct frag *fragP;
   register relax_addressT address;
@@ -2262,7 +2255,7 @@ relax_segment (segment_frag_root, segment)
 
   /* Do relax().  */
   {
-    long stretch;      /* May be any size, 0 or negative.  */
+    offsetT stretch;   /* May be any size, 0 or negative.  */
     /* Cumulative number of addresses we have relaxed this pass.
        We may have relaxed more than one address.  */
     int stretched;     /* Have we stretched on this pass?  */
@@ -2277,7 +2270,7 @@ relax_segment (segment_frag_root, segment)
 
        for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next)
          {
-           long growth = 0;
+           offsetT growth = 0;
            addressT was_address;
            offsetT offset;
            symbolS *symbolP;
@@ -2412,14 +2405,14 @@ relax_segment (segment_frag_root, segment)
                         cannot have fewer than 0 chars.  That is, we can't
                         .org backwards.  */
                      as_bad_where (fragP->fr_file, fragP->fr_line,
-                                   _("attempt to .org backwards"));
+                                   _("attempt to move .org backwards"));
 
                      /* We've issued an error message.  Change the
                          frag to avoid cascading errors.  */
                      fragP->fr_type = rs_align;
                      fragP->fr_subtype = 0;
                      fragP->fr_offset = 0;
-                     fragP->fr_fix = after - address;
+                     fragP->fr_fix = after - was_address;
                      growth = stretch;
                    }
 
@@ -2471,7 +2464,7 @@ relax_segment (segment_frag_root, segment)
              case rs_leb128:
                {
                  valueT value;
-                 int size;
+                 offsetT size;
 
                  value = resolve_symbol_value (fragP->fr_symbol);
                  size = sizeof_leb128 (value, fragP->fr_subtype);
@@ -2526,9 +2519,7 @@ relax_segment (segment_frag_root, segment)
    These will be output later by emit_relocations().  */
 
 static long
-fixup_segment (fixP, this_segment)
-     fixS *fixP;
-     segT this_segment;
+fixup_segment (fixS *fixP, segT this_segment)
 {
   long seg_reloc_count = 0;
   valueT add_number;
@@ -2611,18 +2602,12 @@ fixup_segment (fixP, this_segment)
              add_number += S_GET_VALUE (fixP->fx_addsy);
              add_number -= S_GET_VALUE (fixP->fx_subsy);
              fixP->fx_offset = add_number;
-             /* If the back-end code has selected a pc-relative
-                reloc, adjust the value to be pc-relative.  */
-             if (1
-#ifdef TC_M68K
-                 /* See the comment below about 68k weirdness.  */
-                 && 0
-#endif
-                 && fixP->fx_pcrel)
-               add_number -= MD_PCREL_FROM_SECTION (fixP, this_segment); 
              fixP->fx_addsy = NULL;
              fixP->fx_subsy = NULL;
+#ifdef TC_M68K
+             /* See the comment below about 68k weirdness.  */
              fixP->fx_pcrel = 0;
+#endif
            }
          else if (sub_symbol_segment == absolute_section
                   && !TC_FORCE_RELOCATION_SUB_ABS (fixP))
@@ -2774,10 +2759,7 @@ fixup_segment (fixP, this_segment)
 #endif /* defined (BFD_ASSEMBLER) || (!defined (BFD) && !defined (OBJ_VMS)) */
 
 void
-number_to_chars_bigendian (buf, val, n)
-     char *buf;
-     valueT val;
-     int n;
+number_to_chars_bigendian (char *buf, valueT val, int n)
 {
   if (n <= 0)
     abort ();
@@ -2789,10 +2771,7 @@ number_to_chars_bigendian (buf, val, n)
 }
 
 void
-number_to_chars_littleendian (buf, val, n)
-     char *buf;
-     valueT val;
-     int n;
+number_to_chars_littleendian (char *buf, valueT val, int n)
 {
   if (n <= 0)
     abort ();
@@ -2804,8 +2783,7 @@ number_to_chars_littleendian (buf, val, n)
 }
 
 void
-write_print_statistics (file)
-     FILE *file;
+write_print_statistics (FILE *file)
 {
   fprintf (file, "fixups: %d\n", n_fixups);
 }
@@ -2814,8 +2792,7 @@ write_print_statistics (file)
 extern int indent_level;
 
 void
-print_fixup (fixp)
-     fixS *fixp;
+print_fixup (fixS *fixp)
 {
   indent_level = 1;
   fprintf (stderr, "fix %lx %s:%d", (long) fixp, fixp->fx_file, fixp->fx_line);
This page took 0.034692 seconds and 4 git commands to generate.