[MT PATCH] forbid mixing architectures

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[MT PATCH] forbid mixing architectures

Nathan Sidwell
This patch prevents morphotech from mixing objectfiles compiled for different
architectures.  This has never been safe, due to the different scheduling
constraints and instructions in each variant.  We've had to tolerate it due to
the lack of multilibbing in the compiler.  Now multilibbing is implemented, we
can be stricter here and avoid confusing runtime problems.

ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
[hidden email]    ::     http://www.planetfall.pwp.blueyonder.co.uk


2005-12-20  Nathan Sidwell  <[hidden email]>

        * elf32-mt.c (mt_elf_merge_private_bfd_data): Do not allow mixing
        object files from different mt variants.

Index: bfd/elf32-mt.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mt.c,v
retrieving revision 1.3
diff -c -3 -p -r1.3 elf32-mt.c
*** bfd/elf32-mt.c 16 Dec 2005 10:23:06 -0000 1.3
--- bfd/elf32-mt.c 20 Dec 2005 09:39:29 -0000
*************** static bfd_boolean
*** 548,554 ****
  mt_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
  {
    flagword     old_flags, new_flags;
!   bfd_boolean  error = FALSE;
 
    /* Check if we have the same endianess.  */
    if (_bfd_generic_verify_endian_match (ibfd, obfd) == FALSE)
--- 548,554 ----
  mt_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
  {
    flagword     old_flags, new_flags;
!   bfd_boolean  ok = TRUE;
 
    /* Check if we have the same endianess.  */
    if (_bfd_generic_verify_endian_match (ibfd, obfd) == FALSE)
*************** mt_elf_merge_private_bfd_data (bfd * ibf
*** 578,600 ****
      {
        /* CPU has changed.  This is invalid, because MRISC, MRISC2 and
  MS2 are not subsets of each other.   */
!       error = 1;
!      
!       /* FIXME:However, until the compiler is multilibbed, preventing
! mixing breaks the build.  So we allow merging and use the
! greater CPU value.  This is of course unsafe.  */
!       error = 0;
!       if ((new_flags & EF_MT_CPU_MASK) > (old_flags & EF_MT_CPU_MASK))
! old_flags = ((old_flags & ~EF_MT_CPU_MASK)
!     | (new_flags & EF_MT_CPU_MASK));
      }
!   if (!error)
      {
        obfd->arch_info = ibfd->arch_info;
        elf_elfheader (obfd)->e_flags = old_flags;
      }
 
!   return !error;
  }
 
  static bfd_boolean
--- 578,593 ----
      {
        /* CPU has changed.  This is invalid, because MRISC, MRISC2 and
  MS2 are not subsets of each other.   */
!       ok = FALSE;
      }
!  
!   if (ok)
      {
        obfd->arch_info = ibfd->arch_info;
        elf_elfheader (obfd)->e_flags = old_flags;
      }
 
!   return ok;
  }
 
  static bfd_boolean
Reply | Threaded
Open this post in threaded view
|

Re: [MT PATCH] forbid mixing architectures

Nick Clifton
Hi Nathan,

 > 2005-12-20  Nathan Sidwell  <[hidden email]>
 >
 > * elf32-mt.c (mt_elf_merge_private_bfd_data): Do not allow
 > mixing object files from different mt variants.

Approved - please apply.

Cheers
   Nick