[PATCH] D14090: [ELF2] R_X86_64_COPY relocation implemented

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 28 08:52:33 PDT 2015


grimar added inline comments.

================
Comment at: ELF/Writer.cpp:203-209
@@ -202,2 +202,9 @@
     if (Body) {
+      bool NeedsCopy = false;
+      if (auto *E = dyn_cast<SharedSymbol<ELFT>>(Body)) {
+        NeedsCopy = Target->relocNeedsCopy(Type, *Body);
+        if (NeedsCopy && E->NeedsCopy)
+          continue;
+        E->NeedsCopy = NeedsCopy;
+      }
       NeedsPlt = Target->relocNeedsPlt(Type, *Body);
----------------
ruiu wrote:
> I'm trying to understand this. So, if two or more relocations exist for a shared symbol, the last relocation's NeedsCopy may override the previous results? Is this correct?
What kind of relocations ? According to current logic plt relocations will never happen because it is not function and so the only possible case is relocNeedsGot() which implemented as


bool X86_64TargetInfo::relocNeedsGot(uint32_t Type, const SymbolBody &S) const {
  return Type == R_X86_64_GOTPCREL || relocNeedsPlt(Type, S);
}


that gives us the only case is R_X86_64_GOTPCREL.
Is it possible that symbol will require both R_X86_64_GOTPCREL and copy relocation ? If I understand correctly that case - we can use copy relocation here. So I see nothing wrong, please correct me if I am mistaken.


http://reviews.llvm.org/D14090





More information about the llvm-commits mailing list