<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Fellow hackers,<div><br></div><div>I&#39;m currently trying to get MPW 3.5 (from EMPW) to generate code closely resembling the original Trampoline.</div><div><br></div><div>While doing so, I immediately stumbled across two issues I cannot resolve. I must admit that my MPW skills are limited. I therefore hope to get some help from you.</div><div><br></div><div>1) Trampoline&#39;s startup code initializes the RTOC as follows:</div><div><br></div><div>    mflr r11</div><div>    bl setup_rtoc</div><div>    DC.L 0x1001E8</div><div>setup_rtoc:</div><div>    mflr RTOC</div><div>    lwz RTOC, 0(RTOC)</div><div><br></div><div>The word in the 3rd line contains the base address of TOC. The value shown above is from Apple&#39;s binary. I replaced it with DC.L TOC[TC0] to make PPCAsm/PPCLink to stuff the correct value there. That unfortunately doesn&#39;t work. PPCAsm says:</div><div><br></div><div>### Warning 3171 ### Treating &#39;TOC[TC0]&#39; as a csect relative offset. Make sure to add it to its csect&#39;s TOC entry.</div><div><br></div><div>I don&#39;t understand this message. What do I need to put there in order to get the base address of TOC placed there?</div><div><br></div><div>2) Trampoline&#39;s main() initializes the pointer to OF client interface right at the beginning. The code of interest looks like that:</div><div><br></div><div>lwz r9, CIPtr_TC(RTOC)</div><div>lisori r3, 0xdeadbeef</div><div>stw r5, 0(r9)</div><div>stw r3, 4(r9)</div><div><br></div><div>The pointer to the OF client dispatcher is in R5 (3rd argument of main). The TOC pointer is initialized to 0xDEADBEEF. That&#39;s exactly what I cannot reproduce. I defined a correct function pointer like that:</div><div><br></div><div><div>typedef long (*OfCiPtr)(CIArgs *args);</div></div><div>static OfCIPtr gCIPtr;</div><div><br></div><div>void main(int argc, int arg[], OfCiPtr ciPtr)</div><div>{</div><div>    gCIPtr = ciPtr;</div><div>}</div><div><br></div><div>When I initialize that global pointer gCIPtr with value from ciPtr (3rd argument), only the function address is written while the TOC value remains untouched. The compiled code looks like that:</div><div><br></div><div><div>lwz r9, CIPtr_TC(RTOC)</div><div>stw r5, 0(r9)</div></div><div><br></div><div>I wonder how Apple guys managed to put 0xDEADBEEF into TVector&#39;s TOC? Do you have any clue?</div></div></div></div></div>