aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2004-04-16 03:29:13 +0000
committerAlan Modra <amodra@gmail.com>2004-04-16 03:29:13 +0000
commit57a1784ed8fb404cd444134a16921a40163692ec (patch)
treee3a8cec2ca2650107aa30f6d28757ff88cc9a5d9 /bfd
parentdc718098ad86059b07d50687186c77bbf843d116 (diff)
downloadgdb-57a1784ed8fb404cd444134a16921a40163692ec.zip
gdb-57a1784ed8fb404cd444134a16921a40163692ec.tar.gz
gdb-57a1784ed8fb404cd444134a16921a40163692ec.tar.bz2
* simple.c (bfd_simple_get_relocated_section_contents): Don't
change reloc_done. Set and restore _cooked_size. (RETURN): Delete.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/simple.c40
2 files changed, 19 insertions, 27 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f12dc09..f128442 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2004-04-16 Alan Modra <amodra@bigpond.net.au>
+
+ * simple.c (bfd_simple_get_relocated_section_contents): Don't
+ change reloc_done. Set and restore _cooked_size.
+ (RETURN): Delete.
+
2004-04-15 Mark Kettenis <kettenis@gnu.org>
* netbsd-core.c (netbsd_core_file_p): Set architecture for VAX
diff --git a/bfd/simple.c b/bfd/simple.c
index 4b597a4..fc2472e 100644
--- a/bfd/simple.c
+++ b/bfd/simple.c
@@ -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,28 +140,7 @@ 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;
+ bfd_size_type old_cooked_size;
if (! (sec->flags & SEC_RELOC))
{
@@ -175,7 +154,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
@@ -205,7 +184,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;
}
@@ -224,7 +203,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);
@@ -239,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,
@@ -262,10 +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);
_bfd_generic_link_hash_table_free (link_info.hash);
- RETURN (contents);
+ return contents;
}