Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lld/COFF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 6 additions & 0 deletions lld/COFF/Writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class OutputSection {
// 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;

Expand Down