Hi everyone~ <br><br>In ther linux kernel code, I found the reloc_offset. <br><br>{{{<br>// file : misc.S <br>/* Returns (address we are running at) - (address we were linked at)<br> * for use before the text and data are mapped to KERNELBASE.<br>
*/<br>_GLOBAL(reloc_offset)<br>}}}<br><br>I couldn't understand the comment saying "Returns (address we are running at) - (address we were linked at)". <br>
For now, I'm studying each instruction. <br>
<br>And below is best comment I can explain for each instruction. <br><br>_GLOBAL(reloc_offset)<br> mflr r0 // move from link register, save the return address<br> bl 1f // bl 1f<br>
1: mflr r3 // move from link register, r3 is just return address pointing itself <br> LOAD_REG_IMMEDIATE(r4,1b) // get the 1b address, r4 is the address <br> subf r3,r4,r3 // r3 = r3 – r4 <br>
mtlr r0 // restore return address <br> blr<br><br>After this, I still don't know why "r3-r4" is the offset. <br>And what does it mean ?? <br><br>Please explain to me the reason why we need reloc_offset and the code. <br>
Or let me know any helpful reference about this. <br><br>Thank in advance. <br><br>HongWoo. <br><br>