* elf.c (prep_headers): Get the machine code from the elf
authorAlexandre Oliva <aoliva@redhat.com>
Wed, 12 Sep 2001 23:53:31 +0000 (23:53 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Wed, 12 Sep 2001 23:53:31 +0000 (23:53 +0000)
backend data.
* elf-m10200.c (ELF_MACHINE_CODE): Redefine to EM_MN10200.
(ELF_MACHINE_ALT1): Define to EM_CYGNUS_MN10200.
* elf-m10300.c (ELF_MACHINE_CODE): Redefine to EM_MN10300.
(ELF_MACHINE_ALT1): Define to EM_CYGNUS_MN10300.
* elf-arc.c (arc_elf_final_write_processing): Don't override
e_machine, it's now properly set in prep_headers.
* elf32-avr.c (elf32_avr_object_p): Accept both EM_AVR and
EM_AVR_OLD.
(ELF_MACHINE_ALT1): Define to EM_AVR_OLD.
* elf-d10v.c (ELF_MACHINE_CODE): Redefine to EM_D10V.
(ELF_MACHINE_ALT1): Define to EM_CYGNUS_D10V.
* elf-d30v.c (ELF_MACHINE_CODE): Redefine to EM_D30V.
(ELF_MACHINE_ALT1): Define to EM_CYGNUS_D30V.
* elf-fr30.c (ELF_MACHINE_CODE): Redefine to EM_FR30.
(ELF_MACHINE_ALT1): Define to EM_CYGNUS_FR30.
* elf-m32r.c (ELF_MACHINE_CODE): Redefine to EM_M32R.
(ELF_MACHINE_ALT1): Define to EM_CYGNUS_M32R.
* elf32-pj.c (ELF_MACHINE_ALT1): DEfine to EM_PJ_OLD.
* elf-v850.c (ELF_MACHINE_CODE): Redefine to EM_V850.
(ELF_MACHINE_ALT1): Define to EM_CYGNUS_V850.

bfd/ChangeLog
bfd/elf-m10200.c
bfd/elf.c
bfd/elf32-arc.c
bfd/elf32-avr.c
bfd/elf32-d10v.c
bfd/elf32-d30v.c
bfd/elf32-fr30.c
bfd/elf32-m32r.c
bfd/elf32-pj.c
bfd/elf32-v850.c

index e696e8d8b3dee65561438ceebbc6c22632575070..3c1230c1b62b4f3a64a063bf167653e030e3d394 100644 (file)
@@ -1,3 +1,28 @@
+2001-09-12  Alexandre Oliva  <aoliva@redhat.com>
+
+       * elf.c (prep_headers): Get the machine code from the elf
+       backend data.
+       * elf-m10200.c (ELF_MACHINE_CODE): Redefine to EM_MN10200.
+       (ELF_MACHINE_ALT1): Define to EM_CYGNUS_MN10200.
+       * elf-m10300.c (ELF_MACHINE_CODE): Redefine to EM_MN10300.
+       (ELF_MACHINE_ALT1): Define to EM_CYGNUS_MN10300.
+       * elf-arc.c (arc_elf_final_write_processing): Don't override
+       e_machine, it's now properly set in prep_headers.
+       * elf32-avr.c (elf32_avr_object_p): Accept both EM_AVR and
+       EM_AVR_OLD.
+       (ELF_MACHINE_ALT1): Define to EM_AVR_OLD.
+       * elf-d10v.c (ELF_MACHINE_CODE): Redefine to EM_D10V.
+       (ELF_MACHINE_ALT1): Define to EM_CYGNUS_D10V.
+       * elf-d30v.c (ELF_MACHINE_CODE): Redefine to EM_D30V.
+       (ELF_MACHINE_ALT1): Define to EM_CYGNUS_D30V.
+       * elf-fr30.c (ELF_MACHINE_CODE): Redefine to EM_FR30.
+       (ELF_MACHINE_ALT1): Define to EM_CYGNUS_FR30.
+       * elf-m32r.c (ELF_MACHINE_CODE): Redefine to EM_M32R.
+       (ELF_MACHINE_ALT1): Define to EM_CYGNUS_M32R.
+       * elf32-pj.c (ELF_MACHINE_ALT1): DEfine to EM_PJ_OLD.
+       * elf-v850.c (ELF_MACHINE_CODE): Redefine to EM_V850.
+       (ELF_MACHINE_ALT1): Define to EM_CYGNUS_V850.
+
 2001-09-11  Richard Henderson  <rth@redhat.com>
 
        * elf64-alpha.c (elf64_alpha_section_flags): New.
index 86d0c587359e88610baab0b7803cf4f5a0b34aa5..cde5641d255387f760135fec4838bf45fb9192cf 100644 (file)
@@ -1517,7 +1517,8 @@ mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
 #define TARGET_LITTLE_SYM      bfd_elf32_mn10200_vec
 #define TARGET_LITTLE_NAME     "elf32-mn10200"
 #define ELF_ARCH               bfd_arch_mn10200
-#define ELF_MACHINE_CODE       EM_CYGNUS_MN10200
+#define ELF_MACHINE_CODE       EM_MN10200
+#define ELF_MACHINE_ALT1       EM_CYGNUS_MN10200
 #define ELF_MAXPAGESIZE                0x1000
 
 #define elf_info_to_howto      mn10200_info_to_howto
index f40b5a013c03c0acf472cc10813a3f883d211054..2fb73c5adeaa76f9ba81f8326648e52e5bf7cbae 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3347,119 +3347,22 @@ prep_headers (abfd)
     case bfd_arch_unknown:
       i_ehdrp->e_machine = EM_NONE;
       break;
-    case bfd_arch_sparc:
-      if (bfd_get_arch_size (abfd) == 64)
-       i_ehdrp->e_machine = EM_SPARCV9;
-      else
-       i_ehdrp->e_machine = EM_SPARC;
-      break;
-    case bfd_arch_i370:
-      i_ehdrp->e_machine = EM_S370;
-      break;
-    case bfd_arch_i386:
-      if (bfd_get_arch_size (abfd) == 64)
-       i_ehdrp->e_machine = EM_X86_64;
-      else
-       i_ehdrp->e_machine = EM_386;
-      break;
-    case bfd_arch_ia64:
-      i_ehdrp->e_machine = EM_IA_64;
-      break;
-    case bfd_arch_m68hc11:
-      i_ehdrp->e_machine = EM_68HC11;
-      break;
-    case bfd_arch_m68hc12:
-      i_ehdrp->e_machine = EM_68HC12;
-      break;
-    case bfd_arch_s390:
-      i_ehdrp->e_machine = EM_S390;
-      break;
-    case bfd_arch_m68k:
-      i_ehdrp->e_machine = EM_68K;
-      break;
-    case bfd_arch_m88k:
-      i_ehdrp->e_machine = EM_88K;
-      break;
-    case bfd_arch_i860:
-      i_ehdrp->e_machine = EM_860;
-      break;
-    case bfd_arch_i960:
-      i_ehdrp->e_machine = EM_960;
-      break;
-    case bfd_arch_mips:        /* MIPS Rxxxx */
-      i_ehdrp->e_machine = EM_MIPS;    /* only MIPS R3000 */
-      break;
-    case bfd_arch_hppa:
-      i_ehdrp->e_machine = EM_PARISC;
-      break;
-    case bfd_arch_powerpc:
-      if (bed->s->arch_size == 64)
-       i_ehdrp->e_machine = EM_PPC64;
-      else
-       i_ehdrp->e_machine = EM_PPC;
-      break;
-    case bfd_arch_alpha:
-      i_ehdrp->e_machine = EM_ALPHA;
-      break;
-    case bfd_arch_sh:
-      i_ehdrp->e_machine = EM_SH;
-      break;
-    case bfd_arch_d10v:
-      i_ehdrp->e_machine = EM_CYGNUS_D10V;
-      break;
-    case bfd_arch_d30v:
-      i_ehdrp->e_machine = EM_CYGNUS_D30V;
-      break;
-    case bfd_arch_fr30:
-      i_ehdrp->e_machine = EM_CYGNUS_FR30;
-      break;
-    case bfd_arch_mcore:
-      i_ehdrp->e_machine = EM_MCORE;
-      break;
-    case bfd_arch_avr:
-      i_ehdrp->e_machine = EM_AVR;
-      break;
-    case bfd_arch_v850:
-      switch (bfd_get_mach (abfd))
-       {
-       default:
-       case 0:               i_ehdrp->e_machine = EM_CYGNUS_V850; break;
-       }
-      break;
-    case bfd_arch_arc:
-      i_ehdrp->e_machine = EM_CYGNUS_ARC;
-      break;
-    case bfd_arch_arm:
-      i_ehdrp->e_machine = EM_ARM;
-      break;
-    case bfd_arch_m32r:
-      i_ehdrp->e_machine = EM_CYGNUS_M32R;
-      break;
-    case bfd_arch_mn10200:
-      i_ehdrp->e_machine = EM_CYGNUS_MN10200;
-      break;
-    case bfd_arch_mn10300:
-      i_ehdrp->e_machine = EM_CYGNUS_MN10300;
-      break;
-    case bfd_arch_pj:
-      i_ehdrp->e_machine = EM_PJ;
-      break;
-    case bfd_arch_cris:
-      i_ehdrp->e_machine = EM_CRIS;
-      break;
-    case bfd_arch_openrisc:
-      i_ehdrp->e_machine = EM_OPENRISC;
-      break;
-      /* Also note that EM_M32, AT&T WE32100 is unknown to bfd.  */
-    case bfd_arch_h8300:
-      i_ehdrp->e_machine = EM_H8_300;
-      break;
-    case bfd_arch_h8500:
-      i_ehdrp->e_machine = EM_H8_500;
-      break;
+
+      /* There used to be a long list of cases here, each one setting
+        e_machine to the same EM_* macro #defined as ELF_MACHINE_CODE
+        in the corresponding bfd definition.  To avoid duplication,
+        the switch was removed.  Machines that need special handling
+        can generally do it in elf_backend_final_write_processing(),
+        unless they need the information earlier than the final write.
+        Such need can generally be supplied by replacing the tests for
+        e_machine with the conditions used to determine it.  */
     default:
-      i_ehdrp->e_machine = EM_NONE;
-    }
+      if (get_elf_backend_data (abfd) != NULL)
+       i_ehdrp->e_machine = get_elf_backend_data (abfd)->elf_machine_code;
+      else
+       i_ehdrp->e_machine = EM_NONE;
+      }
+
   i_ehdrp->e_version = bed->s->ev_current;
   i_ehdrp->e_ehsize = bed->s->sizeof_ehdr;
 
