summaryrefslogtreecommitdiff
path: root/bfd/simple.c
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
commitb0cdc7bcb0239e52de59195f8b7e213c3f5ddc14 (patch)
tree2c1103a42b6062211a410ff114c44b00530eb12d /bfd/simple.c
parentbe6389fdef2f1df307fc760d344796c815103075 (diff)
* 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.
Diffstat (limited to 'bfd/simple.c')
-rw-r--r--bfd/simple.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/bfd/simple.c b/bfd/simple.c
index 256fd913b8..c2a741c6f9 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);
}