<html><body><div>Danil,</div><div><br></div><div>These changes are not correct.  I've spent a lot of time over the last few weeks getting these right by comparing them with existing MachO tools.  While it's quite possible there are still bugs, I'm fairly confident of them in general.  Specific incorrectness are noted below:</div><div><br></div><div>- getSymbolOffset</div><div><br></div><div>The Value field of a MachO symbol table entry is a virtual address, not a file offset.  AFAIK, the best way to find the file offset for the symbol is to get the subtract the section virtual address from the symbol virtual address, and add that to section offset.</div><div><br></div><div>- getSymbolAddress</div><div><br></div><div>Your implementation of this seems to be based on an incorrect understanding of what this method is supposed to return.  It is supposed to return the virtual address of the symbol, i.e. the address where the symbol will reside when the dynamic linker maps this object.  Instead, you're returning a pointer in the current process's address space, based on where the object file happens to be memory mapped at the moment.  If the ELF implementation does this, it is simply wrong.</div><div><br></div><div>- getRelocationAddress</div><div><br></div><div>This change is simply wrong.  The value field on MachO relocations holds an offset from the beginning of the section, not a virtual address.  You have to add that the the current section's virtual address to obtain the correct value, as the existing code currently does.</div><div><br></div><div>--Owen</div><div><br>On Nov 03, 2011, at 02:54 PM, Danil Malyshev <dmalyshev@accesssoftek.com> wrote:<br><br></div><div><blockquote type="cite"><div class="msg-quote" lang="RU"><div class="Section1"><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:
10.0pt;font-family:Arial" lang="EN-US" data-mce-style="font-size: 10.0pt; font-family: Arial;">Hello everyone,</span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:
10.0pt;font-family:Arial" lang="EN-US" data-mce-style="font-size: 10.0pt; font-family: Arial;"> </span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:
10.0pt;font-family:Arial" lang="EN-US" data-mce-style="font-size: 10.0pt; font-family: Arial;">Please find attached the patch for review.</span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:
10.0pt;font-family:Arial" lang="EN-US" data-mce-style="font-size: 10.0pt; font-family: Arial;">The patch changed several MachOObjectFile functions:</span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:
10.0pt;font-family:Arial" lang="EN-US" data-mce-style="font-size: 10.0pt; font-family: Arial;">- Fix getSymbolOffset(), getSymbolAddress() and getRelocationAddress(), now it's works same as in ELFObjectFile.</span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:
10.0pt;font-family:Arial" lang="EN-US" data-mce-style="font-size: 10.0pt; font-family: Arial;">- Add implementation getSymbolSize()</span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:
10.0pt;font-family:Arial" lang="EN-US" data-mce-style="font-size: 10.0pt; font-family: Arial;"> </span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:10.0pt;
font-family:Arial" data-mce-style="font-size: 10.0pt; font-family: Arial;"> </span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:10.0pt;
font-family:Arial" data-mce-style="font-size: 10.0pt; font-family: Arial;">Regards,</span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:10.0pt;
font-family:Arial" data-mce-style="font-size: 10.0pt; font-family: Arial;">Danil</span></span></p><p class="MsoNormal"><span face="Arial" size="2" data-mce-style="font-family: Arial; font-size: x-small;" style="font-family: Arial; font-size: x-small;"><span style="font-size:10.0pt;
font-family:Arial" data-mce-style="font-size: 10.0pt; font-family: Arial;"> </span></span></p></div><div class="_stretch">_______________________________________________<br> llvm-commits mailing list<br> <a href="mailto:llvm-commits@cs.uiuc.edu" data-mce-href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" data-mce-href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></div></div></blockquote></div></body></html>