[llvm] r195653 - Refactor to make the .bss, .data and .text sections available for other uses.
Rafael Espindola
rafael.espindola at gmail.com
Mon Nov 25 08:00:32 PST 2013
Author: rafael
Date: Mon Nov 25 10:00:32 2013
New Revision: 195653
URL: http://llvm.org/viewvc/llvm-project?rev=195653&view=rev
Log:
Refactor to make the .bss, .data and .text sections available for other uses.
No functionality change.
Modified:
llvm/trunk/lib/MC/WinCOFFStreamer.cpp
Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=195653&r1=195652&r2=195653&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Mon Nov 25 10:00:32 2013
@@ -94,36 +94,39 @@ private:
DF->getContents().append(Code.begin(), Code.end());
}
- void SetSection(StringRef Section,
- unsigned Characteristics,
- SectionKind Kind) {
- SwitchSection(getContext().getCOFFSection(Section, Characteristics, Kind));
+ const MCSectionCOFF *getSectionText() {
+ return getContext().getCOFFSection(
+ ".text", COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE |
+ COFF::IMAGE_SCN_MEM_READ,
+ SectionKind::getText());
+ }
+
+ const MCSectionCOFF *getSectionData() {
+ return getContext().getCOFFSection(
+ ".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
+ SectionKind::getDataRel());
+ }
+
+ const MCSectionCOFF *getSectionBSS() {
+ return getContext().getCOFFSection(
+ ".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
+ SectionKind::getBSS());
}
void SetSectionText() {
- SetSection(".text",
- COFF::IMAGE_SCN_CNT_CODE
- | COFF::IMAGE_SCN_MEM_EXECUTE
- | COFF::IMAGE_SCN_MEM_READ,
- SectionKind::getText());
+ SwitchSection(getSectionText());
EmitCodeAlignment(4, 0);
}
void SetSectionData() {
- SetSection(".data",
- COFF::IMAGE_SCN_CNT_INITIALIZED_DATA
- | COFF::IMAGE_SCN_MEM_READ
- | COFF::IMAGE_SCN_MEM_WRITE,
- SectionKind::getDataRel());
+ SwitchSection(getSectionData());
EmitCodeAlignment(4, 0);
}
void SetSectionBSS() {
- SetSection(".bss",
- COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA
- | COFF::IMAGE_SCN_MEM_READ
- | COFF::IMAGE_SCN_MEM_WRITE,
- SectionKind::getBSS());
+ SwitchSection(getSectionBSS());
EmitCodeAlignment(4, 0);
}
};
More information about the llvm-commits
mailing list