[lld][NFC] Factor out isCodeSection helper. (#69193)

This commit is contained in:
Jacek Caban 2023-10-16 21:00:13 +02:00 committed by GitHub
parent 38f8b7cbe4
commit f6f944e77f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -1403,11 +1403,7 @@ void Writer::assignAddresses() {
// If /FUNCTIONPADMIN is used, functions are padded in order to create a
// hotpatchable image.
const bool isCodeSection =
(sec->header.Characteristics & IMAGE_SCN_CNT_CODE) &&
(sec->header.Characteristics & IMAGE_SCN_MEM_READ) &&
(sec->header.Characteristics & IMAGE_SCN_MEM_EXECUTE);
uint32_t padding = isCodeSection ? config->functionPadMin : 0;
uint32_t padding = sec->isCodeSection() ? config->functionPadMin : 0;
for (Chunk *c : sec->chunks) {
if (padding && c->isHotPatchable())

View File

@ -64,6 +64,12 @@ public:
// Used only when the name is longer than 8 bytes.
void setStringTableOff(uint32_t v) { stringTableOff = v; }
bool isCodeSection() const {
return (header.Characteristics & llvm::COFF::IMAGE_SCN_CNT_CODE) &&
(header.Characteristics & llvm::COFF::IMAGE_SCN_MEM_READ) &&
(header.Characteristics & llvm::COFF::IMAGE_SCN_MEM_EXECUTE);
}
// N.B. The section index is one based.
uint32_t sectionIndex = 0;