NumberOfRelocations == UINT16_MAX;
}
- Align getAlignment() const {
+ uint32_t getAlignment() const {
// The IMAGE_SCN_TYPE_NO_PAD bit is a legacy way of getting to
// IMAGE_SCN_ALIGN_1BYTES.
if (Characteristics & COFF::IMAGE_SCN_TYPE_NO_PAD)
- return Align(1);
+ return 1;
// Bit [20:24] contains section alignment. 0 means use a default alignment
// of 16.
- uint32_t EncodedLogValue = (Characteristics >> 20) & 0xF;
- return decodeMaybeAlign(EncodedLogValue).value_or(Align(16));
+ uint32_t Shift = (Characteristics >> 20) & 0xF;
+ if (Shift > 0)
+ return 1U << (Shift - 1);
+ return 16;
}
};
uint64_t getSectionSize(DataRefImpl Sec) const override;
Expected<ArrayRef<uint8_t>>
getSectionContents(DataRefImpl Sec) const override;
- Align getSectionAlignment(DataRefImpl Sec) const override;
+ uint64_t getSectionAlignment(DataRefImpl Sec) const override;
bool isSectionCompressed(DataRefImpl Sec) const override;
bool isSectionText(DataRefImpl Sec) const override;
bool isSectionData(DataRefImpl Sec) const override;
uint64_t getSectionSize(DataRefImpl Sec) const override;
Expected<ArrayRef<uint8_t>>
getSectionContents(DataRefImpl Sec) const override;
- Align getSectionAlignment(DataRefImpl Sec) const override;
+ uint64_t getSectionAlignment(DataRefImpl Sec) const override;
bool isSectionCompressed(DataRefImpl Sec) const override;
bool isSectionText(DataRefImpl Sec) const override;
bool isSectionData(DataRefImpl Sec) const override;
}
template <class ELFT>
-Align ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
- // The value 0 or 1 means that the section has no alignment constraints.
- // https://man7.org/linux/man-pages/man5/elf.5.html
- return MaybeAlign(getSection(Sec)->sh_addralign).valueOrOne();
+uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
+ return getSection(Sec)->sh_addralign;
}
template <class ELFT>
ArrayRef<uint8_t> getSectionContents(uint32_t Offset, uint64_t Size) const;
Expected<ArrayRef<uint8_t>>
getSectionContents(DataRefImpl Sec) const override;
- Align getSectionAlignment(DataRefImpl Sec) const override;
+ uint64_t getSectionAlignment(DataRefImpl Sec) const override;
Expected<SectionRef> getSection(unsigned SectionIndex) const;
Expected<SectionRef> getSection(StringRef SectionName) const;
bool isSectionCompressed(DataRefImpl Sec) const override;
virtual uint64_t getSectionSize(DataRefImpl Sec) const = 0;
virtual Expected<ArrayRef<uint8_t>>
getSectionContents(DataRefImpl Sec) const = 0;
- virtual Align getSectionAlignment(DataRefImpl Sec) const = 0;
+ virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
virtual bool isSectionCompressed(DataRefImpl Sec) const = 0;
virtual bool isSectionText(DataRefImpl Sec) const = 0;
virtual bool isSectionData(DataRefImpl Sec) const = 0;
}
inline uint64_t SectionRef::getAlignment() const {
- return OwningObject->getSectionAlignment(SectionPimpl).value();
+ return OwningObject->getSectionAlignment(SectionPimpl);
}
inline bool SectionRef::isCompressed() const {
uint64_t getSectionSize(DataRefImpl Sec) const override;
Expected<ArrayRef<uint8_t>>
getSectionContents(DataRefImpl Sec) const override;
- Align getSectionAlignment(DataRefImpl Sec) const override;
+ uint64_t getSectionAlignment(DataRefImpl Sec) const override;
bool isSectionCompressed(DataRefImpl Sec) const override;
bool isSectionText(DataRefImpl Sec) const override;
bool isSectionData(DataRefImpl Sec) const override;
uint64_t getSectionSize(DataRefImpl Sec) const override;
Expected<ArrayRef<uint8_t>>
getSectionContents(DataRefImpl Sec) const override;
- Align getSectionAlignment(DataRefImpl Sec) const override;
+ uint64_t getSectionAlignment(DataRefImpl Sec) const override;
bool isSectionCompressed(DataRefImpl Sec) const override;
bool isSectionText(DataRefImpl Sec) const override;
bool isSectionData(DataRefImpl Sec) const override;
B = &G->createZeroFillBlock(
*GraphSec, getSectionSize(Obj, *Sec),
orc::ExecutorAddr(getSectionAddress(Obj, *Sec)),
- (*Sec)->getAlignment().value(), 0);
+ (*Sec)->getAlignment(), 0);
else {
ArrayRef<uint8_t> Data;
if (auto Err = Obj.getSectionContents(*Sec, Data))
B = &G->createContentBlock(
*GraphSec, CharData, orc::ExecutorAddr(getSectionAddress(Obj, *Sec)),
- (*Sec)->getAlignment().value(), 0);
+ (*Sec)->getAlignment(), 0);
}
setGraphBlock(SecIndex, B);
return Res;
}
-Align COFFObjectFile::getSectionAlignment(DataRefImpl Ref) const {
+uint64_t COFFObjectFile::getSectionAlignment(DataRefImpl Ref) const {
const coff_section *Sec = toSec(Ref);
- return Align(Sec->getAlignment());
+ return Sec->getAlignment();
}
bool COFFObjectFile::isSectionCompressed(DataRefImpl Sec) const {
return getSectionContents(Offset, Size);
}
-Align MachOObjectFile::getSectionAlignment(DataRefImpl Sec) const {
+uint64_t MachOObjectFile::getSectionAlignment(DataRefImpl Sec) const {
+ uint32_t Align;
+ if (is64Bit()) {
+ MachO::section_64 Sect = getSection64(Sec);
+ Align = Sect.align;
+ } else {
+ MachO::section Sect = getSection(Sec);
+ Align = Sect.align;
+ }
- return is64Bit() ? Align(1ULL << getSection64(Sec).align)
- : Align(1ULL << getSection(Sec).align);
+ return uint64_t(1) << Align;
}
Expected<SectionRef> MachOObjectFile::getSection(unsigned SectionIndex) const {
return S.Content;
}
-Align WasmObjectFile::getSectionAlignment(DataRefImpl Sec) const {
- return Align(1);
+uint64_t WasmObjectFile::getSectionAlignment(DataRefImpl Sec) const {
+ return 1;
}
bool WasmObjectFile::isSectionCompressed(DataRefImpl Sec) const {
return makeArrayRef(ContentStart,SectionSize);
}
-Align XCOFFObjectFile::getSectionAlignment(DataRefImpl Sec) const {
+uint64_t XCOFFObjectFile::getSectionAlignment(DataRefImpl Sec) const {
+ uint64_t Result = 0;
llvm_unreachable("Not yet implemented!");
- return {};
+ return Result;
}
uint64_t XCOFFObjectFile::getSectionFileOffsetToRawData(DataRefImpl Sec) const {