<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:m="http://schemas.microsoft.com/office/2004/12/omml" 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 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@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:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I’ll look into adding an ExecutionEngine test case.  This case shows up in the LLDB test suite where it’s a result of some manipulation that LLDB does before
 emitting code.  Specifically, it happens in 32-bit x86 code when LLDB’s expression evaluator tries to create a call to an absolute address, but LLVM generates a PC-relative call with an absolute R_386_PC32 relocation instead.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I’ll see if I can capture the IR to distill this into a stand-alone test case in some sensible way, but I’m not sure it will be reasonable to do so.  There
 may be other situations under which this type of relocation is generated, but I don’t have one handy.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-Andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Stefanus Du Toit [mailto:sjdutoit@gmail.com]
<br>
<b>Sent:</b> Wednesday, February 20, 2013 10:24 AM<br>
<b>To:</b> Kaylor, Andrew<br>
<b>Cc:</b> llvm-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: [llvm] r175643 - Adding support for absolute relocations. This occurs in ELF files when a relocation is given with no name and an undefined section. The relocation is applied with an address of zero.<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Can a test case be added?<br>
<br>
On Wednesday, February 20, 2013, Andrew Kaylor wrote:<o:p></o:p></p>
<p class="MsoNormal">Author: akaylor<br>
Date: Wed Feb 20 12:09:21 2013<br>
New Revision: 175643<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=175643&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=175643&view=rev</a><br>
Log:<br>
Adding support for absolute relocations.  This occurs in ELF files when a relocation is given with no name and an undefined section.  The relocation is applied with an address of zero.<br>
<br>
Modified:<br>
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=175643&r1=175642&r2=175643&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=175643&r1=175642&r2=175643&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Feb 20 12:09:21 2013<br>
@@ -432,14 +432,21 @@ void RuntimeDyldImpl::resolveExternalSym<br>
     RelocationList &Relocs = i->second;<br>
     SymbolTableMap::const_iterator Loc = GlobalSymbolTable.find(Name);<br>
     if (Loc == GlobalSymbolTable.end()) {<br>
-      // This is an external symbol, try to get it address from<br>
-      // MemoryManager.<br>
-      uint8_t *Addr = (uint8_t*) MemMgr->getPointerToNamedFunction(Name.data(),<br>
+      if (Name.size() == 0) {<br>
+        // This is an absolute symbol, use an address of zero.<br>
+        DEBUG(dbgs() << "Resolving absolute relocations." << "\n");<br>
+        resolveRelocationList(Relocs, 0);<br>
+      }<br>
+      else {<br>
+        // This is an external symbol, try to get it address from<br>
+        // MemoryManager.<br>
+        uint8_t *Addr = (uint8_t*) MemMgr->getPointerToNamedFunction(Name.data(),<br>
                                                                    true);<br>
-      DEBUG(dbgs() << "Resolving relocations Name: " << Name<br>
-              << "\t" << format("%p", Addr)<br>
-              << "\n");<br>
-      resolveRelocationList(Relocs, (uintptr_t)Addr);<br>
+        DEBUG(dbgs() << "Resolving relocations Name: " << Name<br>
+                << "\t" << format("%p", Addr)<br>
+                << "\n");<br>
+        resolveRelocationList(Relocs, (uintptr_t)Addr);<br>
+      }<br>
     } else {<br>
       report_fatal_error("Expected external symbol");<br>
     }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="javascript:;">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</div>
</body>
</html>