TI C54x target.
[deliverable/binutils-gdb.git] / gas / write.c
index a8b804641388076e75d8e66132534b19f7b0db0b..5a5c45b83aef144108d31dd4e8e857abf8f760fa 100644 (file)
@@ -382,7 +382,7 @@ record_alignment (seg, align)
 
 static void
 renumber_sections (abfd, sec, countparg)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      asection *sec;
      PTR countparg;
 {
@@ -433,9 +433,9 @@ chain_frchains_together_1 (section, frchp)
 
 static void
 chain_frchains_together (abfd, section, xxx)
-     bfd *abfd;                        /* unused */
+     bfd *abfd ATTRIBUTE_UNUSED;
      segT section;
-     PTR xxx;                  /* unused */
+     PTR xxx ATTRIBUTE_UNUSED;
 {
   segment_info_type *info;
 
@@ -498,8 +498,9 @@ cvt_frag_to_fill (headersP, sec, fragP)
                          - fragP->fr_fix) / fragP->fr_var;
       if (fragP->fr_offset < 0)
        {
-         as_bad (_("attempt to .org/.space backwards? (%ld)"),
-                 (long) fragP->fr_offset);
+         as_bad_where (fragP->fr_file, fragP->fr_line,
+                       _("attempt to .org/.space backwards? (%ld)"),
+                       (long) fragP->fr_offset);
        }
       fragP->fr_type = rs_fill;
       break;
@@ -578,7 +579,7 @@ static void
 relax_and_size_seg (abfd, sec, xxx)
      bfd *abfd;
      asection *sec;
-     PTR xxx;
+     PTR xxx ATTRIBUTE_UNUSED;
 {
   flagword flags;
   fragS *fragp;
@@ -644,7 +645,7 @@ relax_and_size_seg (abfd, sec, xxx)
 #ifdef DEBUG2
 static void
 dump_section_relocs (abfd, sec, stream_)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      asection *sec;
      char *stream_;
 {
@@ -659,22 +660,16 @@ dump_section_relocs (abfd, sec, stream_)
   while (fixp)
     {
       symbolS *s = fixp->fx_addsy;
-      if (s)
+
+      fprintf (stream, "  %08lx: type %d ", (unsigned long) fixp,
+              (int) fixp->fx_r_type);
+      if (s == NULL)
+       fprintf (stream, "no sym\n");
+      else
        {
-         fprintf (stream, "  %08x: %s(%s", fixp, S_GET_NAME (s),
-                  s->bsym->section->name);
-         if (s->bsym->flags & BSF_SECTION_SYM)
-           {
-             fprintf (stream, " section sym");
-             if (S_GET_VALUE (s))
-               fprintf (stream, "+%x", S_GET_VALUE (s));
-           }
-         else
-           fprintf (stream, "+%x", S_GET_VALUE (s));
-         fprintf (stream, ")+%x\n", fixp->fx_offset);
+         print_symbol_value_1 (stream, s);
+         fprintf (stream, "\n");
        }
-      else
-       fprintf (stream, "  %08x: type %d no sym\n", fixp, fixp->fx_r_type);
       fixp = fixp->fx_next;
     }
 }
@@ -688,9 +683,9 @@ dump_section_relocs (abfd, sec, stream_)
 
 static void
 adjust_reloc_syms (abfd, sec, xxx)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      asection *sec;
-     PTR xxx;
+     PTR xxx ATTRIBUTE_UNUSED;
 {
   segment_info_type *seginfo = seg_info (sec);
   fixS *fixp;
@@ -780,11 +775,11 @@ adjust_reloc_syms (abfd, sec, xxx)
            goto done;
          }
 
-       /* Don't try to reduce relocs which refer to .linkonce
-           sections.  It can lead to confusion when a debugging
-           section refers to a .linkonce section.  I hope this will
-           always be correct.  */
-       if (symsec != sec)
+       /* Don't try to reduce relocs which refer to non-local symbols
+           in .linkonce sections.  It can lead to confusion when a
+           debugging section refers to a .linkonce section.  I hope
+           this will always be correct.  */
+       if (symsec != sec && ! S_IS_LOCAL (sym))
          {
            boolean linkonce;
 
@@ -865,6 +860,10 @@ adjust_reloc_syms (abfd, sec, xxx)
        fixp->fx_offset += S_GET_VALUE (sym);
        fixp->fx_addsy = section_symbol (S_GET_SEGMENT (sym));
        symbol_mark_used_in_reloc (fixp->fx_addsy);
+#ifdef DEBUG5
+       fprintf (stderr, "\nadjusted fixup:\n");
+       print_fixup (fixp);
+#endif
 
       done:
        ;
@@ -889,7 +888,7 @@ static void
 write_relocs (abfd, sec, xxx)
      bfd *abfd;
      asection *sec;
-     PTR xxx;
+     PTR xxx ATTRIBUTE_UNUSED;
 {
   segment_info_type *seginfo = seg_info (sec);
   int i;
@@ -1069,6 +1068,10 @@ write_relocs (abfd, sec, xxx)
                           (bfd_get_section_flags (abfd, sec)
                            & (flagword) ~SEC_RELOC));
 
+#ifdef SET_SECTION_RELOCS
+  SET_SECTION_RELOCS (sec, relocs, n);
+#endif
+
 #ifdef DEBUG3
   {
     int i;
@@ -1088,9 +1091,9 @@ write_relocs (abfd, sec, xxx)
 
 static void
 write_contents (abfd, sec, xxx)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      asection *sec;
-     PTR xxx;
+     PTR xxx ATTRIBUTE_UNUSED;
 {
   segment_info_type *seginfo = seg_info (sec);
   unsigned long offset = 0;
@@ -1372,7 +1375,8 @@ subsegs_finish ()
          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),
-                 NOP_OPCODE, 0);
+                 subseg_text_p (now_seg) ? NOP_OPCODE : 0,
+                 0);
 
       /* frag_align will have left a new frag.
         Use this last frag for an empty ".fill".
@@ -1624,6 +1628,9 @@ write_object_file ()
            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
            md_number_to_chars (lie->word_goes_here, to_addr, 2);
            for (untruth = lie->next_broken_word; untruth && untruth->dispfrag == fragP; untruth = untruth->next_broken_word)
@@ -2301,8 +2308,16 @@ relax_segment (segment_frag_root, segment)
                      /* Growth may be negative, but variable part of frag
                         cannot have fewer than 0 chars.  That is, we can't
                         .org backwards. */
-                     as_bad (_("attempt to .org backwards ignored"));
-                     growth = 0;
+                     as_bad_where (fragP->fr_file, fragP->fr_line,
+                                   _("attempt to .org backwards ignored"));
+
+                     /* 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;
+                     growth = stretch;
                    }
 
                  growth -= stretch;    /* This is an absolute growth factor */
@@ -2671,11 +2686,13 @@ fixup_segment (fixP, this_segment_type)
 #if !(defined (TC_V850) && defined (OBJ_ELF))
 #if !(defined (TC_M68K) && defined (OBJ_ELF))
 #if !(defined (TC_ARM)  && defined (OBJ_ELF))
+#if !(defined (TC_I960) && defined (OBJ_ELF))
 #if !defined (TC_I386) || !(defined (OBJ_ELF) || defined (OBJ_COFF)) || defined (TE_PE)
                  add_number += S_GET_VALUE (add_symbolP);
 #endif
 #endif
 #endif
+#endif
 #endif
                }
            }
