]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
rth's fix for relaxation ordering problem.
authorAlan Modra <amodra@gmail.com>
Fri, 30 Mar 2001 03:11:28 +0000 (03:11 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 30 Mar 2001 03:11:28 +0000 (03:11 +0000)
gas/ChangeLog
gas/config/tc-i386.c
gas/write.c

index 555748a2cbd4bebe310092507e44b6d5ab6b8f8c..5f222e0285a5e64d69dbca236ca62627754aaca8 100644 (file)
@@ -1,3 +1,11 @@
+2001-03-30  Richard Henderson  <rth@redhat.com>
+
+       * write.c (relax_seg, size_seg): Split from relax_and_size_seg.
+       (write_object_file): Relax code then data, then size sections.
+
+       * config/tc-i386.c (md_convert_frag): Don't die on local symbols
+       that have been finalized.
+
 2001-03-28  Alan Modra  <alan@linuxcare.com.au>
 
        * config/tc-hppa.c (DEFAULT_LEVEL): Define.
index 6e9fda2b9168876be1872496d760594f1ee338be..05bdcdcfcbd7216e9c7d6c16f9fa5ab0a8fe3d48 100644 (file)
@@ -3981,7 +3981,12 @@ md_convert_frag (abfd, sec, fragP)
   target_address = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset;
 #ifdef BFD_ASSEMBLER
   /* Not needed otherwise?  */
-  target_address += symbol_get_frag (fragP->fr_symbol)->fr_address;
+  {
+    /* Local symbols which have already been resolved have a NULL frags.  */
+    fragS *sym_frag = symbol_get_frag (fragP->fr_symbol);
+    if (sym_frag)
+      target_address += sym_frag->fr_address;
+  }
 #endif
 
   /* Address opcode resides at in file space.  */
index 24b387e649f7b9aacd4450f5f3e6563065b2ece9..9ef356fe55ec625be2cbe4ee9800dda1dd730a4d 100644 (file)
@@ -121,7 +121,8 @@ 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 relax_seg PARAMS ((bfd *, asection *, PTR));
+static void 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));
@@ -593,7 +594,21 @@ cvt_frag_to_fill (headersP, sec, fragP)
 
 #ifdef BFD_ASSEMBLER
 static void
-relax_and_size_seg (abfd, sec, xxx)
+relax_seg (abfd, sec, do_code)
+     bfd *abfd;
+     asection *sec;
+     PTR do_code;
+{
+  flagword flags = bfd_get_section_flags (abfd, sec);
+  segment_info_type *seginfo = seg_info (sec);
+
+  if (!(flags & SEC_CODE) == !do_code
+      && seginfo && seginfo->frchainP)
+    relax_segment (seginfo->frchainP->frch_root, sec);
+}
+
+static void
+size_seg (abfd, sec, xxx)
      bfd *abfd;
      asection *sec;
      PTR xxx ATTRIBUTE_UNUSED;
@@ -606,12 +621,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;
@@ -624,6 +636,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;
 
@@ -1514,7 +1528,9 @@ write_object_file ()
 #endif
 
 #ifdef BFD_ASSEMBLER
-  bfd_map_over_sections (stdoutput, relax_and_size_seg, (char *) 0);
+  bfd_map_over_sections (stdoutput, relax_seg, (char *) 1);
+  bfd_map_over_sections (stdoutput, relax_seg, (char *) 0);
+  bfd_map_over_sections (stdoutput, size_seg, (char *) 0);
 #else
   relax_and_size_all_segments ();
 #endif /* BFD_ASSEMBLER  */