[lld] c9c2363 - [lld-macho][nfc] Don't mix file sizes with addresses

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 14:53:02 PDT 2022


Author: Jez Ng
Date: 2022-03-22T17:52:53-04:00
New Revision: c9c2363048b00749561070008d3b696438ee1024

URL: https://github.com/llvm/llvm-project/commit/c9c2363048b00749561070008d3b696438ee1024
DIFF: https://github.com/llvm/llvm-project/commit/c9c2363048b00749561070008d3b696438ee1024.diff

LOG: [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.

Added: 
    

Modified: 
    lld/MachO/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index ccd4f9067610b..e47c7e325a343 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -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(


        


More information about the llvm-commits mailing list