Mon Oct 14 11:24:28 1996 Richard Henderson <rth@tamu.edu>
authorIan Lance Taylor <ian@airs.com>
Mon, 14 Oct 1996 15:40:15 +0000 (15:40 +0000)
committerIan Lance Taylor <ian@airs.com>
Mon, 14 Oct 1996 15:40:15 +0000 (15:40 +0000)
* config/obj-elf.c (elf_frob_file): Move ECOFF debug processing to ...
(elf_frob_file_after_relocs): ... here.  New function.
* config/obj-elf.h (obj_from_file_after_relocs): New macro.
* write.c (write_object_file): Call *frob_after_relocs after the
call to write_relocs.

* config/tc-alpha.c: Use new BFD_RELOC_ALPHA_ELF_LITERAL reloc.

* config/tc-alpha.c (load_expression): Don't SET_VALUE on the section
symbol, as this messes up linking.  Instead, expand the recursive call
inline and change up the appropriate bits to get the 0x8000 offset
in the reloc addend.

gas/ChangeLog
gas/config/obj-elf.c
gas/write.c

index 747f89d..dc6d4de 100644 (file)
@@ -1,3 +1,18 @@
+Mon Oct 14 11:24:28 1996  Richard Henderson  <rth@tamu.edu>
+
+       * config/obj-elf.c (elf_frob_file): Move ECOFF debug processing to ...
+       (elf_frob_file_after_relocs): ... here.  New function.
+       * config/obj-elf.h (obj_from_file_after_relocs): New macro.
+       * write.c (write_object_file): Call *frob_after_relocs after the
+       call to write_relocs.
+
+       * config/tc-alpha.c: Use new BFD_RELOC_ALPHA_ELF_LITERAL reloc.
+
+       * config/tc-alpha.c (load_expression): Don't SET_VALUE on the section
+       symbol, as this messes up linking.  Instead, expand the recursive call
+       inline and change up the appropriate bits to get the 0x8000 offset
+       in the reloc addend.
+
 Thu Oct 10 17:30:31 1996  Ian Lance Taylor  <ian@cygnus.com>
 
        * config/tc-sparc.h (tc_fix_adjustable): Permit the difference of
index ffd66d1..6c37d71 100644 (file)
@@ -377,7 +377,7 @@ obj_elf_common (ignore)
   }
 }
 
-static void 
+static void
 obj_elf_local (ignore)
      int ignore;
 {
@@ -406,7 +406,7 @@ obj_elf_local (ignore)
   demand_empty_rest_of_line ();
 }
 
