Skip to content

Commit

Permalink
plain underscore prefixes were causing issues with built-in signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettgu10 committed Aug 9, 2021
1 parent f04a482 commit 0f2a1cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/java/wasm/WasmLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ private String getMethodName(WasmNameSection names, WasmExportSection exports, i
if(names != null) {
String name = names.getFunctionName(id);
if(name != null) {
return "_" + name;
return "wasm_" + name;
}
}

if(exports != null) {
WasmExportEntry entry = exports.findMethod(id);
if (entry != null) {
return "_" + entry.getName();
return "export_" + entry.getName();
}
}
return "unnamed_function_" + id;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/wasm/analysis/WasmAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
import wasm.format.sections.structures.WasmImportEntry;

public class WasmAnalysis {
private static HashMap<Program, WasmAnalysis> states = new HashMap<>();
private static HashMap<String, WasmAnalysis> states = new HashMap<>();
public static WasmAnalysis getState(Program p) {
if(!states.containsKey(p)) {
String key = p.getExecutableSHA256();
if(!states.containsKey(key)) {
System.out.println("Creating new analysis state for "+p.getName());
states.put(p, new WasmAnalysis(p));
states.put(key, new WasmAnalysis(p));
}
return states.get(p);
return states.get(key);
}

private Program program;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/wasm/analysis/WasmFunctionAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public WasmFunctionAnalysis(WasmAnalysis parent, Function f) {

}

public Function getFunction() {
return function;
}

public void collectMeta(MetaInstruction meta) {
metas.add(meta);
}
Expand Down Expand Up @@ -132,10 +136,7 @@ public void performResolution() {
case RETURN:
if(valueStackDepth != 0) {
if(valueStackDepth != 1) {
for(MetaInstruction meta: metas) {
System.out.println(meta);
}
throw new RuntimeException("Too many items on stack at return");
throw new RuntimeException("Too many items on stack at return (entry point " + function.getEntryPoint() + ")");
}
ReturnMetaInstruction ret = (ReturnMetaInstruction) instr;
ret.returnsVal = true;
Expand Down

0 comments on commit 0f2a1cd

Please # to comment.