From b5985a4f47fc6e8bbc65caab02765cc1d0dc1ea4 Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Thu, 29 Aug 2013 20:16:40 +0200 Subject: [PATCH] Improved handling of the stack idenfitication at end of memory that works better for mspgcc 4.7.x --- se/sics/mspsim/util/ELF.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/se/sics/mspsim/util/ELF.java b/se/sics/mspsim/util/ELF.java index e4b0e01..fbde95d 100644 --- a/se/sics/mspsim/util/ELF.java +++ b/se/sics/mspsim/util/ELF.java @@ -374,6 +374,7 @@ public class ELF { public MapTable getMap() { MapTable map = new MapTable(); int sAddrHighest = -1; + boolean foundEnd = false; ELFSection name = sections[symTable.link]; int len = symTable.size; @@ -418,13 +419,14 @@ public class ELF { if (sAddr > 0 && sAddr < 0x100000) { String symbolName = sn; - if (sAddr < 0x5c00 && sAddr > sAddrHighest) { + if (sAddr < 0x5c00 && sAddr > sAddrHighest && !sn.equals("__stack")) { sAddrHighest = sAddr; } // if (bind == ELFSection.SYMBIND_LOCAL) { // symbolName += " (" + currentFile + ')'; // } if ("_end".equals(symbolName)) { + foundEnd = true; map.setHeapStart(sAddr); } else if ("__stack".equals(symbolName)){ map.setStackStart(sAddr); @@ -455,10 +457,10 @@ public class ELF { addr += symTable.getEntrySize(); } - if (map.getHeapStart() <= 0 && sAddrHighest > 0) { - System.err.printf("Warning: Unable to parse _end symbol. I'm guessing that heap starts at 0x%05x\n", sAddrHighest); - map.setHeapStart(sAddrHighest); - } + if (!foundEnd && sAddrHighest > 0) { + System.out.printf("Warning: Unable to parse _end symbol. I'm guessing that heap starts at 0x%05x\n", sAddrHighest); + map.setHeapStart(sAddrHighest); + } return map; }