From: Stephane Carrez Date: Sun, 1 Dec 2002 12:18:29 +0000 (+0000) Subject: * bfd-in2.h (bfd_mach_m6812): Rebuild. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bc7c6a9029e2590f0715a88193da72c5e5451e1d;p=binutils-gdb.git * bfd-in2.h (bfd_mach_m6812): Rebuild. * archures.c (bfd_mach_m6812_default, bfd_mach_m6812, bfd_mach_m6812s): Declare. * elf32-m68hc12.c (m68hc12_elf_set_mach_from_flags): New function. (_bfd_m68hc12_elf_set_private_flags): Call it. (_bfd_m68hc12_elf_print_private_bfd_data): Report processor version. (_bfd_m68hc12_elf_merge_private_bfd_data): Merge the flags and report microcontroller incompatibilities (HC12 vs HCS12). (elf_backend_object_p): Update. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d4b1167370b..ae96c5a3c4b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,16 @@ +2002-12-01 Stephane Carrez + + * bfd-in2.h (bfd_mach_m6812): Rebuild. + * archures.c (bfd_mach_m6812_default, bfd_mach_m6812, + bfd_mach_m6812s): Declare. + + * elf32-m68hc12.c (m68hc12_elf_set_mach_from_flags): New function. + (_bfd_m68hc12_elf_set_private_flags): Call it. + (_bfd_m68hc12_elf_print_private_bfd_data): Report processor version. + (_bfd_m68hc12_elf_merge_private_bfd_data): Merge the flags and + report microcontroller incompatibilities (HC12 vs HCS12). + (elf_backend_object_p): Update. + 2002-11-30 Alan Modra * bfd-in.h (TRUE_FALSE_ALREADY_DEFINED, BFD_TRUE_FALSE): Delete. diff --git a/bfd/archures.c b/bfd/archures.c index 583098a8ef4..d969a9b82b8 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -201,6 +201,9 @@ DESCRIPTION . bfd_arch_dlx, {* DLX *} . bfd_arch_m68hc11, {* Motorola 68HC11 *} . bfd_arch_m68hc12, {* Motorola 68HC12 *} +.#define bfd_mach_m6812_default 0 +.#define bfd_mach_m6812 1 +.#define bfd_mach_m6812s 2 . bfd_arch_z8k, {* Zilog Z8000 *} .#define bfd_mach_z8001 1 .#define bfd_mach_z8002 2 diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index cde91f178cb..11b6d3ce9d9 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1628,6 +1628,9 @@ enum bfd_architecture bfd_arch_dlx, /* DLX */ bfd_arch_m68hc11, /* Motorola 68HC11 */ bfd_arch_m68hc12, /* Motorola 68HC12 */ +#define bfd_mach_m6812_default 0 +#define bfd_mach_m6812 1 +#define bfd_mach_m6812s 2 bfd_arch_z8k, /* Zilog Z8000 */ #define bfd_mach_z8001 1 #define bfd_mach_z8002 2 diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c index 3dba14ca9de..97d7d3a728a 100644 --- a/bfd/elf32-m68hc12.c +++ b/bfd/elf32-m68hc12.c @@ -633,6 +633,30 @@ elf32_m68hc11_gc_sweep_hook (abfd, info, sec, relocs) } +static bfd_boolean +m68hc12_elf_set_mach_from_flags (abfd) + bfd *abfd; +{ + flagword flags = elf_elfheader (abfd)->e_flags; + + switch (flags & EF_M68HC11_MACH_MASK) + { + case EF_M68HC12_MACH: + bfd_default_set_arch_mach (abfd, bfd_arch_m68hc12, bfd_mach_m6812); + break; + case EF_M68HCS12_MACH: + bfd_default_set_arch_mach (abfd, bfd_arch_m68hc12, bfd_mach_m6812s); + break; + case EF_M68HC11_GENERIC: + bfd_default_set_arch_mach (abfd, bfd_arch_m68hc12, + bfd_mach_m6812_default); + break; + default: + return FALSE; + } + return TRUE; +} + /* Set and control ELF flags in ELF header. */ bfd_boolean @@ -645,7 +669,7 @@ _bfd_m68hc12_elf_set_private_flags (abfd, flags) elf_elfheader (abfd)->e_flags = flags; elf_flags_init (abfd) = TRUE; - return TRUE; + return m68hc12_elf_set_mach_from_flags (abfd); } /* Merge backend specific data from an object file to the output @@ -669,7 +693,6 @@ _bfd_m68hc12_elf_merge_private_bfd_data (ibfd, obfd) return TRUE; new_flags = elf_elfheader (ibfd)->e_flags; - elf_elfheader (obfd)->e_flags |= new_flags & EF_M68HC11_ABI; old_flags = elf_elfheader (obfd)->e_flags; if (! elf_flags_init (obfd)) @@ -707,10 +730,24 @@ _bfd_m68hc12_elf_merge_private_bfd_data (ibfd, obfd) bfd_archive_filename (ibfd)); ok = FALSE; } - new_flags &= ~EF_M68HC11_ABI; - old_flags &= ~EF_M68HC11_ABI; + + /* Processor compatibility. */ + if (!EF_M68HC11_CAN_MERGE_MACH (new_flags, old_flags)) + { + (*_bfd_error_handler) + (_("%s: linking files compiled for HCS12 with " + "others compiled for HC12"), + bfd_archive_filename (ibfd)); + ok = FALSE; + } + new_flags = ((new_flags & ~EF_M68HC11_MACH_MASK) + | (EF_M68HC11_MERGE_MACH (new_flags, old_flags))); + + elf_elfheader (obfd)->e_flags = new_flags; /* Warn about any other mismatches */ + new_flags &= ~(EF_M68HC11_ABI | EF_M68HC11_MACH_MASK); + old_flags &= ~(EF_M68HC11_ABI | EF_M68HC11_MACH_MASK); if (new_flags != old_flags) { (*_bfd_error_handler) @@ -750,17 +787,19 @@ _bfd_m68hc12_elf_print_private_bfd_data (abfd, ptr) fprintf (file, _("[abi=16-bit int,")); if (elf_elfheader (abfd)->e_flags & E_M68HC11_F64) - fprintf (file, _(" 64-bit double]")); + fprintf (file, _(" 64-bit double,")); else - fprintf (file, _(" 32-bit double]")); + fprintf (file, _(" 32-bit double,")); + if (elf_elfheader (abfd)->e_flags & EF_M68HCS12_MACH) + fprintf (file, _(" cpu=HCS12]")); + else + fprintf (file, _(" cpu=HC12]")); fputc ('\n', file); return TRUE; } -/* Below is the only difference between elf32-m68hc12.c and elf32-m68hc11.c. - The Motorola spec says to use a different Elf machine code. */ #define ELF_ARCH bfd_arch_m68hc12 #define ELF_MACHINE_CODE EM_68HC12 #define ELF_MAXPAGESIZE 0x1000 @@ -772,7 +811,7 @@ _bfd_m68hc12_elf_print_private_bfd_data (abfd, ptr) #define elf_info_to_howto_rel m68hc11_info_to_howto_rel #define elf_backend_gc_mark_hook elf32_m68hc11_gc_mark_hook #define elf_backend_gc_sweep_hook elf32_m68hc11_gc_sweep_hook -#define elf_backend_object_p 0 +#define elf_backend_object_p m68hc12_elf_set_mach_from_flags #define elf_backend_final_write_processing 0 /* Disabled as this backend uses the generic linker. */ #define elf_backend_can_gc_sections 0