[PATCH] [lld][ELF][ARM] Generate PLT entries for function calls from ARM and Thumb code

Denis Protivensky dprotivensky at accesssoftek.com
Tue Mar 31 23:38:43 PDT 2015


================
Comment at: lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp:296-308
@@ +295,15 @@
+  /// \brief get a veneer for a PLT entry.
+  const PLTAtom *getPLTVeneer(const DefinedAtom *da, PLTAtom *pa,
+                              StringRef source) {
+    auto va = new (_file._alloc) ARMPLTVeneerAtom(_file);
+    // Fake reference to show connection between veneer and PLT entry.
+    va->addReferenceELF_ARM(R_ARM_NONE, 0, pa, 0);
+#ifndef NDEBUG
+    va->_name = "__plt_from_thumb";
+    va->_name += source;
+    va->_name += da->name();
+#endif
+    _pltAtoms[da] = PLTWithVeneer(pa, va);
+    return va;
+  }
+
----------------
shankarke wrote:
> Isnt a seperate entry in the PLT for a thumb call preferred ? 
When the same atom is called through PLT from both ARM and Thumb, it's enough to generate one PLT with transition code on top of it. ARM code will reference ARM instructions while Thumb code will first execute instruction mode switch. Obviously, I first implemented separate PLTs for ARM & Thumb, but then saw how gcc handles it in one PLT entry and decided that it's more optimal.

================
Comment at: lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp:555-556
@@ -472,6 +554,4 @@
                                        StringRef secName) {
-    auto veneer = _veneerMap.find(da);
-    if (_veneerMap.end() != veneer)
-      return veneer->second;
-
+    if (auto veneer = _veneerAtoms.lookup(da))
+      return veneer;
     auto v = new (_file._alloc) Veneer_THM_B_BL_StaticAtom(_file, secName);
----------------
shankarke wrote:
> Say for example you call the same atom from thumb/arm, the current code would reuse the veneer generated by ARM for thumb too, is this correct ?
When the same atom is called from both modes, the one mode will call the code directly as mode switch is not needed, and the other will use the veneer generated. The conditions for veneer generation are checked in `handleVeneer` method, while this method only creates a veneer when requested.

http://reviews.llvm.org/D8701

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list