Skip to content

Commit 39cacee

Browse files
committed
[lld][NFC] Factor out isCodeSection helper.
1 parent 38f8b7c commit 39cacee

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lld/COFF/Writer.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,7 @@ void Writer::assignAddresses() {
14031403

14041404
// If /FUNCTIONPADMIN is used, functions are padded in order to create a
14051405
// hotpatchable image.
1406-
const bool isCodeSection =
1407-
(sec->header.Characteristics & IMAGE_SCN_CNT_CODE) &&
1408-
(sec->header.Characteristics & IMAGE_SCN_MEM_READ) &&
1409-
(sec->header.Characteristics & IMAGE_SCN_MEM_EXECUTE);
1410-
uint32_t padding = isCodeSection ? config->functionPadMin : 0;
1406+
uint32_t padding = sec->isCodeSection() ? config->functionPadMin : 0;
14111407

14121408
for (Chunk *c : sec->chunks) {
14131409
if (padding && c->isHotPatchable())

lld/COFF/Writer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ class OutputSection {
6464
// Used only when the name is longer than 8 bytes.
6565
void setStringTableOff(uint32_t v) { stringTableOff = v; }
6666

67+
bool isCodeSection() const {
68+
return (header.Characteristics & llvm::COFF::IMAGE_SCN_CNT_CODE) &&
69+
(header.Characteristics & llvm::COFF::IMAGE_SCN_MEM_READ) &&
70+
(header.Characteristics & llvm::COFF::IMAGE_SCN_MEM_EXECUTE);
71+
}
72+
6773
// N.B. The section index is one based.
6874
uint32_t sectionIndex = 0;
6975

0 commit comments

Comments
 (0)