-static void 
+static void
 obj_elf_weak (ignore)
      int ignore;
 {
@@ -439,7 +439,7 @@ static segT previous_section;
 static int previous_subsection;
 
 /* Handle the .section pseudo-op.  This code supports two different
-   syntaxes.  
+   syntaxes.
 
    The first is found on Solaris, and looks like
        .section ".sec1",#alloc,#execinstr,#write
@@ -825,7 +825,7 @@ obj_elf_line (ignore)
   demand_empty_rest_of_line ();
 }
 
-void 
+void
 obj_read_begin_hook ()
 {
 #ifdef NEED_ECOFF_DEBUG
@@ -834,7 +834,7 @@ obj_read_begin_hook ()
 #endif
 }
 
-void 
+void
 obj_symbol_new_hook (symbolP)
      symbolS *symbolP;
 {
@@ -846,7 +846,7 @@ obj_symbol_new_hook (symbolP)
 #endif
 }
 
-void 
+void
 obj_elf_version (ignore)
      int ignore;
 {
@@ -1200,7 +1200,7 @@ elf_frob_symbol (symp, puntp)
 #endif
 }
 
-void 
+void
 elf_frob_file ()
 {
   bfd_map_over_sections (stdoutput, adjust_stab_sections, (PTR) 0);
@@ -1208,7 +1208,16 @@ elf_frob_file ()
 #ifdef elf_tc_final_processing
   elf_tc_final_processing ();
 #endif
+}
+
+/* It is required that we let write_relocs have the opportunity to
+   optimize away fixups before output has begun, since it is possible
+   to eliminate all fixups for a section and thus we never should
+   have generated the relocation section.  */
 
+void
+elf_frob_file_after_relocs ()
+{
 #ifdef NEED_ECOFF_DEBUG
   if (ECOFF_DEBUGGING)
     /* Generate the ECOFF debugging information.  */
@@ -1227,7 +1236,7 @@ elf_frob_file ()
 #define SET(ptr, offset, type) \
     debug.ptr = (type) (buf + debug.symbolic_header.offset)
 
-       SET (line, cbLineOffset, unsigned char *);
+      SET (line, cbLineOffset, unsigned char *);
       SET (external_dnr, cbDnOffset, PTR);
       SET (external_pdr, cbPdOffset, PTR);
       SET (external_sym, cbSymOffset, PTR);
@@ -1238,7 +1247,7 @@ elf_frob_file ()
       SET (external_rfd, cbRfdOffset, PTR);
       /* ssext and external_ext are set up just below.  */
 
-#undef SET    
+#undef SET
 
       /* Set up the external symbols.  */
       debug.ssext = debug.ssext_end = NULL;
index abfe79f..736e150 100644 (file)
@@ -295,7 +295,7 @@ fix_new_exp (frag, where, size, exp, pcrel, r_type)
     case O_constant:
       off = exp->X_add_number;
       break;
-      
+
     default:
       as_bad ("expression too complex for fixup");
     }
@@ -319,7 +319,7 @@ append (charPP, fromP, length)
   *charPP += length;
 }
 
-#ifndef BFD_ASSEMBLER 
+#ifndef BFD_ASSEMBLER
 int section_alignment[SEG_MAXIMUM_ORDINAL];
 #endif
 
@@ -329,7 +329,7 @@ int section_alignment[SEG_MAXIMUM_ORDINAL];
  * boundary, all of the other alignments within it will work.  At
  * least one object format really uses this info.
  */
-void 
+void
 record_alignment (seg, align)
      /* Segment to which alignment pertains */
      segT seg;
@@ -427,7 +427,7 @@ chain_frchains_together (abfd, section, xxx)
 
 #if !defined (BFD) && !defined (BFD_ASSEMBLER)
 
-void 
+void
 remove_subsegs (head, seg, root, last)
      frchainS *head;
      int seg;
@@ -727,7 +727,7 @@ adjust_reloc_syms (abfd, sec, xxx)
 #endif
 
        /* Is there some other (target cpu dependent) reason we can't adjust
-          this one?  (E.g. relocations involving function addresses on 
+          this one?  (E.g. relocations involving function addresses on
           the PA.  */
 #ifdef tc_fix_adjustable
        if (! tc_fix_adjustable (fixp))
@@ -760,9 +760,13 @@ adjust_reloc_syms (abfd, sec, xxx)
 
        /* If the section symbol isn't going to be output, the relocs
           at least should still work.  If not, figure out what to do
-          when we run into that case.  */
+          when we run into that case.
+
+          We refetch the segment when calling section_symbol, rather
+          than using symsec, because S_GET_VALUE may wind up changing
+          the section when it calls resolve_symbol_value. */
        fixp->fx_offset += S_GET_VALUE (sym);
-       fixp->fx_addsy = section_symbol (symsec);
+       fixp->fx_addsy = section_symbol (S_GET_SEGMENT (sym));
        fixp->fx_addsy->sy_used_in_reloc = 1;
 
       done:
@@ -842,9 +846,13 @@ write_relocs (abfd, sec, xxx)
          n--;
          continue;
        }
+
+#if 0
+      /* This test is triggered inappropriately for the SH.  */
       if (fixp->fx_where + fixp->fx_size
          > fixp->fx_frag->fr_fix + fixp->fx_frag->fr_offset)
        abort ();
