This is the mail archive of the binutils@sources.redhat.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]
Other format: [Raw text]

Patch to fix merging of EF_MIPS_MACH flags


This code in _bfd_mips_elf_merge_private_bfd_data:

	      /* Do we need to update the mach field?  */
	      if (_bfd_mips_elf_mach_extends_p (old_mach, new_mach))
		{
		  elf_elfheader (obfd)->e_flags &= ~EF_MIPS_MACH;
		  elf_elfheader (obfd)->e_flags |= new_mach;
		  bfd_set_arch_info (obfd, bfd_get_arch_info (ibfd));
		}

didn't have the desired effect because the EF_MIPS_MACH bits are
overwritten by _bfd_mips_elf_final_write_processing.  Is the
patch below the right fix?  (Based on the h8300 port.)

Tested on mips64-elf, no regressions.

Richard

bfd/
	* elfxx-mips.c (_bfd_mips_elf_mach_extends_p): Be more strict.
	(_bfd_mips_elf_merge_private_bfd_data): When changing the
	EF_MIPS_MACH flag, change the bfd arch_info as well.

ld/testsuite
	* ld-mips-elf/vr4120-1.d: New test.
	* ld-mips-elf/mips-elf.exp: Run it.

Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.26
diff -c -d -p -r1.26 elfxx-mips.c
*** bfd/elfxx-mips.c	11 Oct 2002 08:33:11 -0000	1.26
--- bfd/elfxx-mips.c	11 Oct 2002 15:49:46 -0000
*************** _bfd_mips_elf_mach_extends_p (base, exte
*** 7663,7669 ****
       and vr5500 code to be merged anyway, since many libraries will
       just use the core ISA.  Perhaps we could add some sort of ASE
       flag if this ever proves a problem.  */
!   return (base == 0
  	  || (base == E_MIPS_MACH_5400 && extension == E_MIPS_MACH_5500)
  	  || (base == E_MIPS_MACH_4100 && extension == E_MIPS_MACH_4111)
  	  || (base == E_MIPS_MACH_4100 && extension == E_MIPS_MACH_4120));
--- 7663,7669 ----
       and vr5500 code to be merged anyway, since many libraries will
       just use the core ISA.  Perhaps we could add some sort of ASE
       flag if this ever proves a problem.  */
!   return ((base == 0 && extension != 0)
  	  || (base == E_MIPS_MACH_5400 && extension == E_MIPS_MACH_5500)
  	  || (base == E_MIPS_MACH_4100 && extension == E_MIPS_MACH_4111)
  	  || (base == E_MIPS_MACH_4100 && extension == E_MIPS_MACH_4120));
*************** _bfd_mips_elf_merge_private_bfd_data (ib
*** 7798,7803 ****
--- 7798,7804 ----
  		{
  		  elf_elfheader (obfd)->e_flags &= ~EF_MIPS_MACH;
  		  elf_elfheader (obfd)->e_flags |= new_mach;
+ 		  bfd_set_arch_info (obfd, bfd_get_arch_info (ibfd));
  		}
  
  	      /* Do we need to update the ISA field?  */
Index: ld/testsuite/ld-mips-elf/mips-elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/mips-elf.exp,v
retrieving revision 1.6
diff -c -d -p -r1.6 mips-elf.exp
*** ld/testsuite/ld-mips-elf/mips-elf.exp	3 Oct 2002 23:56:24 -0000	1.6
--- ld/testsuite/ld-mips-elf/mips-elf.exp	11 Oct 2002 15:49:46 -0000
*************** if { [istarget mips*-*-*] } then {
*** 30,35 ****
--- 30,37 ----
  	# MIPS branch offset final link checking.
  	run_dump_test "branch-misc-1"
  	run_dump_test "branch-misc-2"
+ 
+ 	run_dump_test "vr4120-1"
      }
  
      if { $embedded_elf } {
*** /dev/null	Tue Nov 14 21:44:43 2000
--- ld/testsuite/ld-mips-elf/vr4120-1.d	Fri Oct 11 16:17:25 2002
***************
*** 0 ****
--- 1,7 ----
+ #source: mips16-1a.s -march=vr4100
+ #source: mips16-1b.s -march=vr4120
+ #ld: -r
+ #readelf: --header
+ #...
+   Flags:.* 4120.*
+ #pass


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