* simple.c (bfd_simple_get_relocated_section_contents): Move

reloc_done hack to before first bfd_section_size call.  Change all
	returns to use new wrapper macro RETURN, restoring sec->reloc_done.
This commit is contained in:
Hans-Peter Nilsson 2003-08-17 07:37:33 +00:00
parent be6389fdef
commit b0cdc7bcb0
2 changed files with 32 additions and 12 deletions

View File

@ -1,3 +1,9 @@
2003-08-17 Hans-Peter Nilsson <hp@bitrange.com>
* simple.c (bfd_simple_get_relocated_section_contents): Move
reloc_done hack to before first bfd_section_size call. Change all
returns to use new wrapper macro RETURN, restoring sec->reloc_done.
2003-08-16 Alan Modra <amodra@bigpond.net.au>
* elf64-ppc.c: Don't include elf/ppc.h.

View File

@ -140,6 +140,28 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
bfd_byte *contents, *data;
int storage_needed;
void *saved_offsets;
bfd_boolean saved_reloc_done = sec->reloc_done;
#undef RETURN
#define RETURN(x) \
do \
{ \
sec->reloc_done = saved_reloc_done; \
return (x); \
} \
while (0)
/* Foul hack to prevent bfd_section_size aborts. The reloc_done flag
only controls that macro (and the related size macros), selecting
between _raw_size and _cooked_size. We may be called with relocation
done or not, so we need to save the done-flag and mark the section as
not relocated.
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;
if (! (sec->flags & SEC_RELOC))
{
@ -153,7 +175,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
if (contents)
bfd_get_section_contents (abfd, sec, contents, 0, size);
return contents;
RETURN (contents);
}
/* In order to use bfd_get_relocated_section_contents, we need
@ -183,7 +205,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
{
data = bfd_malloc (bfd_section_size (abfd, sec));
if (data == NULL)
return NULL;
RETURN (NULL);
outbuf = data;
}
@ -202,7 +224,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
{
if (data)
free (data);
return NULL;
RETURN (NULL);
}
bfd_map_over_sections (abfd, simple_save_output_info, saved_offsets);
@ -243,15 +265,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
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);
return contents;
RETURN (contents);
}