summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2014-10-28 22:21:10 +0000
committerNick Kledzik <kledzik@apple.com>2014-10-28 22:21:10 +0000
commit54ce2958490fb41d5c8522e176e5bead0d0f310e (patch)
tree5f31360cd051d5378343753cbf4db860bd0190de /lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
parent37f7abe4244c2c532b5e9545bcae93847e36264c (diff)
downloadbcm5719-llvm-54ce2958490fb41d5c8522e176e5bead0d0f310e.tar.gz
bcm5719-llvm-54ce2958490fb41d5c8522e176e5bead0d0f310e.zip
[mach-o] generate LC_DATA_IN_CODE in final linked images
lld was regenerating LC_DATA_IN_CODE in .o output files, but not into final linked images. Update test case to verify data-in-code info makes it into final linked images. llvm-svn: 220827
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp')
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index 275060d57ee..543b60fe8bc 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -415,6 +415,12 @@ uint32_t MachOFileLayout::loadCommandsSize(uint32_t &count) {
++count;
}
+ // Add LC_DATA_IN_CODE if needed
+ if (!_file.dataInCode.empty()) {
+ size += sizeof(linkedit_data_command);
+ ++count;
+ }
+
return size;
}
@@ -823,6 +829,17 @@ std::error_code MachOFileLayout::writeLoadCommands() {
lc[sizeof(dylib_command)+dep.path.size()] = '\0';
lc += size;
}
+ // Add LC_DATA_IN_CODE if needed.
+ if (_dataInCodeSize != 0) {
+ linkedit_data_command* dl = reinterpret_cast<linkedit_data_command*>(lc);
+ dl->cmd = LC_DATA_IN_CODE;
+ dl->cmdsize = sizeof(linkedit_data_command);
+ dl->dataoff = _startOfDataInCode;
+ dl->datasize = _dataInCodeSize;
+ if (_swap)
+ swapStruct(*dl);
+ lc += sizeof(linkedit_data_command);
+ }
}
return ec;
}
@@ -1242,6 +1259,7 @@ void MachOFileLayout::writeLinkEditContent() {
writeLazyBindingInfo();
// TODO: add weak binding info
writeExportInfo();
+ writeDataInCodeInfo();
writeSymbolTable();
}
}
OpenPOWER on IntegriCloud