llvm.org GIT mirror llvm / e0fd567
Remove duplicated info on what .text, .data and .bss look like. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199951 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
5 changed file(s) with 19 addition(s) and 49 deletion(s). Raw diff Collapse all Expand all
107107
108108 SmallPtrSet BindingExplicitlySet;
109109
110
111 void SetSection(StringRef Section, unsigned Type, unsigned Flags,
112 SectionKind Kind);
113110 void SetSectionData();
114111 void SetSectionText();
115112 void SetSectionBss();
282282 *MAB, Out, MCE,
283283 hasMCRelaxAll(),
284284 hasMCNoExecStack()));
285 AsmStreamer.get()->InitSections();
286285
287286 // Create the AsmPrinter, which takes ownership of AsmStreamer if successful.
288287 FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer);
2121 #include "llvm/MC/MCELFSymbolFlags.h"
2222 #include "llvm/MC/MCExpr.h"
2323 #include "llvm/MC/MCInst.h"
24 #include "llvm/MC/MCObjectFileInfo.h"
2425 #include "llvm/MC/MCObjectStreamer.h"
2526 #include "llvm/MC/MCSection.h"
2627 #include "llvm/MC/MCSectionELF.h"
3334
3435 using namespace llvm;
3536
36
37 inline void MCELFStreamer::SetSection(StringRef Section, unsigned Type,
38 unsigned Flags, SectionKind Kind) {
39 SwitchSection(getContext().getELFSection(Section, Type, Flags, Kind));
40 }
41
4237 inline void MCELFStreamer::SetSectionData() {
43 SetSection(".data",
44 ELF::SHT_PROGBITS,
45 ELF::SHF_WRITE | ELF::SHF_ALLOC,
46 SectionKind::getDataRel());
38 SwitchSection(getContext().getObjectFileInfo()->getDataSection());
4739 EmitCodeAlignment(4, 0);
4840 }
4941
5042 inline void MCELFStreamer::SetSectionText() {
51 SetSection(".text",
52 ELF::SHT_PROGBITS,
53 ELF::SHF_EXECINSTR | ELF::SHF_ALLOC,
54 SectionKind::getText());
43 SwitchSection(getContext().getObjectFileInfo()->getTextSection());
5544 EmitCodeAlignment(4, 0);
5645 }
5746
5847 inline void MCELFStreamer::SetSectionBss() {
59 SetSection(".bss",
60 ELF::SHT_NOBITS,
61 ELF::SHF_WRITE | ELF::SHF_ALLOC,
62 SectionKind::getBSS());
48 SwitchSection(getContext().getObjectFileInfo()->getBSSSection());
6349 EmitCodeAlignment(4, 0);
6450 }
6551
1515 #include "llvm/MC/MCExpr.h"
1616 #include "llvm/MC/MCInst.h"
1717 #include "llvm/MC/MCMachOSymbolFlags.h"
18 #include "llvm/MC/MCObjectFileInfo.h"
1819 #include "llvm/MC/MCObjectStreamer.h"
1920 #include "llvm/MC/MCSection.h"
2021 #include "llvm/MC/MCSectionMachO.h"
9899 }
99100
100101 void MCMachOStreamer::InitToTextSection() {
101 SwitchSection(getContext().getMachOSection(
102 "__TEXT", "__text",
103 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 0,
104 SectionKind::getText()));
102 SwitchSection(getContext().getObjectFileInfo()->getTextSection());
105103 }
106104
107105 void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
334332 void MCMachOStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
335333 unsigned ByteAlignment) {
336334 // '.lcomm' is equivalent to '.zerofill'.
337 return EmitZerofill(getContext().getMachOSection("__DATA", "__bss",
338 MCSectionMachO::S_ZEROFILL,
339 0, SectionKind::getBSS()),
335 return EmitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(),
340336 Symbol, Size, ByteAlignment);
341337 }
342338
1919 #include "llvm/MC/MCCodeEmitter.h"
2020 #include "llvm/MC/MCContext.h"
2121 #include "llvm/MC/MCExpr.h"
22 #include "llvm/MC/MCObjectFileInfo.h"
2223 #include "llvm/MC/MCObjectStreamer.h"
2324 #include "llvm/MC/MCSection.h"
2425 #include "llvm/MC/MCSectionCOFF.h"
9495 DF->getContents().append(Code.begin(), Code.end());
9596 }
9697
97 const MCSectionCOFF *getSectionText() {
98 return getContext().getCOFFSection(
99 ".text", COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE |
100 COFF::IMAGE_SCN_MEM_READ,
101 SectionKind::getText());
102 }
103
104 const MCSectionCOFF *getSectionData() {
105 return getContext().getCOFFSection(
106 ".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
107 COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
108 SectionKind::getDataRel());
109 }
110
111 const MCSectionCOFF *getSectionBSS() {
112 return getContext().getCOFFSection(
113 ".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
114 COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
115 SectionKind::getBSS());
98 const MCSection *getSectionText() {
99 return getContext().getObjectFileInfo()->getTextSection();
100 }
101
102 const MCSection *getSectionData() {
103 return getContext().getObjectFileInfo()->getDataSection();
104 }
105
106 const MCSection *getSectionBSS() {
107 return getContext().getObjectFileInfo()->getBSSSection();
116108 }
117109
118110 void SetSectionText() {
140132 unsigned ByteAlignment, bool External) {
141133 assert(!Symbol->isInSection() && "Symbol must not already have a section!");
142134
143 const MCSectionCOFF *Section = getSectionBSS();
135 const MCSection *Section = getSectionBSS();
144136 MCSectionData &SectionData = getAssembler().getOrCreateSectionData(*Section);
145137 if (SectionData.getAlignment() < ByteAlignment)
146138 SectionData.setAlignment(ByteAlignment);