Skip to content

Commit

Permalink
[lld][NFC] Factor out isCodeSection helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjacek committed Oct 16, 2023
1 parent 38f8b7c commit 39cacee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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

0 comments on commit 39cacee

Please sign in to comment.