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] Recognize elf64-i386 at least as elf64-little.


On Thu, Jul 31, 2008 at 01:23:09PM +0200, Jan Kratochvil wrote:
> 	Recognize elf64-i386 at least as elf64-little.
> 	* elfcore.h (elf_core_file_p): Exclusion of existing arches for the
> 	generic arch fallback now matches also the arch size.

We probably should have this in elfcode.h too.  Also, I see that
elf_object_p might allow an ELF file without any section headers to
match a backend with the wrong arch size, so I added another test.
elf_core_file_p doesn't need the extra check since the arch size must
be correct for the program header size to match.

	* elfcore.h (elf_core_file_p): Ensure we have a backend match
	with the correct arch size before rejecting the generic fallback.
	* elfcode.h (elf_object_p): Likewise.  Ensure arch size matches
	before accepting a target.

Index: bfd/elfcode.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcode.h,v
retrieving revision 1.90
diff -u -p -r1.90 elfcode.h
--- bfd/elfcode.h	12 Mar 2008 08:36:58 -0000	1.90
+++ bfd/elfcode.h	1 Aug 2008 11:46:54 -0000
@@ -574,6 +574,8 @@ elf_object_p (bfd *abfd)
     goto got_wrong_format_error;
 
   ebd = get_elf_backend_data (abfd);
+  if (ebd->s->arch_size != ARCH_SIZE)
+    goto got_wrong_format_error;
 
   /* Check that the ELF e_machine field matches what this particular
      BFD format expects.  */
@@ -595,6 +597,8 @@ elf_object_p (bfd *abfd)
 	  if ((*target_ptr)->flavour != bfd_target_elf_flavour)
 	    continue;
 	  back = xvec_get_elf_backend_data (*target_ptr);
+	  if (back->s->arch_size != ARCH_SIZE)
+	    continue;
 	  if (back->elf_machine_code == i_ehdrp->e_machine
 	      || (back->elf_machine_alt1 != 0
 		  && back->elf_machine_alt1 == i_ehdrp->e_machine)
Index: bfd/elfcore.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcore.h,v
retrieving revision 1.27
diff -u -p -r1.27 elfcore.h
--- bfd/elfcore.h	10 May 2008 01:58:17 -0000	1.27
+++ bfd/elfcore.h	1 Aug 2008 11:46:54 -0000
@@ -159,6 +159,8 @@ elf_core_file_p (bfd *abfd)
 	  if ((*target_ptr)->flavour != bfd_target_elf_flavour)
 	    continue;
 	  back = xvec_get_elf_backend_data (*target_ptr);
+	  if (back->s->arch_size != ARCH_SIZE)
+	    continue;
 	  if (back->elf_machine_code == i_ehdrp->e_machine
 	      || (back->elf_machine_alt1 != 0
 	          && i_ehdrp->e_machine == back->elf_machine_alt1)

-- 
Alan Modra
Australia Development Lab, IBM


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