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]

[PATCH] add bfd elf_m68k_final_write_processing


Hi all,

currently,
	objcopy -I binary -B m68k:cfv4e -O elf32-m68k
does set architecture (m68k), but not machine (cfv4e)

here is a small patch fixing settings of elf header e_flags for m68k
architecture by objcopy when input is not an elf file :

make check does not show any regression with target m68k-elf

Philippe

Index: bfd/ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.4782
diff -u -p -r1.4782 ChangeLog
--- bfd/ChangeLog	14 Sep 2009 12:24:27 -0000	1.4782
+++ bfd/ChangeLog	14 Sep 2009 21:55:40 -0000
@@ -1,3 +1,8 @@
+2009-09-14  Philippe De Muyter  <phdm@macqel.be>
+
+	* elf32-m68k.c (+elf_m68k_final_write_processing): New function.
+	(elf_backend_final_write_processing): Macro defined as above function.
+
 2009-09-14  Nick Clifton  <nickc@redhat.com>
 
 	* po/fi.po: Updated Finnish translation.
Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.116
diff -u -p -r1.116 elf32-m68k.c
--- bfd/elf32-m68k.c	7 Sep 2009 16:29:34 -0000	1.116
+++ bfd/elf32-m68k.c	14 Sep 2009 21:55:48 -0000
@@ -1080,6 +1080,67 @@ elf32_m68k_object_p (bfd *abfd)
   return TRUE;
 }
 
+/*
+** somewhat reverse of elf32_m68k_object_p, and similar to
+** gas/config/tc-m68k.c:m68k_elf_final_processing (void)
+*/
+
+static void
+elf_m68k_final_write_processing (bfd *abfd,
+				 bfd_boolean linker ATTRIBUTE_UNUSED)
+{
+  int mach = bfd_get_mach (abfd);
+  unsigned long e_flags = elf_elfheader (abfd)->e_flags;
+
+  if (!e_flags)
+    {
+      unsigned int arch_mask;
+
+      arch_mask = bfd_m68k_mach_to_features (mach);
+      if (arch_mask & m68000)
+	e_flags = EF_M68K_M68000;
+      else if (arch_mask & cpu32)
+	e_flags = EF_M68K_CPU32;
+      else if (arch_mask & fido_a)
+	e_flags = EF_M68K_FIDO;
+      else
+	{
+	  switch (arch_mask
+		  & (mcfisa_a|mcfisa_aa|mcfisa_b|mcfisa_c|mcfhwdiv|mcfusp))
+	    {
+	    case mcfisa_a:
+	      e_flags |= EF_M68K_CF_ISA_A_NODIV;
+	      break;
+	    case mcfisa_a|mcfhwdiv:
+	      e_flags |= EF_M68K_CF_ISA_A;
+	      break;
+	    case mcfisa_a|mcfisa_aa|mcfhwdiv|mcfusp:
+	      e_flags |= EF_M68K_CF_ISA_A_PLUS;
+	      break;
+	    case mcfisa_a|mcfisa_b|mcfhwdiv:
+	      e_flags |= EF_M68K_CF_ISA_B_NOUSP;
+	      break;
+	    case mcfisa_a|mcfisa_b|mcfhwdiv|mcfusp:
+	      e_flags |= EF_M68K_CF_ISA_B;
+	      break;
+	    case mcfisa_a|mcfisa_c|mcfhwdiv|mcfusp:
+	      e_flags |= EF_M68K_CF_ISA_C;
+	      break;
+	    case mcfisa_a|mcfisa_c|mcfusp:
+	      e_flags |= EF_M68K_CF_ISA_C_NODIV;
+	      break;
+	    }
+	  if (arch_mask & mcfmac)
+	    e_flags |= EF_M68K_CF_MAC;
+	  else if (arch_mask & mcfemac)
+	    e_flags |= EF_M68K_CF_EMAC;
+	  if (arch_mask & cfloat)
+	    e_flags |= EF_M68K_CF_FLOAT | EF_M68K_CFV4E;
+	}
+      elf_elfheader (abfd)->e_flags = e_flags;
+    }
+}
+
 /* Keep m68k-specific flags in the ELF header.  */
 static bfd_boolean
 elf32_m68k_set_private_flags (abfd, flags)
@@ -4770,6 +4831,7 @@ elf_m68k_plt_sym_val (bfd_vma i, const a
 					elf_m68k_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections \
 					elf_m68k_finish_dynamic_sections
+#define elf_backend_final_write_processing	elf_m68k_final_write_processing
 #define elf_backend_gc_mark_hook	elf_m68k_gc_mark_hook
 #define elf_backend_gc_sweep_hook	elf_m68k_gc_sweep_hook
 #define elf_backend_copy_indirect_symbol elf_m68k_copy_indirect_symbol


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