[lld] a2d096d - [lld-macho] Use uint64_t for getSize() instead of size_t

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 16 19:09:04 PDT 2020


Author: Jez Ng
Date: 2020-06-16T18:42:45-07:00
New Revision: a2d096df26079ab81ae6a4b7fbd34986291210d5

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

LOG: [lld-macho] Use uint64_t for getSize() instead of size_t

Summary:
So things work on 32-bit machines. (@vzakhari reported the
breakage starting from D80177).

Reviewers: #lld-macho, vzakhari

Subscribers: llvm-commits, vzakhari

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81982

Added: 
    

Modified: 
    lld/MachO/InputSection.h
    lld/MachO/MergedOutputSection.h
    lld/MachO/OutputSection.h
    lld/MachO/SyntheticSections.cpp
    lld/MachO/SyntheticSections.h

Removed: 
    


################################################################################
diff  --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h
index 10250200bb18..8b0e31dae0ff 100644
--- a/lld/MachO/InputSection.h
+++ b/lld/MachO/InputSection.h
@@ -38,7 +38,7 @@ struct Reloc {
 class InputSection {
 public:
   virtual ~InputSection() = default;
-  virtual size_t getSize() const { return data.size(); }
+  virtual uint64_t getSize() const { return data.size(); }
   virtual uint64_t getFileSize() const { return getSize(); }
   uint64_t getFileOffset() const;
   uint64_t getVA() const;

diff  --git a/lld/MachO/MergedOutputSection.h b/lld/MachO/MergedOutputSection.h
index 9a9600d6089d..5658fe742c55 100644
--- a/lld/MachO/MergedOutputSection.h
+++ b/lld/MachO/MergedOutputSection.h
@@ -28,7 +28,7 @@ class MergedOutputSection : public OutputSection {
   const InputSection *lastSection() const { return inputs.back(); }
 
   // These accessors will only be valid after finalizing the section
-  size_t getSize() const override { return size; }
+  uint64_t getSize() const override { return size; }
   uint64_t getFileSize() const override { return fileSize; }
 
   void mergeInput(InputSection *input) override;

diff  --git a/lld/MachO/OutputSection.h b/lld/MachO/OutputSection.h
index 157d8b57841b..d9ffb1eb2ccb 100644
--- a/lld/MachO/OutputSection.h
+++ b/lld/MachO/OutputSection.h
@@ -37,7 +37,7 @@ class OutputSection {
   uint64_t getSegmentOffset() const;
 
   // How much space the section occupies in the address space.
-  virtual size_t getSize() const = 0;
+  virtual uint64_t getSize() const = 0;
   // How much space the section occupies in the file. Most sections are copied
   // as-is so their file size is the same as their address space size.
   virtual uint64_t getFileSize() const { return getSize(); }

diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index af1c18134152..16fdbb5cc008 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -45,7 +45,7 @@ void MachHeaderSection::addLoadCommand(LoadCommand *lc) {
   sizeOfCmds += lc->getSize();
 }
 
-size_t MachHeaderSection::getSize() const {
+uint64_t MachHeaderSection::getSize() const {
   return sizeof(mach_header_64) + sizeOfCmds;
 }
 
@@ -138,7 +138,7 @@ void BindingSection::writeTo(uint8_t *buf) const {
 StubsSection::StubsSection()
     : SyntheticSection(segment_names::text, "__stubs") {}
 
-size_t StubsSection::getSize() const {
+uint64_t StubsSection::getSize() const {
   return entries.size() * target->stubSize;
 }
 
@@ -158,7 +158,7 @@ void StubsSection::addEntry(DylibSymbol &sym) {
 StubHelperSection::StubHelperSection()
     : SyntheticSection(segment_names::text, "__stub_helper") {}
 
-size_t StubHelperSection::getSize() const {
+uint64_t StubHelperSection::getSize() const {
   return target->stubHelperHeaderSize +
          in.stubs->getEntries().size() * target->stubHelperEntrySize;
 }
@@ -200,7 +200,7 @@ LazyPointerSection::LazyPointerSection()
   flags = S_LAZY_SYMBOL_POINTERS;
 }
 
-size_t LazyPointerSection::getSize() const {
+uint64_t LazyPointerSection::getSize() const {
   return in.stubs->getEntries().size() * WordSize;
 }
 
@@ -281,7 +281,7 @@ SymtabSection::SymtabSection(StringTableSection &stringTableSection)
   align = WordSize;
 }
 
-size_t SymtabSection::getSize() const {
+uint64_t SymtabSection::getSize() const {
   return symbols.size() * sizeof(structs::nlist_64);
 }
 

diff  --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h
index 88b1758fe1b5..c95f1556e918 100644
--- a/lld/MachO/SyntheticSections.h
+++ b/lld/MachO/SyntheticSections.h
@@ -53,7 +53,7 @@ class MachHeaderSection : public SyntheticSection {
   MachHeaderSection();
   void addLoadCommand(LoadCommand *);
   bool isHidden() const override { return true; }
-  size_t getSize() const override;
+  uint64_t getSize() const override;
   void writeTo(uint8_t *buf) const override;
 
 private:
@@ -67,7 +67,7 @@ class PageZeroSection : public SyntheticSection {
 public:
   PageZeroSection();
   bool isHidden() const override { return true; }
-  size_t getSize() const override { return PageZeroSize; }
+  uint64_t getSize() const override { return PageZeroSize; }
   uint64_t getFileSize() const override { return 0; }
   void writeTo(uint8_t *buf) const override {}
 };
@@ -84,7 +84,7 @@ class GotSection : public SyntheticSection {
 
   bool isNeeded() const override { return !entries.empty(); }
 
-  size_t getSize() const override { return entries.size() * WordSize; }
+  uint64_t getSize() const override { return entries.size() * WordSize; }
 
   void writeTo(uint8_t *buf) const override {
     // Nothing to write, GOT contains all zeros at link time; it's populated at
@@ -102,7 +102,7 @@ class BindingSection : public SyntheticSection {
 public:
   BindingSection();
   void finalizeContents();
-  size_t getSize() const override { return contents.size(); }
+  uint64_t getSize() const override { return contents.size(); }
   // Like other sections in __LINKEDIT, the binding section is special: its
   // offsets are recorded in the LC_DYLD_INFO_ONLY load command, instead of in
   // section headers.
@@ -138,7 +138,7 @@ class BindingSection : public SyntheticSection {
 class StubsSection : public SyntheticSection {
 public:
   StubsSection();
-  size_t getSize() const override;
+  uint64_t getSize() const override;
   bool isNeeded() const override { return !entries.empty(); }
   void writeTo(uint8_t *buf) const override;
 
@@ -153,7 +153,7 @@ class StubsSection : public SyntheticSection {
 class StubHelperSection : public SyntheticSection {
 public:
   StubHelperSection();
-  size_t getSize() const override;
+  uint64_t getSize() const override;
   bool isNeeded() const override;
   void writeTo(uint8_t *buf) const override;
 
@@ -169,13 +169,13 @@ class StubHelperSection : public SyntheticSection {
 class ImageLoaderCacheSection : public InputSection {
 public:
   ImageLoaderCacheSection();
-  size_t getSize() const override { return WordSize; }
+  uint64_t getSize() const override { return WordSize; }
 };
 
 class LazyPointerSection : public SyntheticSection {
 public:
   LazyPointerSection();
-  size_t getSize() const override;
+  uint64_t getSize() const override;
   bool isNeeded() const override;
   void writeTo(uint8_t *buf) const override;
 };
@@ -184,7 +184,7 @@ class LazyBindingSection : public SyntheticSection {
 public:
   LazyBindingSection();
   void finalizeContents();
-  size_t getSize() const override { return contents.size(); }
+  uint64_t getSize() const override { return contents.size(); }
   uint32_t encode(const DylibSymbol &);
   // Like other sections in __LINKEDIT, the lazy binding section is special: its
   // offsets are recorded in the LC_DYLD_INFO_ONLY load command, instead of in
@@ -203,7 +203,7 @@ class ExportSection : public SyntheticSection {
 public:
   ExportSection();
   void finalizeContents();
-  size_t getSize() const override { return size; }
+  uint64_t getSize() const override { return size; }
   // Like other sections in __LINKEDIT, the export section is special: its
   // offsets are recorded in the LC_DYLD_INFO_ONLY load command, instead of in
   // section headers.
@@ -221,7 +221,7 @@ class StringTableSection : public SyntheticSection {
   StringTableSection();
   // Returns the start offset of the added string.
   uint32_t addString(StringRef);
-  size_t getSize() const override { return size; }
+  uint64_t getSize() const override { return size; }
   // Like other sections in __LINKEDIT, the string table section is special: its
   // offsets are recorded in the LC_SYMTAB load command, instead of in section
   // headers.
@@ -246,7 +246,7 @@ class SymtabSection : public SyntheticSection {
   SymtabSection(StringTableSection &);
   void finalizeContents();
   size_t getNumSymbols() const { return symbols.size(); }
-  size_t getSize() const override;
+  uint64_t getSize() const override;
   // Like other sections in __LINKEDIT, the symtab section is special: its
   // offsets are recorded in the LC_SYMTAB load command, instead of in section
   // headers.


        


More information about the llvm-commits mailing list