[PATCH] D89795: [jitlink][ELF] Allocate SHN_COMMON symbols as uninitialized blocks in __common

Stefan Gränitz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 22 06:08:39 PDT 2020


sgraenitz updated this revision to Diff 299942.
sgraenitz added a comment.

Fix NULL entry in symbol table


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89795/new/

https://reviews.llvm.org/D89795

Files:
  llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp


Index: llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -229,6 +229,8 @@
     switch (Type) {
     case ELF::R_X86_64_PC32:
       return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32;
+    case ELF::R_X86_64_32S:
+      return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32;
     case ELF::R_X86_64_64:
       return ELF_x86_64_Edges::ELFX86RelocationKind::Pointer64;
     case ELF::R_X86_64_GOTPCREL:
@@ -513,6 +515,17 @@
         // I am not sure on If this is going to hold as an invariant. Revisit.
         if (!Name)
           return Name.takeError();
+
+        // Allocate uninitialized common blocks.
+        if (SymRef.isCommon()) {
+          // st_value holds alignment constraints for SHN_COMMON symbols
+          Symbol &S =
+              G->addCommonSymbol(*Name, Scope::Default, getCommonSection(), 0,
+                                 SymRef.st_size, SymRef.getValue(), false);
+          JITSymbolTable[SymbolIndex] = &S;
+          continue;
+        }
+
         // TODO: weak and hidden
         if (SymRef.isExternal())
           bindings = {Linkage::Strong, Scope::Default};
@@ -554,18 +567,12 @@
           JITSymbolTable[SymbolIndex] = &S;
         }
 
-        //  }
         // TODO: The following has to be implmented.
         // leaving commented out to save time for future patchs
         /*
           G->addAbsoluteSymbol(*Name, SymRef.getValue(), SymRef.st_size,
           Linkage::Strong, Scope::Default, false);
-
-          if(SymRef.isCommon()) {
-            G->addCommonSymbol(*Name, Scope::Default, getCommonSection(), 0, 0,
-          SymRef.getValue(), false);
-          }
-  */
+        */
       }
     }
     return Error::success();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89795.299942.patch
Type: text/x-patch
Size: 1866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201022/95db5da9/attachment.bin>


More information about the llvm-commits mailing list