@@ -2721,24 +2738,12 @@ fixup_segment (fixP, this_segment_type)
        {
          if ((size_t) size < sizeof (valueT))
            {
-             valueT mask, hibit;
+             valueT mask;
 
-             /* set all bits to one */
              mask = 0;
-             mask--;
-             /* Technically, combining these produces an undefined result
-                if size is sizeof (valueT), though I think these two
-                half-way operations should both be defined.  And the
-                compiler should be able to combine them if it's valid on
-                the host architecture.  */
-             mask <<= size * 4;
-             mask <<= size * 4;
-             hibit = (valueT) 1 << (size * 8 - 1);
-             if (((add_number & mask) != 0
-                  || (fixP->fx_signed
-                      && (add_number & hibit) != 0))
-                 && ((add_number & mask) != mask
-                     || (add_number & hibit) == 0))
+             mask--;           /* set all bits to one */
+             mask <<= size * 8 - (fixP->fx_signed ? 1 : 0);
+             if ((add_number & mask) != 0 && (add_number & mask) != mask)
                {
                  char buf[50], buf2[50];
                  sprint_value (buf, fragP->fr_address + where);
@@ -2766,7 +2771,8 @@ fixup_segment (fixP, this_segment_type)
        }                       /* not a bit fix */
 
 #ifdef TC_VALIDATE_FIX
-    skip: ;
+    skip:  ATTRIBUTE_UNUSED_LABEL
+      ;
 #endif
 #ifdef DEBUG5
       fprintf (stderr, "result:\n");
This page took 0.027031 seconds and 4 git commands to generate.