This is the mail archive of the binutils@sourceware.cygnus.com 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]

Re: [patch] binary file endianness


Geoff Keating wrote:
> 
> Shouldn't it instead check to see whether the endianness is unknown?
> 
> You still don't want to be linking a little-endian COFF with a
> big-endian ELF, I think.

Indeed. Here's the revised patch.

How about removing the inline checks for endianness
and calling _bfd_generic_verify_endian_match() instead ?

Regards,
-velco
2000-05-21  Momchil Velikov  <velco@fadata.bg>

	* elf32-mcore.c (mcore_elf_merge_private_bfd_data): Check endianness
	only if it is known for both input and output bfds.  

	* libbfd.c (_bfd_generic_verify_endian_match): Likewise.  

	* elf32-mips.c (_bfd_mips_elf_merge_private_bfd_data): Likewise.  

	* elf32-ppc.c (_bfd_mips_elf_merge_private_bfd_data): Likewise.  

	* elf32-arm.h (elf32_arm_merge_private_bfd_data): Check for input and
	output bfd endiannes before checking bfd flavour.  
--- elf32-arm.h.orig	Sun May 21 12:16:54 2000
+++ elf32-arm.h	Sun May 21 12:17:24 2000
@@ -2007,10 +2007,6 @@
   flagword out_flags;
   flagword in_flags;
 
-  if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
-      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
-    return true;
-
   /* Check if we have the same endianess */
   if (   ibfd->xvec->byteorder != obfd->xvec->byteorder
       && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
@@ -2025,6 +2021,10 @@
       bfd_set_error (bfd_error_wrong_format);
       return false;
     }
+
+  if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+    return true;
 
   /* The input BFD must have had its flags initialised.  */
   /* The following seems bogus to me -- The flags are initialized in
--- elf32-mcore.c.orig	Sun May 21 12:18:01 2000
+++ elf32-mcore.c	Sun May 21 12:18:41 2000
@@ -323,6 +323,7 @@
 
   /* Check if we have the same endianess */
   if (   ibfd->xvec->byteorder != obfd->xvec->byteorder
+      && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
       && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
     {
       (*_bfd_error_handler)
--- elf32-mips.c.orig	Sun May 21 12:19:08 2000
+++ elf32-mips.c	Sun May 21 12:19:33 2000
@@ -2461,6 +2461,7 @@
 
   /* Check if we have the same endianess */
   if (ibfd->xvec->byteorder != obfd->xvec->byteorder
+      && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
       && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
     {
       const char *msg;
--- elf32-ppc.c.orig	Sun May 21 02:35:46 2000
+++ elf32-ppc.c	Sun May 21 12:14:00 2000
@@ -1400,6 +1400,7 @@
 
   /* Check if we have the same endianess */
   if (ibfd->xvec->byteorder != obfd->xvec->byteorder
+      && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
       && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
     {
       const char *msg;
--- libbfd.c.orig	Sun May 21 12:21:55 2000
+++ libbfd.c	Sun May 21 12:22:08 2000
@@ -1306,6 +1306,7 @@
      bfd *obfd;
 {
   if (ibfd->xvec->byteorder != obfd->xvec->byteorder
+      && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
       && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
     {
       (*_bfd_error_handler)

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