mirror of
https://github.com/intel/llvm.git
synced 2026-02-06 15:18:53 +08:00
[ELF] Move SyntheticSections to InputSection.h. NFC
Keep the main SectionBase hierarchy in InputSection.h. And inline MergeInputSection::getParent.
This commit is contained in:
@@ -1343,10 +1343,6 @@ static size_t findNull(StringRef s, size_t entSize) {
|
||||
llvm_unreachable("");
|
||||
}
|
||||
|
||||
SyntheticSection *MergeInputSection::getParent() const {
|
||||
return cast_or_null<SyntheticSection>(parent);
|
||||
}
|
||||
|
||||
// Split SHF_STRINGS section. Such section is a sequence of
|
||||
// null-terminated strings.
|
||||
void MergeInputSection::splitStrings(StringRef s, size_t entSize) {
|
||||
|
||||
@@ -296,7 +296,9 @@ public:
|
||||
return const_cast<MergeInputSection *>(this)->getSectionPiece(offset);
|
||||
}
|
||||
|
||||
SyntheticSection *getParent() const;
|
||||
SyntheticSection *getParent() const {
|
||||
return cast_or_null<SyntheticSection>(parent);
|
||||
}
|
||||
|
||||
private:
|
||||
void splitStrings(StringRef s, size_t size);
|
||||
@@ -394,6 +396,27 @@ private:
|
||||
|
||||
static_assert(sizeof(InputSection) <= 160, "InputSection is too big");
|
||||
|
||||
class SyntheticSection : public InputSection {
|
||||
public:
|
||||
SyntheticSection(uint64_t flags, uint32_t type, uint32_t alignment,
|
||||
StringRef name)
|
||||
: InputSection(nullptr, flags, type, alignment, {}, name,
|
||||
InputSectionBase::Synthetic) {}
|
||||
|
||||
virtual ~SyntheticSection() = default;
|
||||
virtual size_t getSize() const = 0;
|
||||
virtual bool updateAllocSize() { return false; }
|
||||
// If the section has the SHF_ALLOC flag and the size may be changed if
|
||||
// thunks are added, update the section size.
|
||||
virtual bool isNeeded() const { return true; }
|
||||
virtual void finalizeContents() {}
|
||||
virtual void writeTo(uint8_t *buf) = 0;
|
||||
|
||||
static bool classof(const SectionBase *sec) {
|
||||
return sec->kind() == InputSectionBase::Synthetic;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool isDebugSection(const InputSectionBase &sec) {
|
||||
return (sec.flags & llvm::ELF::SHF_ALLOC) == 0 &&
|
||||
sec.name.startswith(".debug");
|
||||
|
||||
@@ -34,27 +34,6 @@ class Defined;
|
||||
struct PhdrEntry;
|
||||
class SymbolTableBaseSection;
|
||||
|
||||
class SyntheticSection : public InputSection {
|
||||
public:
|
||||
SyntheticSection(uint64_t flags, uint32_t type, uint32_t alignment,
|
||||
StringRef name)
|
||||
: InputSection(nullptr, flags, type, alignment, {}, name,
|
||||
InputSectionBase::Synthetic) {}
|
||||
|
||||
virtual ~SyntheticSection() = default;
|
||||
virtual void writeTo(uint8_t *buf) = 0;
|
||||
virtual size_t getSize() const = 0;
|
||||
virtual void finalizeContents() {}
|
||||
// If the section has the SHF_ALLOC flag and the size may be changed if
|
||||
// thunks are added, update the section size.
|
||||
virtual bool updateAllocSize() { return false; }
|
||||
virtual bool isNeeded() const { return true; }
|
||||
|
||||
static bool classof(const SectionBase *d) {
|
||||
return d->kind() == InputSectionBase::Synthetic;
|
||||
}
|
||||
};
|
||||
|
||||
struct CieRecord {
|
||||
EhSectionPiece *cie = nullptr;
|
||||
SmallVector<EhSectionPiece *, 0> fdes;
|
||||
|
||||
Reference in New Issue
Block a user