This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Don't match PE/EFI target with EFI/PE file


On Thu, Jul 05, 2007 at 07:46:39AM +0930, Alan Modra wrote:
> On Mon, Jun 18, 2007 at 05:10:14PM +0100, Nick Clifton wrote:
> > >2007-06-09  H.J. Lu  <hongjiu.lu@intel.com>
> > >
> > >	* libpei.h (_bfd_XXi_final_link_postscript): Remove
> > >	duplication.
> > >	(bfd_target_pei_p): New.
> > >	(bfd_target_pei_arch): New
> > >	(bfd_target_efi_p): Likewise.
> > >	(bfd_target_efi_arch): New
> > >	(bfd_pe_executable_p): Use bfd_target_pei_p and
> > >	bfd_target_efi_p.
> > >
> > >	* peicode.h (arch_type): New enum.
> > >	(pe_arch): New function.
> > >	(pe_bfd_object_p): Don't match PE/EFI target with EFI/PE file
> > >	if there is an EFI/PE target.
> > 
> > Approved - please apply.
> 
> I believe this patch is responsible for multiple testsuite failures on
> non-x86 pe targets.  eg. arm-wince-pe and mcore-pe.  HJ would you
> please look into it?
> 

I am checking this in as an obvious fix.

Thanks.

H.J.
----
2007-07-04  H.J. Lu  <hongjiu.lu@intel.com>

	* peicode.h (pe_bfd_object_p): Don't check PE vs. EFI target
	if arch is unknown.

--- bfd/peicode.h.pe	2007-07-03 19:35:09.000000000 -0700
+++ bfd/peicode.h	2007-07-04 19:39:36.000000000 -0700
@@ -1342,6 +1342,10 @@ pe_bfd_object_p (bfd * abfd)
       else
 	arch = pe_arch (bfd_target_pei_arch (abfd->xvec));
 
+      /* Don't check PE vs. EFI if arch is unknown.  */
+      if (arch == arch_type_unknown)
+	return target;
+
       for (target_ptr = bfd_target_vector; *target_ptr != NULL;
 	   target_ptr++)
 	{
@@ -1355,13 +1359,13 @@ pe_bfd_object_p (bfd * abfd)
 	      if (pe_arch (bfd_target_efi_arch (*target_ptr)) != arch)
 		continue;
 
-		if (efi)
-		  {
-		    /* TARGET_PTR is an EFI backend.  Don't match
-		       TARGET with a EFI file.  */
-		    bfd_set_error (bfd_error_wrong_format);
-		    return NULL;
-		  }
+	      if (efi)
+		{
+		  /* TARGET_PTR is an EFI backend.  Don't match
+		     TARGET with a EFI file.  */
+		  bfd_set_error (bfd_error_wrong_format);
+		  return NULL;
+		}
 	    }
 	  else if (bfd_target_pei_p (*target_ptr))
 	    {
@@ -1369,13 +1373,13 @@ pe_bfd_object_p (bfd * abfd)
 	      if (pe_arch (bfd_target_pei_arch (*target_ptr)) != arch)
 		continue;
 
-		if (!efi)
-		  {
-		    /* TARGET_PTR is a PE backend.  Don't match
-		       TARGET with a PE file.  */
-		    bfd_set_error (bfd_error_wrong_format);
-		    return NULL;
-		  }
+	      if (!efi)
+		{
+		  /* TARGET_PTR is a PE backend.  Don't match
+		     TARGET with a PE file.  */
+		  bfd_set_error (bfd_error_wrong_format);
+		  return NULL;
+		}
 	    }
 	}
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]