diff options
author | Lang Hames <lhames@gmail.com> | 2016-08-10 22:15:09 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2016-08-10 22:15:09 +0000 |
commit | 8c2406b1fc10051d9c8d00cbb84d394b66e7d52c (patch) | |
tree | c75e439ff3d951e4e2ccd65283bbf2438b34be7e /lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp | |
parent | 2ff5935a955f611a8288d76a8e3ec771fc7da51c (diff) | |
download | bcm5719-llvm-8c2406b1fc10051d9c8d00cbb84d394b66e7d52c.tar.gz bcm5719-llvm-8c2406b1fc10051d9c8d00cbb84d394b66e7d52c.zip |
[lld][MachO] Fix LC_SEGEMENT[_64] filesize computation in -r mode.
Using vmsize to populate this file works when outputing MachO images, but fails
when outputting relocatable objects. This patch fixes the computation to use
file offsets, which works for both output types.
Fixes <rdar://problem/27727666>
llvm-svn: 278297
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp')
-rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp index 89b0f6f55a5..8cca2a217c4 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp @@ -643,7 +643,9 @@ llvm::Error MachOFileLayout::writeSingleSegmentLoadCommand(uint8_t *&lc) { seg->vmsize = _file.sections.back().address + _file.sections.back().content.size(); seg->fileoff = _endOfLoadCommands; - seg->filesize = seg->vmsize; + seg->filesize = _sectInfo[&_file.sections.back()].fileOffset + + _file.sections.back().content.size() - + _sectInfo[&_file.sections.front()].fileOffset; seg->maxprot = VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE; seg->initprot = VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE; seg->nsects = _file.sections.size(); |