<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:2.0cm 42.5pt 2.0cm 3.0cm;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=RU link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>Hello Owen,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>Please find attached the
changed patch which addresses the following 2 things:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>1. Functions in
ELFObjectFile, MachOObjectFile and COFFObjectFile should returns same result.</span></font><font
color=black><span lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>2. We don't need have
several functions with similar functionality which can be obtained by other
means.</span></font><font color=black><span lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>getSymbolAddress -
removed.</span></font><font color=black><span lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>getRelocationAddress -
removed.</span></font><font color=black><span lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-US style='font-size:12.0pt;color:black'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>getSymbolOffset - returns
the offset from the beginning of the section.</span></font><font color=black><span
lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>If we need the virtual
address we can use something like symbol.getOffset() +
symbol.getSection().getAddress()</span></font><font color=black><span
lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>If we need the offset
from the beginning of the object file, we can use something like
symbol.getOffset() + symbol.getSection().getSectionContents().begin() -
object->getData().begin()</span></font><font color=black><span lang=EN-US
style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>If we need the pointer to
the first byte of symbol we can use something like getOffset() +
getSection().getSectionContents().begin()</span></font><font color=black><span
lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-US style='font-size:12.0pt;color:black'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>getRelocationOffset -
returns the offset from the beginning of the section.</span></font><font
color=black><span lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>If we need the virtual
address we can use somethings like reloc.getOffset() +
reloc.getSection().getAddress()</span></font><font color=black><span
lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>If we need the offset
from the beginning of the object file, we can use something like
reloc.getOffset() + reloc.getSection().getSectionContents().begin() -
object->getData().begin()</span></font><font color=black><span lang=EN-US
style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>If we need the pointer to
the first byte of relocation address we can use something like
reloc.getOffset() + reloc.getSection().getSectionContents().begin()</span></font><font
color=black><span lang=EN-US style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-US style='font-size:12.0pt;color:black'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-US style='font-size:12.0pt;color:black'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>Regards,</span></font><font
color=black><span style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'>Danil</span></font><font
color=black><span style='color:black'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-US
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> Owen Anderson
[mailto:resistor@mac.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, November 04, 2011
12:49 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Danil Malyshev<br>
<b><span style='font-weight:bold'>Cc:</span></b> 'llvm-commits@cs.uiuc.edu'<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [llvm-commits]
MachOObjectFile fix functions</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Danil,<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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:<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>- getSymbolOffset<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>- getSymbolAddress<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>- getRelocationAddress<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>--Owen<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><br>
On Nov 03, 2011, at 02:54 PM, Danil Malyshev <dmalyshev@accesssoftek.com>
wrote:<o:p></o:p></span></font></p>

</div>

<div>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span lang=EN-US style='font-size:10.0pt;font-family:Arial'>Hello
everyone,</span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span lang=EN-US style='font-size:10.0pt;font-family:Arial'> </span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span lang=EN-US style='font-size:10.0pt;font-family:Arial'>Please
find attached the patch for review.</span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span lang=EN-US style='font-size:10.0pt;font-family:Arial'>The
patch changed several MachOObjectFile functions:</span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span lang=EN-US style='font-size:10.0pt;font-family:Arial'>- Fix
getSymbolOffset(), getSymbolAddress() and getRelocationAddress(), now it's
works same as in ELFObjectFile.</span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span lang=EN-US style='font-size:10.0pt;font-family:Arial'>- Add
implementation getSymbolSize()</span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span lang=EN-US style='font-size:10.0pt;font-family:Arial'> </span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'> </span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>Regards,</span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>Danil</span></span></font></span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
face=Arial size=2 data-mce-style="font-family: Arial; font-size: x-small;"><span
data-mce-style="font-size: 10.0pt; font-family: Arial;"><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'> </span></span></font></span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>_______________________________________________<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><o:p></o:p></span></font></p>

</div>

</div>

</blockquote>

</div>

</div>

</body>

</html>