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; }