[llvm] c737d4d - [JITLink][ELF] Don't skip sections of size 0

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 30 09:19:21 PST 2021


Author: Steven Wu
Date: 2021-11-30T09:19:14-08:00
New Revision: c737d4d203210f96919f4406e5b815b0946535ab

URL: https://github.com/llvm/llvm-project/commit/c737d4d203210f96919f4406e5b815b0946535ab
DIFF: https://github.com/llvm/llvm-project/commit/c737d4d203210f96919f4406e5b815b0946535ab.diff

LOG: [JITLink][ELF] Don't skip sections of size 0

Size 0 sections can have symbols that have size 0. Build those sections
and symbols into the LinkGraph so they can be used properly if needed.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D114749

Added: 
    llvm/test/ExecutionEngine/JITLink/X86/ELF_empty_section.s

Modified: 
    llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
index d141072891f4f..f9101d71dfa8a 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
@@ -316,11 +316,6 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySections() {
     else
       Prot = MemProt::Read | MemProt::Write;
 
-    // For now we just use this to skip the "undefined" section, probably need
-    // to revist.
-    if (Sec.sh_size == 0)
-      continue;
-
     auto &GraphSec = G->createSection(*Name, Prot);
     if (Sec.sh_type != ELF::SHT_NOBITS) {
       auto Data = Obj.template getSectionContentsAsArray<char>(Sec);

diff  --git a/llvm/test/ExecutionEngine/JITLink/X86/ELF_empty_section.s b/llvm/test/ExecutionEngine/JITLink/X86/ELF_empty_section.s
new file mode 100644
index 0000000000000..5799c046d1f09
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/X86/ELF_empty_section.s
@@ -0,0 +1,12 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t
+// RUN: llvm-jitlink -noexec %t
+
+.section	.foo,"ax"
+.globl  zero
+zero:
+
+
+.text
+.globl main
+main:
+nop


        


More information about the llvm-commits mailing list