summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2016-02-09 02:10:39 +0000
committerPete Cooper <peter_cooper@apple.com>2016-02-09 02:10:39 +0000
commit9b28a4559eb5c1f61501422c916469cc8f611fad (patch)
tree42424bd3dee277425fdaf5391b6cfc73359cc59e /lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
parenta64e1adf849c07232c2bd27b90a59f29659211e7 (diff)
downloadbcm5719-llvm-9b28a4559eb5c1f61501422c916469cc8f611fad.tar.gz
bcm5719-llvm-9b28a4559eb5c1f61501422c916469cc8f611fad.zip
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
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp')
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index d85920f7e19..34c48a500b9 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -288,7 +288,7 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
_endOfLoadCommands += sizeof(linkedit_data_command);
_countOfLoadCommands++;
}
- if (!_file.dataInCode.empty()) {
+ if (_file.generateDataInCodeLoadCommand) {
_endOfLoadCommands += sizeof(linkedit_data_command);
_countOfLoadCommands++;
}
@@ -463,8 +463,9 @@ uint32_t MachOFileLayout::loadCommandsSize(uint32_t &count) {
++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 @@ std::error_code MachOFileLayout::writeLoadCommands() {
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 @@ std::error_code MachOFileLayout::writeLoadCommands() {
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);
OpenPOWER on IntegriCloud