+#endif
 
       s = bfd_install_relocation (stdoutput, reloc,
                                  fixp->fx_frag->fr_literal,
@@ -1228,7 +1236,7 @@ set_symtab ()
 }
 #endif
 
-void 
+void
 write_object_file ()
 {
   struct frchain *frchainP;    /* Track along all frchains. */
@@ -1425,7 +1433,7 @@ write_object_file ()
 #else
          fix_new_exp (lie->frag,
                       lie->word_goes_here - lie->frag->fr_literal,
-                      2, &exp, 0, BFD_RELOC_NONE);
+                      2, &exp, 0, BFD_RELOC_16);
 #endif
 #else
 #if defined(TC_SPARC) || defined(TC_A29K) || defined(NEED_FX_R_TYPE)
@@ -1636,6 +1644,13 @@ write_object_file ()
 
   PROGRESS (1);
 
+#ifdef tc_frob_file_before_adjust
+  tc_frob_file_before_adjust ();
+#endif
+#ifdef obj_frob_file_before_adjust
+  obj_frob_file_before_adjust ();
+#endif
+
   bfd_map_over_sections (stdoutput, adjust_reloc_syms, (char *)0);
 
   /* Set up symbol table, and write it out.  */
@@ -1778,6 +1793,13 @@ write_object_file ()
 
   bfd_map_over_sections (stdoutput, write_relocs, (char *) 0);
 
+#ifdef tc_frob_file_after_relocs
+  tc_frob_file_after_relocs ();
+#endif
+#ifdef obj_frob_file_after_relocs
+  obj_frob_file_after_relocs ();
+#endif
+
   bfd_map_over_sections (stdoutput, write_contents, (char *) 0);
 #endif /* BFD_ASSEMBLER */
 }
@@ -1800,7 +1822,7 @@ write_object_file ()
 #ifdef TC_GENERIC_RELAX_TABLE
 
 /* Subroutines of relax_segment.  */
-static int 
+static int
 is_dnrange (f1, f2)
      struct frag *f1;
      struct frag *f2;
@@ -1835,7 +1857,7 @@ relax_align (address, alignment)
   return (new_address - address);
 }
 
-void 
+void
 relax_segment (segment_frag_root, segment)
      struct frag *segment_frag_root;
      segT segment;
@@ -2210,7 +2232,7 @@ fixup_segment (fixP, this_segment_type)
   int pcrel, plt;
   fragS *fragP;
   segT add_symbol_segment = absolute_section;
-  
+
   /* If the linker is doing the relaxing, we must not do any fixups.
 
      Well, strictly speaking that's not true -- we could do any that are
@@ -2258,7 +2280,7 @@ fixup_segment (fixP, this_segment_type)
 
       if (add_symbolP)
        add_symbol_segment = S_GET_SEGMENT (add_symbolP);
-      
+
       if (sub_symbolP)
        {
          resolve_symbol_value (sub_symbolP);
@@ -2395,7 +2417,7 @@ fixup_segment (fixP, this_segment_type)
              add_number += S_GET_VALUE (add_symbolP);
              add_number -= MD_PCREL_FROM_SECTION (fixP, this_segment_type);
              pcrel = 0;        /* Lie. Don't want further pcrel processing. */
-             
+
              /* Let the target machine make the final determination
                 as to whether or not a relocation will be needed to
                 handle this fixup.  */
@@ -2418,7 +2440,7 @@ fixup_segment (fixP, this_segment_type)
                  /* Let the target machine make the final determination
                     as to whether or not a relocation will be needed to
                     handle this fixup.  */
-                 
+
                  if (!TC_FORCE_RELOCATION (fixP))
                    {
                      fixP->fx_addsy = NULL;
@@ -2446,7 +2468,7 @@ fixup_segment (fixP, this_segment_type)
                      continue;
                    }           /* COBR */
 #endif /* TC_I960 */
-                 
+
 #ifdef OBJ_COFF
 #ifdef TE_I386AIX
                  if (S_IS_COMMON (add_symbolP))