binutils ChangeLog:
[deliverable/binutils-gdb.git] / bfd / simple.c
index 256fd913b851715afccf703b93a835ae80351502..fc2472eefd21eecbd0be413b1c74eb155572d399 100644 (file)
@@ -1,5 +1,5 @@
 /* simple.c -- BFD simple client routines
-   Copyright 2002, 2003
+   Copyright 2002, 2003, 2004
    Free Software Foundation, Inc.
    Contributed by MontaVista Software, Inc.
 
@@ -140,6 +140,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
   bfd_byte *contents, *data;
   int storage_needed;
   void *saved_offsets;
+  bfd_size_type old_cooked_size;
 
   if (! (sec->flags & SEC_RELOC))
     {
@@ -163,7 +164,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
   memset (&link_info, 0, sizeof (link_info));
   link_info.input_bfds = abfd;
 
-  link_info.hash = bfd_link_hash_table_create (abfd);
+  link_info.hash = _bfd_generic_link_hash_table_create (abfd);
   link_info.callbacks = &callbacks;
   callbacks.warning = simple_dummy_warning;
   callbacks.undefined_symbol = simple_dummy_undefined_symbol;
@@ -189,7 +190,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
 
   /* The sections in ABFD may already have output sections and offsets set.
      Because this function is primarily for debug sections, and GCC uses the
-     knowledge that debug sections will generally have VMA 0 when emiting
+     knowledge that debug sections will generally have VMA 0 when emitting
      relocations between DWARF-2 sections (which are supposed to be
      section-relative offsets anyway), we need to reset the output offsets
      to zero.  We also need to arrange for section->output_section->vma plus
@@ -217,6 +218,12 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
   else
     storage_needed = 0;
 
+  /* This function might be called before _cooked_size has been set, and
+     bfd_perform_relocation needs _cooked_size to be valid.  */
+  old_cooked_size = sec->_cooked_size;
+  if (old_cooked_size == 0)
+    sec->_cooked_size = sec->_raw_size;
+
   contents = bfd_get_relocated_section_contents (abfd,
                                                 &link_info,
                                                 &link_order,
@@ -240,18 +247,11 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
     free (symbol_table);
 #endif
 
+  sec->_cooked_size = old_cooked_size;
   bfd_map_over_sections (abfd, simple_restore_output_info, saved_offsets);
   free (saved_offsets);
 
-  /* Foul hack to prevent bfd_section_size aborts.  This flag only controls
-     that macro (and the related size macros), selecting between _raw_size
-     and _cooked_size.  Debug sections won't change size while we're only
-     relocating.  There may be trouble here someday if it tries to run
-     relaxation unexpectedly, so make sure.  */
-  BFD_ASSERT (sec->_raw_size == sec->_cooked_size);
-  sec->reloc_done = 0;
-
-  bfd_link_hash_table_free (abfd, link_info.hash);
+  _bfd_generic_link_hash_table_free (link_info.hash);
 
   return contents;
 }
This page took 0.027624 seconds and 4 git commands to generate.