COFF: Rename Chunk::getPermissions to getOutputCharacteristics.

In an upcoming change I will need to make a distinction between section
type (code, data, bss) and permissions. The term that I use for both
of these things is "output characteristics".

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

llvm-svn: 330361
This commit is contained in:
Peter Collingbourne 2018-04-19 20:03:24 +00:00
parent 317a6ddea7
commit fa322abee9
6 changed files with 14 additions and 14 deletions

View File

@ -387,7 +387,7 @@ bool SectionChunk::hasData() const {
return !(Header->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA);
}
uint32_t SectionChunk::getPermissions() const {
uint32_t SectionChunk::getOutputCharacteristics() const {
return Header->Characteristics & PermMask;
}
@ -425,7 +425,7 @@ CommonChunk::CommonChunk(const COFFSymbolRef S) : Sym(S) {
Alignment = std::min(uint64_t(32), PowerOf2Ceil(Sym.getValue()));
}
uint32_t CommonChunk::getPermissions() const {
uint32_t CommonChunk::getOutputCharacteristics() const {
return IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE;
}
@ -600,7 +600,7 @@ void MergeChunk::finalizeContents() {
}
}
uint32_t MergeChunk::getPermissions() const {
uint32_t MergeChunk::getOutputCharacteristics() const {
return IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA;
}

View File

@ -75,7 +75,7 @@ public:
virtual bool hasData() const { return true; }
// Returns readable/writable/executable bits.
virtual uint32_t getPermissions() const { return 0; }
virtual uint32_t getOutputCharacteristics() const { return 0; }
// Returns the section name if this is a section chunk.
// It is illegal to call this function on non-section chunks.
@ -142,7 +142,7 @@ public:
ArrayRef<uint8_t> getContents() const;
void writeTo(uint8_t *Buf) const override;
bool hasData() const override;
uint32_t getPermissions() const override;
uint32_t getOutputCharacteristics() const override;
StringRef getSectionName() const override { return SectionName; }
void getBaserels(std::vector<Baserel> *Res) override;
bool isCOMDAT() const;
@ -242,7 +242,7 @@ public:
static void addSection(SectionChunk *C);
void finalizeContents() override;
uint32_t getPermissions() const override;
uint32_t getOutputCharacteristics() const override;
StringRef getSectionName() const override { return ".rdata"; }
size_t getSize() const override;
void writeTo(uint8_t *Buf) const override;
@ -260,7 +260,7 @@ public:
CommonChunk(const COFFSymbolRef Sym);
size_t getSize() const override { return Sym.getValue(); }
bool hasData() const override { return false; }
uint32_t getPermissions() const override;
uint32_t getOutputCharacteristics() const override;
StringRef getSectionName() const override { return ".bss"; }
private:

View File

@ -1431,7 +1431,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
E.Name = Def->getName();
E.Sym = Def;
if (Def->getChunk() &&
!(Def->getChunk()->getPermissions() & IMAGE_SCN_MEM_EXECUTE))
!(Def->getChunk()->getOutputCharacteristics() & IMAGE_SCN_MEM_EXECUTE))
E.Data = true;
Config->Exports.push_back(E);
});

View File

@ -65,7 +65,7 @@ private:
// Returns a hash value for S.
uint32_t ICF::getHash(SectionChunk *C) {
return hash_combine(C->getPermissions(), C->SectionName, C->Relocs.size(),
return hash_combine(C->getOutputCharacteristics(), C->SectionName, C->Relocs.size(),
C->Alignment, uint32_t(C->Header->SizeOfRawData),
C->Checksum, C->getContents());
}
@ -82,12 +82,12 @@ uint32_t ICF::getHash(SectionChunk *C) {
// insignificant to the user program and the Visual C++ linker does this.
bool ICF::isEligible(SectionChunk *C) {
// Non-comdat chunks, dead chunks, and writable chunks are not elegible.
bool Writable = C->getPermissions() & llvm::COFF::IMAGE_SCN_MEM_WRITE;
bool Writable = C->getOutputCharacteristics() & llvm::COFF::IMAGE_SCN_MEM_WRITE;
if (!C->isCOMDAT() || !C->isLive() || Writable)
return false;
// Code sections are eligible.
if (C->getPermissions() & llvm::COFF::IMAGE_SCN_MEM_EXECUTE)
if (C->getOutputCharacteristics() & llvm::COFF::IMAGE_SCN_MEM_EXECUTE)
return true;
// .xdata unwind info sections are eligble.
@ -146,7 +146,7 @@ bool ICF::equalsConstant(const SectionChunk *A, const SectionChunk *B) {
return false;
// Compare section attributes and contents.
return A->getPermissions() == B->getPermissions() &&
return A->getOutputCharacteristics() == B->getOutputCharacteristics() &&
A->SectionName == B->SectionName && A->Alignment == B->Alignment &&
A->Header->SizeOfRawData == B->Header->SizeOfRawData &&
A->Checksum == B->Checksum && A->getContents() == B->getContents();

View File

@ -138,7 +138,7 @@ void coff::writeDefFile(StringRef Name) {
<< "@" << E.Ordinal;
if (auto *Def = dyn_cast_or_null<Defined>(E.Sym)) {
if (Def && Def->getChunk() &&
!(Def->getChunk()->getPermissions() & IMAGE_SCN_MEM_EXECUTE))
!(Def->getChunk()->getOutputCharacteristics() & IMAGE_SCN_MEM_EXECUTE))
OS << " DATA";
}
OS << "\n";

View File

@ -457,7 +457,7 @@ void Writer::createSections() {
std::vector<Chunk *> &Chunks = Pair.second;
for (Chunk *C : Chunks) {
Sec->addChunk(C);
Sec->addPermissions(C->getPermissions());
Sec->addPermissions(C->getOutputCharacteristics());
}
}