aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2000-12-29 05:44:51 +0000
committerHans-Peter Nilsson <hp@axis.com>2000-12-29 05:44:51 +0000
commita77a9fefcf7641773dbc585f636890feb7814b06 (patch)
tree092ae614aa28bad4615d252116513d57af71c637 /bfd
parente4897a3288f37d5f69e8acd256a6e83e607fe8d8 (diff)
downloadgdb-a77a9fefcf7641773dbc585f636890feb7814b06.zip
gdb-a77a9fefcf7641773dbc585f636890feb7814b06.tar.gz
gdb-a77a9fefcf7641773dbc585f636890feb7814b06.tar.bz2
* elfcode.h (elf_object_p): Also restore the bfd mach field on
error, by calling bfd_default_set_arch_mach with incoming values.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elfcode.h12
2 files changed, 18 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7fdbcd2..14063b9 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2000-12-29 Hans-Peter Nilsson <hp@bitrange.com>
+
+ * elfcode.h (elf_object_p): Also restore the bfd mach field on
+ error, by calling bfd_default_set_arch_mach with incoming
+ values.
+
2000-12-26 Kazu Hirata <kazu@hxi.com>
* vaxnetbsd.c: Fix formatting.
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index b94f74b..40bbaf5 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -502,6 +502,8 @@ elf_object_p (abfd)
struct elf_obj_tdata *preserved_tdata = elf_tdata (abfd);
struct sec *preserved_sections = abfd->sections;
unsigned int preserved_section_count = abfd->section_count;
+ enum bfd_architecture previous_arch = bfd_get_arch (abfd);
+ unsigned long previous_mach = bfd_get_mach (abfd);
struct elf_obj_tdata *new_tdata = NULL;
asection *s;
@@ -742,6 +744,16 @@ elf_object_p (abfd)
return (abfd->xvec);
got_wrong_format_error:
+ /* There is way too much undoing of half-known state here. The caller,
+ bfd_check_format_matches, really shouldn't iterate on live bfd's to
+ check match/no-match like it does. We have to rely on that a call to
+ bfd_default_set_arch_mach with the previously known mach, undoes what
+ was done by the first bfd_default_set_arch_mach (with mach 0) here.
+ For this to work, only elf-data and the mach may be changed by the
+ target-specific elf_backend_object_p function. Note that saving the
+ whole bfd here and restoring it would be even worse; the first thing
+ you notice is that the cached bfd file position gets out of sync. */
+ bfd_default_set_arch_mach (abfd, previous_arch, previous_mach);
bfd_set_error (bfd_error_wrong_format);
got_no_match:
if (new_tdata != NULL