<div dir="ltr">*it's not *x = *x</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 9, 2014 at 6:32 PM, Keno Fischer <span dir="ltr"><<a href="mailto:kfischer@college.harvard.edu" target="_blank">kfischer@college.harvard.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Let me correct that to noting that<div class=""><div><br></div><div><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">*x = (*x-addr_of_section(r_</span><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">symbolnum)) + addr_of_section(r_symbolnum)</span><br>


</div><div><span style="font-family:arial,sans-serif;font-size:12.727272033691406px"><br></span></div></div><div><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">actually makes sense to do when you're moving the section (so it's *x = *x, sorry for the confusion). It still strikes me as inconsistent with the first definition though, but maybe that's ok?</span></div>


</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jun 8, 2014 at 11:59 PM, Keno Fischer <span dir="ltr"><<a href="mailto:kfischer@college.harvard.edu" target="_blank">kfischer@college.harvard.edu</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello everybody,<div><br></div><div>I would like some insights on the semantics of the X86_64_RELOC_UNSIGNED relocation type. When r_extern=1, the semantics seem pretty clear:</div>


<div><br></div><div>Let x be a pointer to r_offset of appropriate size given by r_size, then</div>
<div>*x += addr_of_symbol(r_symbolnum)</div><div><br></div><div>However, when r_extern=0 the correct behavior is not clear. By analogy with the above, I would have expected</div><div><br></div><div>*x += addr_of_section(r_symbolnum)</div>



<div><br></div><div>but what LLVM implements is different. In RTDyld it implements</div><div><br></div><div>*x = (*x-addr_of_section(r_symbolnum)) + addr_of_section(r_symbolnum)<br></div><div><br></div><div>or equivalently </div>



<div><br></div><div>*x = *x </div><div><br></div><div>i.e. a noop. This works because llvm codegen also emits the absolute value of the address. I am unsure what is intended and would appreciate some clarification. A couple of points to consider:</div>



<div><br></div><div>1. I checked ld64 and as far as I can tell it doesn't consider non-external X86_64_RELOC_UNSIGNED but does *x += addr_of_symbol(r_symbolnum) regardless. That seems like a bug in ld64 to me because other relocations in the same switch statement do check r_extern. </div>



<div><br></div><div>2. I implemented *x += addr_of_section(r_symbolnum) in LLVM and all tests pass just fine</div><div><br></div><div>3. If the current implementation is correct r_symbolnum (and potentially the entire relocation) basically meaningless, which could of course be correct, but which is what originally caused me to look at this. If so I'd appreciate an explanation as to why we need to have the relocation in the first place.</div>



<div><br></div><div>That's all I could find on the subject. I hope somebody else knows more than I. </div><div><br></div><div>Thanks,</div><div>Keno</div><div><br></div><div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>