index b491cee9d78562c8d8b5c239175690c0eccc0c86..87d7a97854e84bfd4875df3db6c9a4b8812889e3 100644 (file)
@@ -207,7 +207,6 @@ arc_elf_final_write_processing (abfd, linker)
       val = E_ARC_MACH_ARC8;
       break;
     }
-  elf_elfheader (abfd)->e_machine = EM_ARC;
   elf_elfheader (abfd)->e_flags &=~ EF_ARC_MACH;
   elf_elfheader (abfd)->e_flags |= val;
 }
index d776e2c97ce7bbdce02408a90e34eab089bff7d0..55ea2c6f870cb0363c4ba8029a1f5e488539a983 100644 (file)
@@ -914,7 +914,8 @@ elf32_avr_object_p (abfd)
      bfd *abfd;
 {
   int e_set = bfd_mach_avr2;
-  if (elf_elfheader (abfd)->e_machine == EM_AVR)
+  if (elf_elfheader (abfd)->e_machine == EM_AVR
+      || elf_elfheader (abfd)->e_machine == EM_AVR_OLD)
     {
       int e_mach = elf_elfheader (abfd)->e_flags & EF_AVR_MACH;
       switch (e_mach)
@@ -947,6 +948,7 @@ elf32_avr_object_p (abfd)
 
 #define ELF_ARCH               bfd_arch_avr
 #define ELF_MACHINE_CODE       EM_AVR
+#define ELF_MACHINE_ALT1       EM_AVR_OLD
 #define ELF_MAXPAGESIZE                1
 
 #define TARGET_LITTLE_SYM       bfd_elf32_avr_vec
index 50f7da64f80f8c4cb1815f8182280e524c1c8bd9..5b6ed270890c519cfd335a288a65bef2e67b706d 100644 (file)
@@ -515,7 +515,8 @@ elf32_d10v_relocate_section (output_bfd, info, input_bfd, input_section,
   return true;
 }
 #define ELF_ARCH               bfd_arch_d10v
-#define ELF_MACHINE_CODE       EM_CYGNUS_D10V
+#define ELF_MACHINE_CODE       EM_D10V
+#define ELF_MACHINE_ALT1       EM_CYGNUS_D10V
 #define ELF_MAXPAGESIZE                0x1000
 
 #define TARGET_BIG_SYM          bfd_elf32_d10v_vec
index 249051378f3c9164e8eee266981aaf2889186887..4d26b92c585f653d565264881655f69976e38797 100644 (file)
@@ -546,7 +546,8 @@ d30v_info_to_howto_rela (abfd, cache_ptr, dst)
 }
 
 #define ELF_ARCH               bfd_arch_d30v
-#define ELF_MACHINE_CODE       EM_CYGNUS_D30V
+#define ELF_MACHINE_CODE       EM_D30V
+#define ELF_MACHINE_ALT1       EM_CYGNUS_D30V
 #define ELF_MAXPAGESIZE                0x1000
 
 #define TARGET_BIG_SYM          bfd_elf32_d30v_vec
index c7a3b2158be1eb8982c1d83fbd4a50164cb7f59a..345d51245a85e1256f190e36731417c5589bf504 100644 (file)
@@ -792,7 +792,8 @@ fr30_elf_check_relocs (abfd, info, sec, relocs)
 }
 \f
 #define ELF_ARCH               bfd_arch_fr30
