* infptrace.c (child_xfer_memory): Add cast to CORE_ADDR.
[deliverable/binutils-gdb.git] / gas / write.c
index b2060b37418bd40e7e58032df7a4709d7cfd2ef3..41edcb3545ff8433d3736db84f43aebb760cb352 100644 (file)
@@ -1,5 +1,6 @@
 /* write.c - emit .o file
-   Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
+   1998, 1999, 2000, 2001
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 #include "subsegs.h"
 #include "obstack.h"
 #include "output-file.h"
+#include "dwarf2dbg.h"
 
 /* This looks like a good idea.  Let's try turning it on always, for now.  */
 #undef  BFD_FAST_SECTION_FILL
 #define BFD_FAST_SECTION_FILL
 
-/* The NOP_OPCODE is for the alignment fill value.  Fill it with a nop
-   instruction so that the disassembler does not choke on it.  */
-#ifndef NOP_OPCODE
-#define NOP_OPCODE 0x00
-#endif
-
 #ifndef TC_ADJUST_RELOC_COUNT
 #define TC_ADJUST_RELOC_COUNT(FIXP,COUNT)
 #endif
 #ifndef TC_FIX_ADJUSTABLE
 #define TC_FIX_ADJUSTABLE(fix) 1
 #endif
-                 
+
+#ifndef TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
+#define TC_FINALIZE_SYMS_BEFORE_SIZE_SEG 1
+#endif
+
 #ifndef        MD_PCREL_FROM_SECTION
 #define MD_PCREL_FROM_SECTION(FIXP, SEC) md_pcrel_from(FIXP)
 #endif
@@ -65,6 +65,9 @@ extern CONST int md_short_jump_size;
 extern CONST int md_long_jump_size;
 #endif
 
+/* Used to control final evaluation of expressions.  */
+int finalize_syms = 0;
+
 int symbol_table_frozen;
 void print_fixup PARAMS ((fixS *));
 
@@ -126,7 +129,6 @@ static fragS *chain_frchains_together_1 PARAMS ((segT, struct frchain *));
 #ifdef BFD_ASSEMBLER
 static void chain_frchains_together PARAMS ((bfd *, segT, PTR));
 static void cvt_frag_to_fill PARAMS ((segT, fragS *));
-static void relax_and_size_seg PARAMS ((bfd *, asection *, PTR));
 static void adjust_reloc_syms PARAMS ((bfd *, asection *, PTR));
 static void write_relocs PARAMS ((bfd *, asection *, PTR));
 static void write_contents PARAMS ((bfd *, asection *, PTR));
@@ -287,6 +289,10 @@ fix_new_exp (frag, where, size, exp, pcrel, r_type)
     case O_absent:
       break;
 
+    case O_register:
+      as_bad (_("register value used as expression"));
+      break;
+
     case O_add:
       /* This comes up when _GLOBAL_OFFSET_TABLE_+(.-L0) is read, if
         the difference expression cannot immediately be reduced.  */
@@ -382,6 +388,19 @@ record_alignment (seg, align)
 #endif
 }
 
+int
+get_recorded_alignment (seg)
+     segT seg;
+{
+  if (seg == absolute_section)
+    return 0;
+#ifdef BFD_ASSEMBLER
+  return bfd_get_section_alignment (stdoutput, seg);
+#else
+  return section_alignment[(int) seg];
+#endif
+}
+
 #ifdef BFD_ASSEMBLER
 
 /* Reset the section indices after removing the gas created sections.  */
