[lld] f6f944e - [lld][NFC] Factor out isCodeSection helper. (#69193)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 16 12:00:18 PDT 2023
Author: Jacek Caban
Date: 2023-10-16T21:00:13+02:00
New Revision: f6f944e77f741861e641e1dd46c30dcbaf8c83b7
URL: https://github.com/llvm/llvm-project/commit/f6f944e77f741861e641e1dd46c30dcbaf8c83b7
DIFF: https://github.com/llvm/llvm-project/commit/f6f944e77f741861e641e1dd46c30dcbaf8c83b7.diff
LOG: [lld][NFC] Factor out isCodeSection helper. (#69193)
Added:
Modified:
lld/COFF/Writer.cpp
lld/COFF/Writer.h
Removed:
################################################################################
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 4f6c2a57f533505..d4f6ee6fde4952c 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -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())
diff --git a/lld/COFF/Writer.h b/lld/COFF/Writer.h
index 4a74aa7ada59d73..9004bb310d07305 100644
--- a/lld/COFF/Writer.h
+++ b/lld/COFF/Writer.h
@@ -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;
More information about the llvm-commits
mailing list