[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.

Kaylor, Andrew andrew.kaylor at intel.com
Wed Feb 20 10:32:55 PST 2013


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.

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.

-Andy

From: Stefanus Du Toit [mailto:sjdutoit at gmail.com]
Sent: Wednesday, February 20, 2013 10:24 AM
To: Kaylor, Andrew
Cc: llvm-commits at cs.uiuc.edu
Subject: 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.

Can a test case be added?

On Wednesday, February 20, 2013, Andrew Kaylor wrote:
Author: akaylor
Date: Wed Feb 20 12:09:21 2013
New Revision: 175643

URL: http://llvm.org/viewvc/llvm-project?rev=175643&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=175643&r1=175642&r2=175643&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Feb 20 12:09:21 2013
@@ -432,14 +432,21 @@ void RuntimeDyldImpl::resolveExternalSym
     RelocationList &Relocs = i->second;
     SymbolTableMap::const_iterator Loc = GlobalSymbolTable.find(Name);
     if (Loc == GlobalSymbolTable.end()) {
-      // This is an external symbol, try to get it address from
-      // MemoryManager.
-      uint8_t *Addr = (uint8_t*) MemMgr->getPointerToNamedFunction(Name.data(),
+      if (Name.size() == 0) {
+        // This is an absolute symbol, use an address of zero.
+        DEBUG(dbgs() << "Resolving absolute relocations." << "\n");
+        resolveRelocationList(Relocs, 0);
+      }
+      else {
+        // This is an external symbol, try to get it address from
+        // MemoryManager.
+        uint8_t *Addr = (uint8_t*) MemMgr->getPointerToNamedFunction(Name.data(),
                                                                    true);
-      DEBUG(dbgs() << "Resolving relocations Name: " << Name
-              << "\t" << format("%p", Addr)
-              << "\n");
-      resolveRelocationList(Relocs, (uintptr_t)Addr);
+        DEBUG(dbgs() << "Resolving relocations Name: " << Name
+                << "\t" << format("%p", Addr)
+                << "\n");
+        resolveRelocationList(Relocs, (uintptr_t)Addr);
+      }
     } else {
       report_fatal_error("Expected external symbol");
     }


_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu<javascript:;>
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130220/b6a025a1/attachment.html>


More information about the llvm-commits mailing list