diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-25 16:00:32 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-25 16:00:32 +0000 |
commit | 68bef454399b25f7f8fb4484a806a5efd69eb3d7 (patch) | |
tree | d83b28ecd71312c0169182d192579c5ea0ef7970 /lib/MC/WinCOFFStreamer.cpp | |
parent | 1b4c8c1fc828927c2027a41166ca735a982926c9 (diff) | |
download | llvm-68bef454399b25f7f8fb4484a806a5efd69eb3d7.tar.gz llvm-68bef454399b25f7f8fb4484a806a5efd69eb3d7.tar.bz2 llvm-68bef454399b25f7f8fb4484a806a5efd69eb3d7.tar.xz |
Refactor to make the .bss, .data and .text sections available for other uses.
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/WinCOFFStreamer.cpp')
-rw-r--r-- | lib/MC/WinCOFFStreamer.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp index 7fc114cbff..0c205e5070 100644 --- a/lib/MC/WinCOFFStreamer.cpp +++ b/lib/MC/WinCOFFStreamer.cpp @@ -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); } }; |