[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
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
index d141072..f9101d7 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
@@ -316,11 +316,6 @@
     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 0000000..5799c04
--- /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