[lld] r269362 - Handle thunks in adjustExpr.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 14:53:34 PDT 2016


Author: rafael
Date: Thu May 12 16:53:34 2016
New Revision: 269362

URL: http://llvm.org/viewvc/llvm-project?rev=269362&view=rev
Log:
Handle thunks in adjustExpr.

This is similar to the other changes this function does. With this all
Relocations.push_back calls look similar.

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=269362&r1=269361&r2=269362&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu May 12 16:53:34 2016
@@ -69,7 +69,8 @@ private:
 
   void scanRelocs(InputSection<ELFT> &C);
   void scanRelocs(InputSectionBase<ELFT> &S, const Elf_Shdr &RelSec);
-  RelExpr adjustExpr(SymbolBody &S, bool IsWrite, RelExpr Expr, uint32_t Type);
+  RelExpr adjustExpr(const elf::ObjectFile<ELFT> &File, SymbolBody &S,
+                     bool IsWrite, RelExpr Expr, uint32_t Type);
   void createPhdrs();
   void assignAddresses();
   void assignFileOffsets();
@@ -513,8 +514,11 @@ static RelExpr fromPlt(RelExpr Expr) {
 }
 
 template <class ELFT>
-RelExpr Writer<ELFT>::adjustExpr(SymbolBody &Body, bool IsWrite, RelExpr Expr,
+RelExpr Writer<ELFT>::adjustExpr(const elf::ObjectFile<ELFT> &File,
+                                 SymbolBody &Body, bool IsWrite, RelExpr Expr,
                                  uint32_t Type) {
+  if (Target->needsThunk(Type, File, Body))
+    return R_THUNK;
   bool Preemptible = Body.isPreemptible();
   if (Body.isGnuIFunc())
     Expr = toPlt(Expr);
@@ -614,7 +618,7 @@ void Writer<ELFT>::scanRelocs(InputSecti
       continue;
 
     bool Preemptible = Body.isPreemptible();
-    Expr = adjustExpr(Body, IsWrite, Expr, Type);
+    Expr = adjustExpr(File, Body, IsWrite, Expr, Type);
     if (HasError)
       continue;
 
@@ -679,8 +683,8 @@ void Writer<ELFT>::scanRelocs(InputSecti
       continue;
     }
 
-    if (Target->needsThunk(Type, File, Body)) {
-      C.Relocations.push_back({R_THUNK, Type, Offset, Addend, &Body});
+    if (Expr == R_THUNK) {
+      C.Relocations.push_back({Expr, Type, Offset, Addend, &Body});
       continue;
     }
 




More information about the llvm-commits mailing list