Add cmdline options for LC_DATA_IN_CODE load command.

Also added the defaults for whether to generate this load command, which
the cmdline options are able to override.

There was also a difference to ld64 which is fixed here in that ld64 will
generate an empty data in code command if requested.

rdar://problem/24472630

llvm-svn: 260191
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index d85920f..34c48a5 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -288,7 +288,7 @@
       _endOfLoadCommands += sizeof(linkedit_data_command);
       _countOfLoadCommands++;
     }
-    if (!_file.dataInCode.empty()) {
+    if (_file.generateDataInCodeLoadCommand) {
       _endOfLoadCommands += sizeof(linkedit_data_command);
       _countOfLoadCommands++;
     }
@@ -463,8 +463,9 @@
     ++count;
   }
 
-  // Add LC_DATA_IN_CODE if needed
-  if (!_file.dataInCode.empty()) {
+  // Add LC_DATA_IN_CODE if requested.  Note, we do encode zero length entries.
+  // FIXME: Zero length entries is only to match ld64.  Should we change this?
+  if (_file.generateDataInCodeLoadCommand) {
     size += sizeof(linkedit_data_command);
     ++count;
   }
@@ -810,8 +811,8 @@
       lc += sizeof(linkedit_data_command);
     }
 
-    // Add LC_DATA_IN_CODE if needed.
-    if (_dataInCodeSize != 0) {
+    // Add LC_DATA_IN_CODE if requested.
+    if (_file.generateDataInCodeLoadCommand) {
       linkedit_data_command* dl = reinterpret_cast<linkedit_data_command*>(lc);
       dl->cmd      = LC_DATA_IN_CODE;
       dl->cmdsize  = sizeof(linkedit_data_command);
@@ -993,8 +994,8 @@
       lc += sizeof(linkedit_data_command);
     }
 
-    // Add LC_DATA_IN_CODE if needed.
-    if (_dataInCodeSize != 0) {
+    // Add LC_DATA_IN_CODE if requested.
+    if (_file.generateDataInCodeLoadCommand) {
       linkedit_data_command* dl = reinterpret_cast<linkedit_data_command*>(lc);
       dl->cmd      = LC_DATA_IN_CODE;
       dl->cmdsize  = sizeof(linkedit_data_command);