From: Alexandre Oliva Date: Wed, 12 Sep 2001 23:53:31 +0000 (+0000) Subject: * elf.c (prep_headers): Get the machine code from the elf X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aa4f99bbfde8d1650d61163622544d106c7eeab0;p=binutils-gdb.git * 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e696e8d8b3d..3c1230c1b62 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,28 @@ +2001-09-12 Alexandre Oliva + + * 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 * elf64-alpha.c (elf64_alpha_section_flags): New. diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c index 86d0c587359..cde5641d255 100644 --- a/bfd/elf-m10200.c +++ b/bfd/elf-m10200.c @@ -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 diff --git a/bfd/elf.c b/bfd/elf.c index f40b5a013c0..2fb73c5adea 100644 --- 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; diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index b491cee9d78..87d7a97854e 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -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; } diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c index d776e2c97ce..55ea2c6f870 100644 --- a/bfd/elf32-avr.c +++ b/bfd/elf32-avr.c @@ -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 diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c index 50f7da64f80..5b6ed270890 100644 --- a/bfd/elf32-d10v.c +++ b/bfd/elf32-d10v.c @@ -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 diff --git a/bfd/elf32-d30v.c b/bfd/elf32-d30v.c index 249051378f3..4d26b92c585 100644 --- a/bfd/elf32-d30v.c +++ b/bfd/elf32-d30v.c @@ -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 diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c index c7a3b2158be..345d51245a8 100644 --- a/bfd/elf32-fr30.c +++ b/bfd/elf32-fr30.c @@ -792,7 +792,8 @@ fr30_elf_check_relocs (abfd, info, sec, relocs) } #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 diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index c7e4f404dfb..fd3d227c7af 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -2168,7 +2168,8 @@ m32r_elf_check_relocs (abfd, info, sec, relocs) } #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 diff --git a/bfd/elf32-pj.c b/bfd/elf32-pj.c index 4d48c8d465e..5502616ee49 100644 --- a/bfd/elf32-pj.c +++ b/bfd/elf32-pj.c @@ -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 diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index 518073644e6..7696c00f7d4 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -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