shithub: 5v

Download patch

ref: f1f56304b68bf740f6f282ed270fee7e9f9596e1
parent: 907de081e187e8630a1710d98b2eae84947fe7c2
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Sep 9 21:33:39 EDT 2023

arm: hook sbrk too

--- a/arm.c
+++ b/arm.c
@@ -22,6 +22,7 @@
 u32int mallocaddr;
 u32int freeaddr;
 u32int reallocaddr;
+u32int sbrkaddr;
 u32int setmalloctagaddr;
 u32int setrealloctagaddr;
 
@@ -325,7 +326,7 @@
 	npc = P->R[15] + offset + 4;
 	if(instr & fLi){
 		P->R[14] = P->R[15];
-		if(check){
+		if(check && P->hookpc == 0){
 			if(npc == mallocaddr){
 				P->hookarg[0] = arg(1);	/* size */
 				P->hookfn = hookmalloc;
@@ -338,6 +339,11 @@
 				P->hookpc = P->R[15];
 			}else if(npc == freeaddr){
 				P->hookarg[0] = arg(1);
+				P->hookarg[1] = asize(1);
+				P->hookfn = hookfree;
+				P->hookpc = P->R[15];
+			}else if(npc == sbrkaddr){
+				P->hookarg[0] = arg(0);
 				P->hookarg[1] = asize(1);
 				P->hookfn = hookfree;
 				P->hookpc = P->R[15];
--- a/dat.h
+++ b/dat.h
@@ -78,6 +78,7 @@
 extern u32int mallocaddr;
 extern u32int freeaddr;
 extern u32int reallocaddr;
+extern u32int sbrkaddr;
 extern u32int setmalloctagaddr;
 extern u32int setrealloctagaddr;
 extern uvlong okrange[];