[PSP] prxtool fix reloc count and code end point

Create a single thread for each patch to be added to the repository. Please try to stay on topic.
Post Reply
coyotebean
Posts: 18
Joined: Sat Dec 05, 2009 1:02 am

[PSP] prxtool fix reloc count and code end point

Post by coyotebean »

Fix error in reloc counting and changes the calculation of the m_StubBottom (end of text section)

Code: Select all

Index: prxtool-2459-fix/ProcessPrx.C
===================================================================
--- prxtool-2459-fix/ProcessPrx.C	(revision 2459)
+++ prxtool-2459-fix/ProcessPrx.C	(working copy)
@@ -192,10 +192,6 @@
 				funcAddr += 8;
 			}
 			
-			if (funcAddr > m_stubBottom) {
-				m_stubBottom = funcAddr;
-			}
-
 			for&#40;iLoop = 0; iLoop < pLib->v_count; iLoop++&#41;
 			&#123;
 				u32 varFixup;
@@ -272,7 +268,6 @@
 
 	imp_base = m_modInfo.info.imports;
 	imp_end =  m_modInfo.info.imp_end;
-	m_stubBottom = 0;
 
 	if&#40;imp_base != 0&#41;
 	&#123;
@@ -304,9 +299,6 @@
 		&#125;
 	&#125;
 
-	m_stubBottom += 4;
-	COutput&#58;&#58;Printf&#40;LEVEL_DEBUG, "Stub bottom 0x%08X\n", m_stubBottom&#41;;
-
 	return blRet;
 &#125;
 
@@ -497,6 +489,8 @@
 		m_modInfo.info.exp_end = LW&#40;m_modInfo.info.exp_end&#41;;
 		m_modInfo.info.imports = LW&#40;m_modInfo.info.imports&#41;;
 		m_modInfo.info.imp_end = LW&#40;m_modInfo.info.imp_end&#41;;
+		m_stubBottom = m_modInfo.info.exports - 4; // ".lib.ent.top"
+		COutput&#58;&#58;Printf&#40;LEVEL_DEBUG, "Stub bottom 0x%08X\n", m_stubBottom&#41;;
 		blRet = true;
 
 		if&#40;COutput&#58;&#58;GetDebug&#40;&#41;&#41;
@@ -641,13 +635,28 @@
 					return 0;
 				&#125;
 				part1 = block1&#91;temp&#93;;
-				pos += &#40;part1 & 0x06&#41;;
-				if &#40;&#40;part1 & 0x01&#41; != 0&#41; &#123;
-					if &#40;part1 & 0x38 == 0x10&#41; &#123;
+				if &#40; &#40;part1 & 0x01&#41; == 0 &#41; &#123;
+					if &#40; &#40; part1 & 0x06 &#41; == 4 &#41; &#123;
+						pos += 4;
+					&#125;
+				&#125;
+				else &#123;
+					switch &#40;part1 & 0x06&#41; &#123;
+					case 2&#58;
 						pos += 2;
-					&#125; else if &#40;part1 & 0x38 == 0x18&#41; &#123;
+						break;
+					case 4&#58;
 						pos += 4;
+						break;
 					&#125;
+					switch &#40;part1 & 0x38&#41; &#123;
+					case 0x10&#58;
+						pos += 2;
+						break;
+					case 0x18&#58;
+						pos += 4;
+						break;
+					&#125;
 				&#125;
 				iRelocCount++;
 			&#125;
Last edited by coyotebean on Thu Jan 21, 2010 5:19 pm, edited 2 times in total.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

please use unified diff format ("diff -u") or just do a "svn diff"
coyotebean
Posts: 18
Joined: Sat Dec 05, 2009 1:02 am

Post by coyotebean »

code updated ^_^
Post Reply