[mach-o] Support data-only dylibs

In final linked shared images, the __TEXT segment contains both code and
the mach-o header/load-commands.  In the case of a data-only dylib, there is
no code, so we need to force the addition of the __TEXT segment.

llvm-svn: 220597
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index 208ef0b..275060d 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -500,6 +500,9 @@
                   << ", fileOffset=" << _segInfo[&sg].fileOffset << "\n");
 
     uint32_t segFileSize = 0;
+    // A segment that is not zero-fill must use a least one page of disk space.
+    if (sg.access)
+      segFileSize = _file.pageSize;
     for (const Section *s : _segInfo[&sg].sections) {
       uint32_t sectOffset = s->address - sg.address;
       uint32_t sectFileSize =