From c9c2363048b00749561070008d3b696438ee1024 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Fri, 10 Sep 2021 17:00:43 -0400 Subject: [PATCH] [lld-macho][nfc] Don't mix file sizes with addresses Update DataInCode's calculation of `endAddr` to use `getSize()` instead of `getFileSize()` -- while in practice they're the same for non-zerofill sections (which code sections are), we still should treat address sizes / offsets as distinct from file sizes / offsets. --- lld/MachO/SyntheticSections.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp index ccd4f90..e47c7e3 100644 --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -770,7 +770,7 @@ static std::vector collectDataInCodeEntries() { [](const MachO::data_in_code_entry &entry, uint64_t addr) { return entry.offset < addr; }); - const uint64_t endAddr = beginAddr + isec->getFileSize(); + const uint64_t endAddr = beginAddr + isec->getSize(); for (const auto end = entries.end(); it != end && it->offset + it->length <= endAddr; ++it) dataInCodeEntries.push_back( -- 2.7.4