[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
This commit is contained in:
Jez Ng 2020-06-16 17:27:28 -07:00
parent 9aaa32cfcb
commit a2d096df26
5 changed files with 20 additions and 20 deletions

View File

@ -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;

View File

@ -28,7 +28,7 @@ public:
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;

View File

@ -37,7 +37,7 @@ public:
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(); }

View File

@ -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);
}

View File

@ -53,7 +53,7 @@ public:
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 @@ public:
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 @@ public:
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 @@ private:
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 @@ public:
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 @@ public:
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 @@ public:
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.