summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2003-08-17 07:37:33 +0000
committerHans-Peter Nilsson <hp@axis.com>2003-08-17 07:37:33 +0000
commit98367ef3a4f443c255d6635f1f3563c03d01636c (patch)
treede25fad9187c72234131e098a3990fab2ae20643
parent886509273ea05b6015380233f1c8d76635d808b3 (diff)
downloadgdb-98367ef3a4f443c255d6635f1f3563c03d01636c.tar.gz
* 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.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/simple.c38
2 files changed, 32 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3887f37f937..2ebddbfd1cc 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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.
diff --git a/bfd/simple.c b/bfd/simple.c
index 256fd913b85..c2a741c6f90 100644
--- a/bfd/simple.c
+++ b/bfd/simple.c
@@ -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);
}