-#define ELF_MACHINE_CODE       EM_CYGNUS_FR30
+#define ELF_MACHINE_CODE       EM_FR30
+#define ELF_MACHINE_ALT1       EM_CYGNUS_FR30
 #define ELF_MAXPAGESIZE                0x1000
 
 #define TARGET_BIG_SYM          bfd_elf32_fr30_vec
index c7e4f404dfb29bee465cff15080dffdc24a1b90b..fd3d227c7af7885c2728e012273c052c0b95de5e 100644 (file)
@@ -2168,7 +2168,8 @@ m32r_elf_check_relocs (abfd, info, sec, relocs)
 }
 \f
 #define ELF_ARCH               bfd_arch_m32r
-#define ELF_MACHINE_CODE       EM_CYGNUS_M32R
+#define ELF_MACHINE_CODE       EM_M32R
+#define ELF_MACHINE_ALT1       EM_CYGNUS_M32R
 #define ELF_MAXPAGESIZE                0x1 /* Explicitly requested by Mitsubishi.  */
 
 #define TARGET_BIG_SYM          bfd_elf32_m32r_vec
index 4d48c8d465e98c36c0cd21c097e39110b8bf68fc..5502616ee49e058e170f017567707a7ffe51d4e7 100644 (file)
@@ -341,6 +341,7 @@ pj_elf_final_write_processing (abfd, linker)
 #define TARGET_LITTLE_NAME     "elf32-pjl"
 #define ELF_ARCH               bfd_arch_pj
 #define ELF_MACHINE_CODE       EM_PJ
+#define ELF_MACHINE_ALT1       EM_PJ_OLD
 #define ELF_MAXPAGESIZE                0x1000
 #define bfd_elf32_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
 #define bfd_elf32_bfd_reloc_type_lookup                     pj_elf_reloc_type_lookup
index 518073644e61c0c1cd9b730b214e97d08e5fb7b9..7696c00f7d45f2ac105c88e90315e75651dd2e45 100644 (file)
@@ -2218,7 +2218,8 @@ v850_elf_fake_sections (abfd, hdr, sec)
 #define TARGET_LITTLE_SYM                      bfd_elf32_v850_vec
 #define TARGET_LITTLE_NAME                     "elf32-v850"
 #define ELF_ARCH                               bfd_arch_v850
-#define ELF_MACHINE_CODE                       EM_CYGNUS_V850
+#define ELF_MACHINE_CODE                       EM_V850
+#define ELF_MACHINE_ALT1                       EM_CYGNUS_V850
 #define ELF_MAXPAGESIZE                                0x1000
 
 #define elf_info_to_howto                      v850_elf_info_to_howto_rela