@@ -493,6 +512,7 @@ cvt_frag_to_fill (headersP, sec, fragP)
     {
     case rs_align:
     case rs_align_code:
+    case rs_align_test:
     case rs_org:
     case rs_space:
 #ifdef HANDLE_ALIGN
@@ -534,6 +554,10 @@ cvt_frag_to_fill (headersP, sec, fragP)
       eh_frame_convert_frag (fragP);
       break;
 
+    case rs_dwarf2dbg:
+      dwarf2dbg_convert_frag (fragP);
+      break;
+
     case rs_machine_dependent:
 #ifdef BFD_ASSEMBLER
       md_convert_frag (stdoutput, sec, fragP);
@@ -579,8 +603,26 @@ cvt_frag_to_fill (headersP, sec, fragP)
 #endif /* defined (BFD_ASSEMBLER) || !defined (BFD)  */
 
 #ifdef BFD_ASSEMBLER
+static void relax_seg PARAMS ((bfd *, asection *, PTR));
 static void
-relax_and_size_seg (abfd, sec, xxx)
+relax_seg (abfd, sec, xxx)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     asection *sec;
+     PTR xxx;
+{
+  segment_info_type *seginfo = seg_info (sec);
+
+  if (seginfo && seginfo->frchainP
+      && relax_segment (seginfo->frchainP->frch_root, sec))
+    {
+      int *result = (int *) xxx;
+      *result = 1;
+    }
+}
+
+static void size_seg PARAMS ((bfd *, asection *, PTR));
+static void
+size_seg (abfd, sec, xxx)
      bfd *abfd;
      asection *sec;
      PTR xxx ATTRIBUTE_UNUSED;
@@ -593,12 +635,9 @@ relax_and_size_seg (abfd, sec, xxx)
 
   subseg_change (sec, 0);
 
-  flags = bfd_get_section_flags (abfd, sec);
-
   seginfo = seg_info (sec);
   if (seginfo && seginfo->frchainP)
     {
-      relax_segment (seginfo->frchainP->frch_root, sec);
       for (fragp = seginfo->frchainP->frch_root; fragp; fragp = fragp->fr_next)
        cvt_frag_to_fill (sec, fragp);
       for (fragp = seginfo->frchainP->frch_root;
@@ -611,6 +650,8 @@ relax_and_size_seg (abfd, sec, xxx)
   else
     size = 0;
 
+  flags = bfd_get_section_flags (abfd, sec);
+
   if (size > 0 && ! seginfo->bss)
     flags |= SEC_HAS_CONTENTS;
 
@@ -721,10 +762,10 @@ adjust_reloc_syms (abfd, sec, xxx)
           symbols, though, since they are not in the regular symbol
           table.  */
        if (sym != NULL)
-         resolve_symbol_value (sym, 1);
+         resolve_symbol_value (sym);
 
        if (fixp->fx_subsy != NULL)
-         resolve_symbol_value (fixp->fx_subsy, 1);
+         resolve_symbol_value (fixp->fx_subsy);
 
        /* If this symbol is equated to an undefined symbol, convert
            the fixup to being against that symbol.  */
@@ -833,6 +874,13 @@ adjust_reloc_syms (abfd, sec, xxx)
            symbol_mark_used_in_reloc (fixp->fx_addsy);
            goto done;
          }
+
+       /* Never adjust a reloc against local symbol in a merge section.  */
+       if (symsec->flags & SEC_MERGE)
+         {
+           symbol_mark_used_in_reloc (fixp->fx_addsy);
+           goto done;
+         }
 #endif
 
        /* Is there some other reason we can't adjust this one?  (E.g.,
@@ -899,7 +947,7 @@ write_relocs (abfd, sec, xxx)
      PTR xxx ATTRIBUTE_UNUSED;
 {
   segment_info_type *seginfo = seg_info (sec);
-  int i;
+  unsigned int i;
   unsigned int n;
   arelent **relocs;
   fixS *fixp;
@@ -1008,7 +1056,7 @@ write_relocs (abfd, sec, xxx)
        }
 
       /* If this is an undefined symbol which was equated to another
-         symbol, then use generate the reloc against the latter symbol
+         symbol, then generate the reloc against the latter symbol
          rather than the former.  */
       sym = fixp->fx_addsy;
       while (symbol_equated_p (sym)
@@ -1385,14 +1433,25 @@ subsegs_finish ()
 
   for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next)
     {
+      int alignment;
+
       subseg_set (frchainP->frch_seg, frchainP->frch_subseg);
 
       /* This now gets called even if we had errors.  In that case,
          any alignment is meaningless, and, moreover, will look weird
          if we are generating a listing.  */
-      frag_align (had_errors () ? 0 : SUB_SEGMENT_ALIGN (now_seg),
-                 subseg_text_p (now_seg) ? NOP_OPCODE : 0,
-                 0);
+      alignment = had_errors () ? 0 : SUB_SEGMENT_ALIGN (now_seg);
+
+      /* The last subsegment gets an aligment corresponding to the
+        alignment of the section.  This allows proper nop-filling
+        at the end of code-bearing sections.  */
+      if (!frchainP->frch_next || frchainP->frch_next->frch_seg != now_seg)
+       alignment = get_recorded_alignment (now_seg);
+
+      if (subseg_text_p (now_seg))
+       frag_align_code (alignment, 0);
+      else
+       frag_align (alignment, 0, 0);
 
       /* frag_align will have left a new frag.
         Use this last frag for an empty ".fill".
@@ -1490,11 +1549,53 @@ write_object_file ()
 #endif
 
 #ifdef BFD_ASSEMBLER
-  bfd_map_over_sections (stdoutput, relax_and_size_seg, (char *) 0);
+  while (1)
+    {
+      int changed;
+
+#ifndef WORKING_DOT_WORD
+      /* We need to reset the markers in the broken word list and
+        associated frags between calls to relax_segment (via
+        relax_seg).  Since the broken word list is global, we do it
+        once per round, rather than locally in relax_segment for each
+        segment.  */
+      struct broken_word *brokp;
+
+      for (brokp = broken_words;
+          brokp != (struct broken_word *) NULL;
+          brokp = brokp->next_broken_word)
+       {
+         brokp->added = 0;
+
+         if (brokp->dispfrag != (fragS *) NULL
+             && brokp->dispfrag->fr_type == rs_broken_word)
+           brokp->dispfrag->fr_subtype = 0;
+       }
+#endif
+
+      changed = 0;
+      bfd_map_over_sections (stdoutput, relax_seg, &changed);
+      if (!changed)
+       break;
+    }
+
+  /* Note - Most ports will use the default value of
+     TC_FINALIZE_SYMS_BEFORE_SIZE_SEG, which 1.  This will force
+     local symbols to be resolved, removing their frag information.
+     Some ports however, will not have finished relaxing all of
+     their frags and will still need the local symbol frag
+     information.  These ports can set
+     TC_FINALIZE_SYMS_BEFORE_SIZE_SEG to 0.  */
+  finalize_syms = TC_FINALIZE_SYMS_BEFORE_SIZE_SEG;
+
+  bfd_map_over_sections (stdoutput, size_seg, (char *) 0);
 #else
   relax_and_size_all_segments ();
 #endif /* BFD_ASSEMBLER  */
 
+  /* Relaxation has completed.  Freeze all syms.  */
+  finalize_syms = 1;
+
 #if defined (BFD_ASSEMBLER) && defined (OBJ_COFF) && defined (TE_GO32)
   /* Now that the segments have their final sizes, run through the
      sections and set their vma and lma. !BFD gas sets them, and BFD gas
@@ -1649,9 +1750,6 @@ write_object_file ()
            /* Patch the jump table.  */
            /* This is the offset from ??? to table_ptr+0.  */
            to_addr = table_addr - S_GET_VALUE (lie->sub);
-#ifdef BFD_ASSEMBLER
-           to_addr -= symbol_get_frag (lie->sub)->fr_address;
-#endif
 #ifdef TC_CHECK_ADJUSTED_BROKEN_DOT_WORD
            TC_CHECK_ADJUSTED_BROKEN_DOT_WORD (to_addr, lie);
 #endif
@@ -1668,9 +1766,6 @@ write_object_file ()
            /* This is a long jump from table_ptr+0 to the final target.  */
            from_addr = table_addr;
            to_addr = S_GET_VALUE (lie->add) + lie->addnum;
-#ifdef BFD_ASSEMBLER
-           to_addr += symbol_get_frag (lie->add)->fr_address;
-#endif
            md_create_long_jump (table_ptr, from_addr, to_addr, lie->dispfrag,
                                 lie->add);
            table_ptr += md_long_jump_size;
@@ -1813,7 +1908,7 @@ write_object_file ()
       symbolS *symp;
 
       for (symp = symbol_rootP; symp; symp = symbol_next (symp))
-       resolve_symbol_value (symp, 1);
+       resolve_symbol_value (symp);
     }
   resolve_local_symbol_values ();
 
@@ -1861,7 +1956,7 @@ write_object_file ()
          /* Do it again, because adjust_reloc_syms might introduce
             more symbols.  They'll probably only be section symbols,
             but they'll still need to have the values computed.  */
-         resolve_symbol_value (symp, 1);
+         resolve_symbol_value (symp);
 
          /* Skip symbols which were equated to undefined or common
              symbols.  */
@@ -1971,24 +2066,11 @@ write_object_file ()
 
 #ifdef TC_GENERIC_RELAX_TABLE
 
-static int is_dnrange PARAMS ((fragS *, fragS *));
-
-/* Subroutines of relax_segment.  */
-static int
-is_dnrange (f1, f2)
-     fragS *f1;
-     fragS *f2;
-{
-  for (; f1; f1 = f1->fr_next)
-    if (f1->fr_next == f2)
-      return 1;
-  return 0;
-}
-
 /* Relax a fragment by scanning TC_GENERIC_RELAX_TABLE.  */
 
 long
-relax_frag (fragP, stretch)
+relax_frag (segment, fragP, stretch)
+     segT segment;
      fragS *fragP;
      long stretch;
 {
@@ -1996,20 +2078,26 @@ relax_frag (fragP, stretch)
   const relax_typeS *start_type;
   relax_substateT next_state;
   relax_substateT this_state;
-  long aim, target, growth;
-  symbolS *symbolP = fragP->fr_symbol;
-  long offset = fragP->fr_offset;
-  /* Recompute was_address by undoing "+= stretch" done by relax_segment.  */
-  unsigned long was_address = fragP->fr_address - stretch;
-  unsigned long address = fragP->fr_address;
-  const relax_typeS *table = TC_GENERIC_RELAX_TABLE;
-
+  long growth;
+  offsetT aim;
+  addressT target;
+  addressT address;
+  symbolS *symbolP;
+  const relax_typeS *table;
+
+  target = fragP->fr_offset;
+  address = fragP->fr_address;
+  table = TC_GENERIC_RELAX_TABLE;
   this_state = fragP->fr_subtype;
   start_type = this_type = table + this_state;
-  target = offset;
+  symbolP = fragP->fr_symbol;
 
   if (symbolP)
     {
+      fragS *sym_frag;
+
+      sym_frag = symbol_get_frag (symbolP);
+
 #ifndef DIFF_EXPR_OK
 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
       know ((S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE)
@@ -2017,23 +2105,20 @@ relax_frag (fragP, stretch)
            || (S_GET_SEGMENT (symbolP) == SEG_BSS)
            || (S_GET_SEGMENT (symbolP) == SEG_TEXT));
 #endif
-      know (symbolP->sy_frag);
+      know (sym_frag != NULL);
 #endif
       know (!(S_GET_SEGMENT (symbolP) == absolute_section)
-           || symbolP->sy_frag == &zero_address_frag);
-      target += S_GET_VALUE (symbolP) + symbol_get_frag (symbolP)->fr_address;
+           || sym_frag == &zero_address_frag);
+      target += S_GET_VALUE (symbolP);
 
       /* If frag has yet to be reached on this pass,
         assume it will move by STRETCH just as we did.
         If this is not so, it will be because some frag
-        between grows, and that will force another pass.
-
-        Beware zero-length frags.
-
-        There should be a faster way to do this.  */
+        between grows, and that will force another pass.  */
 
-      if (symbol_get_frag (symbolP)->fr_address >= was_address
-         && is_dnrange (fragP, symbol_get_frag (symbolP)))
+      if (stretch != 0
+         && sym_frag->relax_marker != fragP->relax_marker
+         && S_GET_SEGMENT (symbolP) == segment)
        {
          target += stretch;
        }
@@ -2122,13 +2207,15 @@ relax_align (address, alignment)
    these frag addresses may not be the same as final object-file
    addresses.  */
 
-void
+int
 relax_segment (segment_frag_root, segment)
      struct frag *segment_frag_root;
      segT segment;
 {
   register struct frag *fragP;
   register relax_addressT address;
+  int ret;
+
 #if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
   know (segment == SEG_DATA || segment == SEG_TEXT || segment == SEG_BSS);
 #endif
@@ -2140,6 +2227,7 @@ relax_segment (segment_frag_root, segment)
   address = 0;
   for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next)
     {
+      fragP->relax_marker = 0;
       fragP->fr_address = address;
       address += fragP->fr_fix;
 
@@ -2151,6 +2239,7 @@ relax_segment (segment_frag_root, segment)
 
        case rs_align:
        case rs_align_code:
+       case rs_align_test:
          {
            addressT offset = relax_align (address, (int) fragP->fr_offset);
 
@@ -2159,8 +2248,9 @@ relax_segment (segment_frag_root, segment)
 
            if (offset % fragP->fr_var != 0)
              {
-               as_bad (_("alignment padding (%lu bytes) not a multiple of %ld"),
-                       (unsigned long) offset, (long) fragP->fr_var);
+               as_bad_where (fragP->fr_file, fragP->fr_line,
+                             _("alignment padding (%lu bytes) not a multiple of %ld"),
+                             (unsigned long) offset, (long) fragP->fr_var);
                offset -= (offset % fragP->fr_var);
              }
 
@@ -2193,6 +2283,10 @@ relax_segment (segment_frag_root, segment)
          address += eh_frame_estimate_size_before_relax (fragP);
          break;
 
+       case rs_dwarf2dbg:
+         address += dwarf2dbg_estimate_size_before_relax (fragP);
+         break;
+
        default:
          BAD_CASE (fragP->fr_type);
          break;
@@ -2204,14 +2298,15 @@ relax_segment (segment_frag_root, segment)
     long 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.  */
-    long stretched;    /* Have we stretched on this pass?  */
+    int stretched;     /* Have we stretched on this pass?  */
     /* This is 'cuz stretch may be zero, when, in fact some piece of code
        grew, and another shrank.  If a branch instruction doesn't fit anymore,
        we could be scrod.  */
 
     do
       {
-       stretch = stretched = 0;
+       stretch = 0;
+       stretched = 0;
 
        for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next)
          {
@@ -2220,6 +2315,7 @@ relax_segment (segment_frag_root, segment)
            offsetT offset;
            symbolS *symbolP;
 
+           fragP->relax_marker ^= 1;
            was_address = fragP->fr_address;
            address = fragP->fr_address += stretch;
            symbolP = fragP->fr_symbol;
@@ -2254,21 +2350,20 @@ relax_segment (segment_frag_root, segment)
                      if (lie->added)
                        continue;
 
-                     offset = (symbol_get_frag (lie->add)->fr_address
-                               + S_GET_VALUE (lie->add)
+                     offset = (S_GET_VALUE (lie->add)
                                + lie->addnum
-                               - (symbol_get_frag (lie->sub)->fr_address
-                                  + S_GET_VALUE (lie->sub)));
+                               - S_GET_VALUE (lie->sub));
                      if (offset <= -32768 || offset >= 32767)
                        {
                          if (flag_warn_displacement)
                            {
                              char buf[50];
                              sprint_value (buf, (addressT) lie->addnum);
-                             as_warn (_(".word %s-%s+%s didn't fit"),
-                                      S_GET_NAME (lie->add),
-                                      S_GET_NAME (lie->sub),
-                                      buf);
+                             as_warn_where (fragP->fr_file, fragP->fr_line,
+                                            _(".word %s-%s+%s didn't fit"),
+                                            S_GET_NAME (lie->add),
+                                            S_GET_NAME (lie->sub),
+                                            buf);
                            }
                          lie->added = 1;
                          if (fragP->fr_subtype == 0)
@@ -2296,6 +2391,7 @@ relax_segment (segment_frag_root, segment)
 #endif
              case rs_align:
              case rs_align_code:
+             case rs_align_test:
                {
                  addressT oldoff, newoff;
 
@@ -2318,8 +2414,8 @@ relax_segment (segment_frag_root, segment)
 
              case rs_org:
                {
-                 long target = offset;
-                 long after;
+                 addressT target = offset;
+                 addressT after;
 
                  if (symbolP)
                    {
@@ -2332,9 +2428,8 @@ relax_segment (segment_frag_root, segment)
                      know (!(S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE)
                            || (symbolP->sy_frag == &zero_address_frag));
 #endif
-                     target += (S_GET_VALUE (symbolP)
-                                + symbol_get_frag (symbolP)->fr_address);
-                   }           /* if we have a symbol  */
+                     target += S_GET_VALUE (symbolP);
+                   }
 
                  know (fragP->fr_next);
                  after = fragP->fr_next->fr_address;
@@ -2362,33 +2457,41 @@ relax_segment (segment_frag_root, segment)
                }
 
              case rs_space:
+               growth = 0;
                if (symbolP)
                  {
-                   growth = S_GET_VALUE (symbolP);
-                   if (symbol_get_frag (symbolP) != &zero_address_frag
+                   offsetT amount;
+
+                   amount = S_GET_VALUE (symbolP);
+                   if (S_GET_SEGMENT (symbolP) != absolute_section
                        || S_IS_COMMON (symbolP)
                        || ! S_IS_DEFINED (symbolP))
-                     as_bad_where (fragP->fr_file, fragP->fr_line,
-                                   _(".space specifies non-absolute value"));
-                   fragP->fr_symbol = 0;
-                   if (growth < 0)
                      {
-                       as_warn (_(".space or .fill with negative value, ignored"));
-                       growth = 0;
+                       as_bad_where (fragP->fr_file, fragP->fr_line,
+                                     _(".space specifies non-absolute value"));
+                       /* Prevent repeat of this error message.  */
+                       fragP->fr_symbol = 0;
                      }
+                   else if (amount < 0)
+                     {
+                       as_warn_where (fragP->fr_file, fragP->fr_line,
+                                      _(".space or .fill with negative value, ignored"));
+                       fragP->fr_symbol = 0;
+                     }
+                   else
+                     growth = (was_address + amount
+                               - fragP->fr_next->fr_address);
                  }
-               else
-                 growth = 0;
                break;
 
              case rs_machine_dependent:
 #ifdef md_relax_frag
-               growth = md_relax_frag (fragP, stretch);
+               growth = md_relax_frag (segment, fragP, stretch);
 #else
 #ifdef TC_GENERIC_RELAX_TABLE
                /* The default way to relax a frag is to look through
                   TC_GENERIC_RELAX_TABLE.  */
-               growth = relax_frag (fragP, stretch);
+               growth = relax_frag (segment, fragP, stretch);
 #endif /* TC_GENERIC_RELAX_TABLE  */
 #endif
                break;
@@ -2398,7 +2501,7 @@ relax_segment (segment_frag_root, segment)
                  valueT value;
                  int size;
 
-                 value = resolve_symbol_value (fragP->fr_symbol, 0);
+                 value = resolve_symbol_value (fragP->fr_symbol);
                  size = sizeof_leb128 (value, fragP->fr_subtype);
                  growth = size - fragP->fr_offset;
                  fragP->fr_offset = size;
@@ -2409,6 +2512,10 @@ relax_segment (segment_frag_root, segment)
                growth = eh_frame_relax_frag (fragP);
                break;
 
+             case rs_dwarf2dbg:
+               growth = dwarf2dbg_relax_frag (fragP);
+               break;
+
              default:
                BAD_CASE (fragP->fr_type);
                break;
@@ -2416,17 +2523,21 @@ relax_segment (segment_frag_root, segment)
            if (growth)
              {
                stretch += growth;
-               stretched++;
+               stretched = 1;
              }
          }                     /* For each frag in the segment.  */
       }
     while (stretched);         /* Until nothing further to relax.  */
   }                            /* do_relax  */
 
-  /* We now have valid fr_address'es for each frag.  */
-
-  /* All fr_address's are correct, relative to their own segment.
-     We have made all the fixS we will ever make.  */
+  ret = 0;
+  for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next)
+    if (fragP->last_fr_address != fragP->fr_address)
+      {
+       fragP->last_fr_address = fragP->fr_address;
+       ret = 1;
+      }
+  return ret;
 }
 
 #if defined (BFD_ASSEMBLER) || (!defined (BFD) && !defined (OBJ_VMS))
@@ -2513,7 +2624,7 @@ fixup_segment (fixP, this_segment_type)
 
       if (sub_symbolP)
        {
-         resolve_symbol_value (sub_symbolP, 1);
+         resolve_symbol_value (sub_symbolP);
          if (add_symbolP == NULL || add_symbol_segment == absolute_section)
            {
              if (add_symbolP != NULL)
@@ -2554,8 +2665,15 @@ fixup_segment (fixP, this_segment_type)
                as_bad_where (fixP->fx_file, fixP->fx_line,
                              _("callj to difference of 2 symbols"));
 #endif /* TC_I960  */
-             add_number += S_GET_VALUE (add_symbolP) -
-               S_GET_VALUE (sub_symbolP);
+             add_number += (S_GET_VALUE (add_symbolP)
+                            - S_GET_VALUE (sub_symbolP));
+             if (1
+#ifdef TC_M68K
+                 /* See the comment below about 68k weirdness.  */
+                 && 0
+#endif
+                 && pcrel)
+               add_number -= MD_PCREL_FROM_SECTION (fixP, this_segment_type);
 
              add_symbolP = NULL;
              pcrel = 0;        /* No further pcrel processing.  */
@@ -2580,21 +2698,26 @@ fixup_segment (fixP, this_segment_type)
                add_number -= S_GET_VALUE (sub_symbolP);
 
 #ifdef DIFF_EXPR_OK
-             else if (S_GET_SEGMENT (sub_symbolP) == this_segment_type
-#if 0
-                      /* Do this even if it's already described as
-                         pc-relative.  For example, on the m68k, an
-                         operand of "pc@(foo-.-2)" should address
-                         "foo" in a pc-relative mode.  */
-                      && pcrel
-#endif
-                      )
+             else if (S_GET_SEGMENT (sub_symbolP) == this_segment_type)
                {
                  /* Make it pc-relative.  */
-                 add_number += (MD_PCREL_FROM_SECTION (fixP, this_segment_type)
-                                - S_GET_VALUE (sub_symbolP));
-                 pcrel = 1;
-                 fixP->fx_pcrel = 1;
+                 if (0
+#ifdef TC_M68K
+                     /* Do this for m68k even if it's already described
+                        as pc-relative.  On the m68k, an operand of
+                        "pc@(foo-.-2)" should address "foo" in a
+                        pc-relative mode.  */
+                     || 1
+#endif
+                     || !pcrel)
+                   {
+                     add_number += MD_PCREL_FROM_SECTION (fixP,
+                                                          this_segment_type);
+                     pcrel = 1;
+                     fixP->fx_pcrel = 1;
+                   }
+
+                 add_number -= S_GET_VALUE (sub_symbolP);
                  sub_symbolP = 0;
                  fixP->fx_subsy = 0;
                }
This page took 0.043335 seconds and 4 git commands to generate.