[patch] h8300 sim uses inconsistent memory sizes

Alexandre Oliva
2004-06-27T05:34:02Z

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

sd->memory_size was only initialized in init_pointers(), that was
called before the executable was loaded and the machine-type detection
was run. Even though sim_load() duplicated most of the code in
init_pointers(), it failed to update the memory_size in sd, so if we
attempted to run code from a memory location not available on the
original h8300, we'd get a confusing illegal-instruction error,
because h8_get_cache_idx would return -1.

This patch updates sim_load() such that it matches init_pointers() in
this regard. Ok to install?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sim-h8sx-update-memory-size.patch --]
[-- Type: text/x-patch, Size: 776 bytes --]

Index: sim/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>

* h8300/compile.c (sim_load): Update sd->memory_size.

Index: sim/h8300/compile.c
===================================================================
RCS file: /cvs/src/src/sim/h8300/compile.c,v
retrieving revision 1.40
diff -u -p -r1.40 compile.c
--- sim/h8300/compile.c 10 Jun 2004 20:22:17 -0000 1.40
+++ sim/h8300/compile.c 27 Jun 2004 05:28:19 -0000
@@ -5096,6 +5096,7 @@ sim_load (SIM_DESC sd, char *prog, bfd *
calloc (sizeof (char), memory_size));
h8_set_cache_idx_buf (sd, (unsigned short *)
calloc (sizeof (short), memory_size));
+ sd->memory_size = memory_size;
h8_set_eightbit_buf (sd, (unsigned char *) calloc (sizeof (char), 256));

/* `msize' must be a power of two. */

[-- Attachment #3: Type: text/plain, Size: 188 bytes --]

--
Alexandre Oliva http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}