Mercurial > hg > CbC > CbC_llvm
diff lld/COFF/Chunks.h @ 221:79ff65ed7e25
LLVM12 Original
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Jun 2021 19:15:29 +0900 |
parents | 0572611fdcc8 |
children | c4bab56944e8 |
line wrap: on
line diff
--- a/lld/COFF/Chunks.h Tue Jun 15 19:13:43 2021 +0900 +++ b/lld/COFF/Chunks.h Tue Jun 15 19:15:29 2021 +0900 @@ -86,8 +86,8 @@ // can be stored with 32 bits. uint32_t getRVA() const { return rva; } void setRVA(uint64_t v) { + // This may truncate. The writer checks for overflow later. rva = (uint32_t)v; - assert(rva == v && "RVA truncated"); } // Returns readable/writable/executable bits. @@ -204,6 +204,15 @@ ArrayRef<uint8_t> getContents() const; void writeTo(uint8_t *buf) const; + // Defend against unsorted relocations. This may be overly conservative. + void sortRelocations(); + + // Write and relocate a portion of the section. This is intended to be called + // in a loop. Relocations must be sorted first. + void writeAndRelocateSubsection(ArrayRef<uint8_t> sec, + ArrayRef<uint8_t> subsec, + uint32_t &nextRelocIndex, uint8_t *buf) const; + uint32_t getOutputCharacteristics() const { return header->Characteristics & (permMask | typeMask); } @@ -212,6 +221,7 @@ } void getBaserels(std::vector<Baserel> *res); bool isCOMDAT() const; + void applyRelocation(uint8_t *off, const coff_relocation &rel) const; void applyRelX64(uint8_t *off, uint16_t type, OutputSection *os, uint64_t s, uint64_t p) const; void applyRelX86(uint8_t *off, uint16_t type, OutputSection *os, uint64_t s, @@ -283,8 +293,12 @@ // Allow iteration over the associated child chunks for this section. llvm::iterator_range<AssociatedIterator> children() const { - return llvm::make_range(AssociatedIterator(assocChildren), - AssociatedIterator(nullptr)); + // Associated sections do not have children. The assocChildren field is + // part of the parent's list of children. + bool isAssoc = selection == llvm::COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE; + return llvm::make_range( + AssociatedIterator(isAssoc ? nullptr : assocChildren), + AssociatedIterator(nullptr)); } // The section ID this chunk belongs to in its Obj. @@ -574,6 +588,17 @@ SymbolRVASet syms; }; +// Table which contains symbol RVAs with flags. Used for /guard:ehcont. +class RVAFlagTableChunk : public NonSectionChunk { +public: + explicit RVAFlagTableChunk(SymbolRVASet s) : syms(std::move(s)) {} + size_t getSize() const override { return syms.size() * 5; } + void writeTo(uint8_t *buf) const override; + +private: + SymbolRVASet syms; +}; + // Windows-specific. // This class represents a block in .reloc section. // See the PE/COFF spec 5.6 for details.