summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2007-11-12 21:55:50 +0000
committerH.J. Lu <hjl@lucon.org>2007-11-12 21:55:50 +0000
commited7d44b50c29a6c127ba5336d855a894e0fe6639 (patch)
tree15a23c9c20c6859ccda49e49e63aa83338a5b00a
parent01afcb094356c2fb89d181931bb29c5c59cfb2d8 (diff)
downloadbinutils-redhat-ed7d44b50c29a6c127ba5336d855a894e0fe6639.tar.gz
2007-11-12 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/5299 * peicode.h (pe_bfd_object_p): Save and restore previous bfd state when calling coff_object_p.
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/peicode.h19
2 files changed, 23 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2635fbdb3c..a73d1d5571 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,7 +1,13 @@
+2007-11-12 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/5299
+ * peicode.h (pe_bfd_object_p): Save and restore previous bfd
+ state when calling coff_object_p.
+
2007-11-12 Alan Modra <amodra@bigpond.net.au>
* elf.c (_bfd_elf_get_synthetic_symtab): Only bump the symbol
- pointer when we have a valid symbol. Init udata.p to NULL.
+ pointer when we have a valid symbol. Init udata.p to NULL.
2007-11-09 Nathan Sidwell <nathan@codesourcery.com>
diff --git a/bfd/peicode.h b/bfd/peicode.h
index 9a512a7d6d..15cad54e21 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -1263,6 +1263,7 @@ pe_bfd_object_p (bfd * abfd)
struct external_PEI_IMAGE_hdr image_hdr;
file_ptr offset;
const bfd_target *target;
+ struct bfd_preserve preserve;
/* Detect if this a Microsoft Import Library Format element. */
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
@@ -1327,6 +1328,10 @@ pe_bfd_object_p (bfd * abfd)
return NULL;
}
+ preserve.marker = NULL;
+ if (! bfd_preserve_save (abfd, &preserve))
+ return NULL;
+
target = coff_object_p (abfd);
if (target)
{
@@ -1344,7 +1349,10 @@ pe_bfd_object_p (bfd * abfd)
/* Don't check PE vs. EFI if arch is unknown. */
if (arch == arch_type_unknown)
- return target;
+ {
+ bfd_preserve_finish (abfd, &preserve);
+ return target;
+ }
for (target_ptr = bfd_target_vector; *target_ptr != NULL;
target_ptr++)
@@ -1361,8 +1369,10 @@ pe_bfd_object_p (bfd * abfd)
if (efi)
{
+no_match:
/* TARGET_PTR is an EFI backend. Don't match
TARGET with a EFI file. */
+ bfd_preserve_restore (abfd, &preserve);
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
@@ -1377,12 +1387,15 @@ pe_bfd_object_p (bfd * abfd)
{
/* TARGET_PTR is a PE backend. Don't match
TARGET with a PE file. */
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
+ goto no_match;
}
}
}
+
+ bfd_preserve_finish (abfd, &preserve);
}
+ else
+ bfd_preserve_restore (abfd, &preserve);
return target;
}