From 3fae9fabccdff2700842ac026027512ca4f8edbf Mon Sep 17 00:00:00 2001 From: ciceron Date: Tue, 13 May 2003 18:54:24 +0000 Subject: [PATCH] * elf32-m68hc1x.c (_bfd_m68hc11_elf_merge_private_bfd_data): Check for processor capability, allow merge of HC12 and HCS12 in some cases. (m68hc11_elf_hash_table_create): Use bfd_malloc instead of bfd_zalloc. * cpu-m68hc12.c (bfd_m68hc12s_arch): New struct. (bfd_m68hc12_arch): Link it. (scan_mach): New function. --- bfd/ChangeLog | 9 +++++++++ bfd/cpu-m68hc12.c | 22 +++++++++++++++++++--- bfd/elf32-m68hc1x.c | 22 +++++++++++++++++++--- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 0046a36694..550dcc0282 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2003-05-13 Stephane Carrez + + * elf32-m68hc1x.c (_bfd_m68hc11_elf_merge_private_bfd_data): Check for + processor capability, allow merge of HC12 and HCS12 in some cases. + (m68hc11_elf_hash_table_create): Use bfd_malloc instead of bfd_zalloc. + * cpu-m68hc12.c (bfd_m68hc12s_arch): New struct. + (bfd_m68hc12_arch): Link it. + (scan_mach): New function. + 2003-05-13 Andrew Haley * elf.c (bfd_elf_hash): Mask lower 32 bits of hash. diff --git a/bfd/cpu-m68hc12.c b/bfd/cpu-m68hc12.c index d43eb95fc1..f4c8c9e758 100644 --- a/bfd/cpu-m68hc12.c +++ b/bfd/cpu-m68hc12.c @@ -1,5 +1,5 @@ /* BFD support for the Motorola 68HC12 processor - Copyright 1999, 2000, 2002 Free Software Foundation, Inc. + Copyright 1999, 2000, 2002, 2003 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -21,10 +21,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "sysdep.h" #include "libbfd.h" +const bfd_arch_info_type bfd_m68hc12s_arch = +{ + 16, /* 16 bits in a word */ + 32, /* 16 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_m68hc12, + bfd_mach_m6812s, + "m68hc12:HCS12", + "m68hc12", + 4, /* section alignment power */ + TRUE, + bfd_default_compatible, + bfd_default_scan, + 0, +}; + const bfd_arch_info_type bfd_m68hc12_arch = { 16, /* 16 bits in a word */ - 16, /* 16 bits in an address */ + 32, /* 16 bits in an address */ 8, /* 8 bits in a byte */ bfd_arch_m68hc12, 0, @@ -34,5 +50,5 @@ const bfd_arch_info_type bfd_m68hc12_arch = TRUE, bfd_default_compatible, bfd_default_scan, - 0, + &bfd_m68hc12s_arch, }; diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c index 3c2ff6118f..176a256c74 100644 --- a/bfd/elf32-m68hc1x.c +++ b/bfd/elf32-m68hc1x.c @@ -75,14 +75,15 @@ m68hc11_elf_hash_table_create (abfd) struct m68hc11_elf_link_hash_table *ret; bfd_size_type amt = sizeof (struct m68hc11_elf_link_hash_table); - ret = (struct m68hc11_elf_link_hash_table *) bfd_zalloc (abfd, amt); + ret = (struct m68hc11_elf_link_hash_table *) bfd_malloc (amt); if (ret == (struct m68hc11_elf_link_hash_table *) NULL) return NULL; + memset (ret, 0, amt); if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, _bfd_elf_link_hash_newfunc)) { - bfd_release (abfd, ret); + free (ret); return NULL; } @@ -91,7 +92,7 @@ m68hc11_elf_hash_table_create (abfd) ret->stub_hash_table = (struct bfd_hash_table*) bfd_malloc (amt); if (ret->stub_hash_table == NULL) { - bfd_release (abfd, ret); + free (ret); return NULL; } if (!bfd_hash_table_init (ret->stub_hash_table, stub_hash_newfunc)) @@ -1405,6 +1406,21 @@ _bfd_m68hc11_elf_merge_private_bfd_data (ibfd, obfd) bfd_archive_filename (ibfd)); ok = FALSE; } + + /* 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; + new_flags &= ~EF_M68HC11_ABI; old_flags &= ~EF_M68HC11_ABI; -- 2.11.0