From 234a9a49cf20a2eecf9b990e4a18a5fe9e6c681d Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Fri, 16 May 1997 22:37:02 +0000 Subject: [PATCH] * interp.c (load_mem): If we get a load from an out of range address, abort. (store_mem): Likewise for stores. (max_mem): New variable. --- sim/mn10300/ChangeLog | 7 +++++++ sim/mn10300/interp.c | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/sim/mn10300/ChangeLog b/sim/mn10300/ChangeLog index 51efa7b80d7..50db9743344 100644 --- a/sim/mn10300/ChangeLog +++ b/sim/mn10300/ChangeLog @@ -1,3 +1,10 @@ +Fri May 16 16:36:17 1997 Jeffrey A Law (law@cygnus.com) + + * interp.c (load_mem): If we get a load from an out of range + address, abort. + (store_mem): Likewise for stores. + (max_mem): New variable. + Tue May 6 13:24:36 1997 Jeffrey A Law (law@cygnus.com) * mn10300_sim.h: Fix ordering of bits in the PSW. diff --git a/sim/mn10300/interp.c b/sim/mn10300/interp.c index 711356fd992..1a14039e1e2 100644 --- a/sim/mn10300/interp.c +++ b/sim/mn10300/interp.c @@ -33,6 +33,7 @@ struct hash_entry #endif }; +static int max_mem = 0; struct hash_entry hash_table[MAX_HASH+1]; @@ -241,6 +242,9 @@ load_mem_big (addr, len) { uint8 *p = addr + State.mem; + if (addr > max_mem) + abort (); + switch (len) { case 1: @@ -263,6 +267,9 @@ load_mem (addr, len) { uint8 *p = addr + State.mem; + if (addr > max_mem) + abort (); + switch (len) { case 1: @@ -286,6 +293,9 @@ store_mem (addr, len, data) { uint8 *p = addr + State.mem; + if (addr > max_mem) + abort (); + switch (len) { case 1: @@ -314,6 +324,7 @@ sim_size (power) if (State.mem) free (State.mem); + max_mem = 1 << power; State.mem = (uint8 *) calloc (1, 1 << power); if (!State.mem) { -- 2.30.2