This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH]: Fixes in bfd for HC11/HC12
- From: Stephane Carrez <stcarrez at nerim dot fr>
- To: binutils at sources dot redhat dot com
- Date: Tue, 13 May 2003 20:57:34 +0200
- Subject: [PATCH]: Fixes in bfd for HC11/HC12
Hi!
I committed this patch on 2_14 branch and mainline to fix problems on m6811/m6812-elf:
- fix a crash of objdump -S (due to the use of bfd_zalloc() to allocate the hash table)
- fix a link problem for 68HCS12 which forbided to link object files produced by
gas -m68hcs12 option, recorded in:
[ Bug #3432 ] -m68hcs12 option cannot be used due to link errors with provided libs
http://savannah.gnu.org/bugs/?func=detailbug&group_id=2424&bug_id=3432
Stephane
2003-05-13 Stephane Carrez <stcarrez@nerim.fr>
* 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.
Index: bfd/cpu-m68hc12.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-m68hc12.c,v
retrieving revision 1.3
diff -u -p -r1.3 cpu-m68hc12.c
--- bfd/cpu-m68hc12.c 30 Nov 2002 08:39:36 -0000 1.3
+++ bfd/cpu-m68hc12.c 13 May 2003 18:45:54 -0000
@@ -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,18 +21,47 @@ Foundation, Inc., 59 Temple Place - Suit
#include "sysdep.h"
#include "libbfd.h"
+static bfd_boolean scan_mach
+ PARAMS ((const struct bfd_arch_info *, const char *));
+
+static bfd_boolean
+scan_mach (info, string)
+ const struct bfd_arch_info *info;
+ const char *string;
+{
+ if (strcasecmp (info->printable_name, string) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+const bfd_arch_info_type bfd_m68hc12s_arch =
+{
+ 16, /* 16 bits in a word */
+ 16, /* 16 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_m68hc12,
+ bfd_mach_m6812s,
+ "m68hcs12",
+ "m68hcs12",
+ 4, /* section alignment power */
+ FALSE,
+ bfd_default_compatible,
+ scan_mach,
+ 0,
+};
+
const bfd_arch_info_type bfd_m68hc12_arch =
{
- 16, /* 16 bits in a word */
- 16, /* 16 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_m68hc12,
- 0,
- "m68hc12",
- "m68hc12",
- 4, /* section alignment power */
- TRUE,
- bfd_default_compatible,
- bfd_default_scan,
- 0,
+ 16, /* 16 bits in a word */
+ 16, /* 16 bits in an address */
+ 8, /* 8 bits in a byte */
+ bfd_arch_m68hc12,
+ 0,
+ "m68hc12",
+ "m68hc12",
+ 4, /* section alignment power */
+ TRUE,
+ bfd_default_compatible,
+ scan_mach,
+ &bfd_m68hc12s_arch,
};
Index: bfd/elf32-m68hc1x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc1x.c,v
retrieving revision 1.1
diff -u -p -r1.1 elf32-m68hc1x.c
--- bfd/elf32-m68hc1x.c 21 Apr 2003 13:22:13 -0000 1.1
+++ bfd/elf32-m68hc1x.c 13 May 2003 18:45:58 -0000
@@ -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
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;