[lld-macho][nfc] Don't mix file sizes with addresses
authorJez Ng <jezng@fb.com>
Fri, 10 Sep 2021 21:00:43 +0000 (17:00 -0400)
committerJez Ng <jezng@fb.com>
Tue, 22 Mar 2022 21:52:53 +0000 (17:52 -0400)
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

index ccd4f90..e47c7e3 100644 (file)
@@ -770,7 +770,7 @@ static std::vector<MachO::data_in_code_entry> 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(