llvm.org GIT mirror llvm / 1c13026
Remove more duplicated code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124056 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 9 years ago
12 changed file(s) with 158 addition(s) and 165 deletion(s). Raw diff Collapse all Expand all
1414 #define LLVM_MC_MCSECTIONELF_H
1515
1616 #include "llvm/MC/MCSection.h"
17 #include "llvm/Support/ELF.h"
1718
1819 namespace llvm {
1920
5859 /// header index.
5960 bool HasCommonSymbols() const;
6061
61 /// Valid section flags.
62 enum {
63 // The section contains data that should be writable.
64 SHF_WRITE = 0x1U,
65
66 // The section occupies memory during execution.
67 SHF_ALLOC = 0x2U,
68
69 // The section contains executable machine instructions.
70 SHF_EXECINSTR = 0x4U,
71
72 // The data in the section may be merged to eliminate duplication.
73 SHF_MERGE = 0x10U,
74
75 // Elements in the section consist of null-terminated character strings.
76 SHF_STRINGS = 0x20U,
77
78 // A field in this section holds a section header table index.
79 SHF_INFO_LINK = 0x40U,
80
81 // Adds special ordering requirements for link editors.
82 SHF_LINK_ORDER = 0x80U,
83
84 // This section requires special OS-specific processing to avoid incorrect
85 // behavior.
86 SHF_OS_NONCONFORMING = 0x100U,
87
88 // This section is a member of a section group.
89 SHF_GROUP = 0x200U,
90
91 // This section holds Thread-Local Storage.
92 SHF_TLS = 0x400U,
93
94
95 // Start of target-specific flags.
96
97 /// XCORE_SHF_CP_SECTION - All sections with the "c" flag are grouped
98 /// together by the linker to form the constant pool and the cp register is
99 /// set to the start of the constant pool by the boot code.
100 XCORE_SHF_CP_SECTION = 0x800U,
101
102 /// XCORE_SHF_DP_SECTION - All sections with the "d" flag are grouped
103 /// together by the linker to form the data section and the dp register is
104 /// set to the start of the section by the boot code.
105 XCORE_SHF_DP_SECTION = 0x1000U
106 };
107
10862 StringRef getSectionName() const { return SectionName; }
10963 unsigned getType() const { return Type; }
11064 unsigned getFlags() const { return Flags; }
11973 /// isBaseAddressKnownZero - We know that non-allocatable sections (like
12074 /// debug info) have a base of zero.
12175 virtual bool isBaseAddressKnownZero() const {
122 return (getFlags() & SHF_ALLOC) == 0;
76 return (getFlags() & ELF::SHF_ALLOC) == 0;
12377 }
12478
12579 static bool classof(const MCSection *S) {
507507
508508 // Section flags.
509509 enum {
510 SHF_WRITE = 0x1, // Section data should be writable during execution.
511 SHF_ALLOC = 0x2, // Section occupies memory during program execution.
512 SHF_EXECINSTR = 0x4, // Section contains executable machine instructions.
513 SHF_MERGE = 0x10, // The data in this section may be merged.
514 SHF_STRINGS = 0x20, // The data in this section is null-terminated strings.
515 SHF_MASKPROC = 0xf0000000 // Bits indicating processor-specific flags.
510 // Section data should be writable during execution.
511 SHF_WRITE = 0x1,
512
513 // Section occupies memory during program execution.
514 SHF_ALLOC = 0x2,
515
516 // Section contains executable machine instructions.
517 SHF_EXECINSTR = 0x4,
518
519 // The data in this section may be merged.
520 SHF_MERGE = 0x10,
521
522 // The data in this section is null-terminated strings.
523 SHF_STRINGS = 0x20,
524
525 // A field in this section holds a section header table index.
526 SHF_INFO_LINK = 0x40U,
527
528 // Adds special ordering requirements for link editors.
529 SHF_LINK_ORDER = 0x80U,
530
531 // This section requires special OS-specific processing to avoid incorrect
532 // behavior.
533 SHF_OS_NONCONFORMING = 0x100U,
534
535 // This section is a member of a section group.
536 SHF_GROUP = 0x200U,
537
538 // This section holds Thread-Local Storage.
539 SHF_TLS = 0x400U,
540
541 // Start of target-specific flags.
542
543 /// XCORE_SHF_CP_SECTION - All sections with the "c" flag are grouped
544 /// together by the linker to form the constant pool and the cp register is
545 /// set to the start of the constant pool by the boot code.
546 XCORE_SHF_CP_SECTION = 0x800U,
547
548 /// XCORE_SHF_DP_SECTION - All sections with the "d" flag are grouped
549 /// together by the linker to form the data section and the dp register is
550 /// set to the start of the section by the boot code.
551 XCORE_SHF_DP_SECTION = 0x1000U,
552
553 // Bits indicating processor-specific flags.
554 SHF_MASKPROC = 0xf0000000
516555 };
517556
518557 // Section Group Flags
4747
4848 BSSSection =
4949 getContext().getELFSection(".bss", ELF::SHT_NOBITS,
50 MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
50 ELF::SHF_WRITE |ELF::SHF_ALLOC,
5151 SectionKind::getBSS());
5252
5353 TextSection =
5454 getContext().getELFSection(".text", ELF::SHT_PROGBITS,
55 MCSectionELF::SHF_EXECINSTR |
56 MCSectionELF::SHF_ALLOC,
55 ELF::SHF_EXECINSTR |
56 ELF::SHF_ALLOC,
5757 SectionKind::getText());
5858
5959 DataSection =
6060 getContext().getELFSection(".data", ELF::SHT_PROGBITS,
61 MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
61 ELF::SHF_WRITE |ELF::SHF_ALLOC,
6262 SectionKind::getDataRel());
6363
6464 ReadOnlySection =
6565 getContext().getELFSection(".rodata", ELF::SHT_PROGBITS,
66 MCSectionELF::SHF_ALLOC,
66 ELF::SHF_ALLOC,
6767 SectionKind::getReadOnly());
6868
6969 TLSDataSection =
7070 getContext().getELFSection(".tdata", ELF::SHT_PROGBITS,
71 MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_TLS |
72 MCSectionELF::SHF_WRITE,
71 ELF::SHF_ALLOC | ELF::SHF_TLS |
72 ELF::SHF_WRITE,
7373 SectionKind::getThreadData());
7474
7575 TLSBSSSection =
7676 getContext().getELFSection(".tbss", ELF::SHT_NOBITS,
77 MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_TLS |
78 MCSectionELF::SHF_WRITE,
77 ELF::SHF_ALLOC | ELF::SHF_TLS |
78 ELF::SHF_WRITE,
7979 SectionKind::getThreadBSS());
8080
8181 DataRelSection =
8282 getContext().getELFSection(".data.rel", ELF::SHT_PROGBITS,
83 MCSectionELF::SHF_ALLOC |MCSectionELF::SHF_WRITE,
83 ELF::SHF_ALLOC |ELF::SHF_WRITE,
8484 SectionKind::getDataRel());
8585
8686 DataRelLocalSection =
8787 getContext().getELFSection(".data.rel.local", ELF::SHT_PROGBITS,
88 MCSectionELF::SHF_ALLOC |MCSectionELF::SHF_WRITE,
88 ELF::SHF_ALLOC |ELF::SHF_WRITE,
8989 SectionKind::getDataRelLocal());
9090
9191 DataRelROSection =
9292 getContext().getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
93 MCSectionELF::SHF_ALLOC |MCSectionELF::SHF_WRITE,
93 ELF::SHF_ALLOC |ELF::SHF_WRITE,
9494 SectionKind::getReadOnlyWithRel());
9595
9696 DataRelROLocalSection =
9797 getContext().getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS,
98 MCSectionELF::SHF_ALLOC |MCSectionELF::SHF_WRITE,
98 ELF::SHF_ALLOC |ELF::SHF_WRITE,
9999 SectionKind::getReadOnlyWithRelLocal());
100100
101101 MergeableConst4Section =
102102 getContext().getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
103 MCSectionELF::SHF_ALLOC |MCSectionELF::SHF_MERGE,
103 ELF::SHF_ALLOC |ELF::SHF_MERGE,
104104 SectionKind::getMergeableConst4());
105105
106106 MergeableConst8Section =
107107 getContext().getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
108 MCSectionELF::SHF_ALLOC |MCSectionELF::SHF_MERGE,
108 ELF::SHF_ALLOC |ELF::SHF_MERGE,
109109 SectionKind::getMergeableConst8());
110110
111111 MergeableConst16Section =
112112 getContext().getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
113 MCSectionELF::SHF_ALLOC |MCSectionELF::SHF_MERGE,
113 ELF::SHF_ALLOC |ELF::SHF_MERGE,
114114 SectionKind::getMergeableConst16());
115115
116116 StaticCtorSection =
117117 getContext().getELFSection(".ctors", ELF::SHT_PROGBITS,
118 MCSectionELF::SHF_ALLOC |MCSectionELF::SHF_WRITE,
118 ELF::SHF_ALLOC |ELF::SHF_WRITE,
119119 SectionKind::getDataRel());
120120
121121 StaticDtorSection =
122122 getContext().getELFSection(".dtors", ELF::SHT_PROGBITS,
123 MCSectionELF::SHF_ALLOC |MCSectionELF::SHF_WRITE,
123 ELF::SHF_ALLOC |ELF::SHF_WRITE,
124124 SectionKind::getDataRel());
125125
126126 // Exception Handling Sections.
131131 // adjusted or this should be a data section.
132132 LSDASection =
133133 getContext().getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
134 MCSectionELF::SHF_ALLOC,
134 ELF::SHF_ALLOC,
135135 SectionKind::getReadOnly());
136136 EHFrameSection =
137137 getContext().getELFSection(".eh_frame", ELF::SHT_PROGBITS,
138 MCSectionELF::SHF_ALLOC,
138 ELF::SHF_ALLOC,
139139 SectionKind::getDataRel());
140140
141141 // Debug Info Sections.
229229 unsigned Flags = 0;
230230
231231 if (!K.isMetadata())
232 Flags |= MCSectionELF::SHF_ALLOC;
232 Flags |= ELF::SHF_ALLOC;
233233
234234 if (K.isText())
235 Flags |= MCSectionELF::SHF_EXECINSTR;
235 Flags |= ELF::SHF_EXECINSTR;
236236
237237 if (K.isWriteable())
238 Flags |= MCSectionELF::SHF_WRITE;
238 Flags |= ELF::SHF_WRITE;
239239
240240 if (K.isThreadLocal())
241 Flags |= MCSectionELF::SHF_TLS;
241 Flags |= ELF::SHF_TLS;
242242
243243 // K.isMergeableConst() is left out to honour PR4650
244244 if (K.isMergeableCString() || K.isMergeableConst4() ||
245245 K.isMergeableConst8() || K.isMergeableConst16())
246 Flags |= MCSectionELF::SHF_MERGE;
246 Flags |= ELF::SHF_MERGE;
247247
248248 if (K.isMergeableCString())
249 Flags |= MCSectionELF::SHF_STRINGS;
249 Flags |= ELF::SHF_STRINGS;
250250
251251 return Flags;
252252 }
354354
355355 std::string Name = SizeSpec + utostr(Align);
356356 return getContext().getELFSection(Name, ELF::SHT_PROGBITS,
357 MCSectionELF::SHF_ALLOC |
358 MCSectionELF::SHF_MERGE |
359 MCSectionELF::SHF_STRINGS,
357 ELF::SHF_ALLOC |
358 ELF::SHF_MERGE |
359 ELF::SHF_STRINGS,
360360 Kind);
361361 }
362362
713713 return &Symbol;
714714 }
715715
716 if (Section.getFlags() & MCSectionELF::SHF_MERGE) {
716 if (Section.getFlags() & ELF::SHF_MERGE) {
717717 if (Target.getConstant() == 0)
718718 return NULL;
719719 if (Renamed)
11821182 it != ie; ++it) {
11831183 const MCSectionELF &Section =
11841184 static_cast(it->getSection());
1185 if (!(Section.getFlags() & MCSectionELF::SHF_GROUP))
1185 if (!(Section.getFlags() & ELF::SHF_GROUP))
11861186 continue;
11871187
11881188 const MCSymbol *SignatureSymbol = Section.getGroup();
12051205 it != ie; ++it, ++Index) {
12061206 const MCSectionELF &Section =
12071207 static_cast(it->getSection());
1208 if (!(Section.getFlags() & MCSectionELF::SHF_GROUP))
1208 if (!(Section.getFlags() & ELF::SHF_GROUP))
12091209 continue;
12101210 const MCSectionELF *Group = RevGroupMap[Section.getGroup()];
12111211 MCSectionData &Data = Asm.getOrCreateSectionData(*Group);
155155
156156 void SetSectionData() {
157157 SetSection(".data", ELF::SHT_PROGBITS,
158 MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
158 ELF::SHF_WRITE |ELF::SHF_ALLOC,
159159 SectionKind::getDataRel());
160160 EmitCodeAlignment(4, 0);
161161 }
162162 void SetSectionText() {
163163 SetSection(".text", ELF::SHT_PROGBITS,
164 MCSectionELF::SHF_EXECINSTR |
165 MCSectionELF::SHF_ALLOC, SectionKind::getText());
164 ELF::SHF_EXECINSTR |
165 ELF::SHF_ALLOC, SectionKind::getText());
166166 EmitCodeAlignment(4, 0);
167167 }
168168 void SetSectionBss() {
169169 SetSection(".bss", ELF::SHT_NOBITS,
170 MCSectionELF::SHF_WRITE |
171 MCSectionELF::SHF_ALLOC, SectionKind::getBSS());
170 ELF::SHF_WRITE |
171 ELF::SHF_ALLOC, SectionKind::getBSS());
172172 EmitCodeAlignment(4, 0);
173173 }
174174 };
192192 const MCSectionELF &Section =
193193 static_cast(Symbol->getSection());
194194 MCSymbolData &SD = getAssembler().getSymbolData(*Symbol);
195 if (Section.getFlags() & MCSectionELF::SHF_TLS)
195 if (Section.getFlags() & ELF::SHF_TLS)
196196 SetType(SD, ELF::STT_TLS);
197197 }
198198
346346 if (GetBinding(SD) == ELF_STB_Local) {
347347 const MCSection *Section = getAssembler().getContext().getELFSection(".bss",
348348 ELF::SHT_NOBITS,
349 MCSectionELF::SHF_WRITE |
350 MCSectionELF::SHF_ALLOC,
349 ELF::SHF_WRITE |
350 ELF::SHF_ALLOC,
351351 SectionKind::getBSS());
352352 Symbol->setSection(*Section);
353353
6060 // the best way for us to get access to it?
6161 bool ParseSectionDirectiveData(StringRef, SMLoc) {
6262 return ParseSectionSwitch(".data", ELF::SHT_PROGBITS,
63 MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
63 ELF::SHF_WRITE |ELF::SHF_ALLOC,
6464 SectionKind::getDataRel());
6565 }
6666 bool ParseSectionDirectiveText(StringRef, SMLoc) {
6767 return ParseSectionSwitch(".text", ELF::SHT_PROGBITS,
68 MCSectionELF::SHF_EXECINSTR |
69 MCSectionELF::SHF_ALLOC, SectionKind::getText());
68 ELF::SHF_EXECINSTR |
69 ELF::SHF_ALLOC, SectionKind::getText());
7070 }
7171 bool ParseSectionDirectiveBSS(StringRef, SMLoc) {
7272 return ParseSectionSwitch(".bss", ELF::SHT_NOBITS,
73 MCSectionELF::SHF_WRITE |
74 MCSectionELF::SHF_ALLOC, SectionKind::getBSS());
73 ELF::SHF_WRITE |
74 ELF::SHF_ALLOC, SectionKind::getBSS());
7575 }
7676 bool ParseSectionDirectiveRoData(StringRef, SMLoc) {
7777 return ParseSectionSwitch(".rodata", ELF::SHT_PROGBITS,
78 MCSectionELF::SHF_ALLOC,
78 ELF::SHF_ALLOC,
7979 SectionKind::getReadOnly());
8080 }
8181 bool ParseSectionDirectiveTData(StringRef, SMLoc) {
8282 return ParseSectionSwitch(".tdata", ELF::SHT_PROGBITS,
83 MCSectionELF::SHF_ALLOC |
84 MCSectionELF::SHF_TLS | MCSectionELF::SHF_WRITE,
83 ELF::SHF_ALLOC |
84 ELF::SHF_TLS | ELF::SHF_WRITE,
8585 SectionKind::getThreadData());
8686 }
8787 bool ParseSectionDirectiveTBSS(StringRef, SMLoc) {
8888 return ParseSectionSwitch(".tbss", ELF::SHT_NOBITS,
89 MCSectionELF::SHF_ALLOC |
90 MCSectionELF::SHF_TLS | MCSectionELF::SHF_WRITE,
89 ELF::SHF_ALLOC |
90 ELF::SHF_TLS | ELF::SHF_WRITE,
9191 SectionKind::getThreadBSS());
9292 }
9393 bool ParseSectionDirectiveDataRel(StringRef, SMLoc) {
9494 return ParseSectionSwitch(".data.rel", ELF::SHT_PROGBITS,
95 MCSectionELF::SHF_ALLOC |
96 MCSectionELF::SHF_WRITE,
95 ELF::SHF_ALLOC |
96 ELF::SHF_WRITE,
9797 SectionKind::getDataRel());
9898 }
9999 bool ParseSectionDirectiveDataRelRo(StringRef, SMLoc) {
100100 return ParseSectionSwitch(".data.rel.ro", ELF::SHT_PROGBITS,
101 MCSectionELF::SHF_ALLOC |
102 MCSectionELF::SHF_WRITE,
101 ELF::SHF_ALLOC |
102 ELF::SHF_WRITE,
103103 SectionKind::getReadOnlyWithRel());
104104 }
105105 bool ParseSectionDirectiveDataRelRoLocal(StringRef, SMLoc) {
106106 return ParseSectionSwitch(".data.rel.ro.local", ELF::SHT_PROGBITS,
107 MCSectionELF::SHF_ALLOC |
108 MCSectionELF::SHF_WRITE,
107 ELF::SHF_ALLOC |
108 ELF::SHF_WRITE,
109109 SectionKind::getReadOnlyWithRelLocal());
110110 }
111111 bool ParseSectionDirectiveEhFrame(StringRef, SMLoc) {
112112 return ParseSectionSwitch(".eh_frame", ELF::SHT_PROGBITS,
113 MCSectionELF::SHF_ALLOC |
114 MCSectionELF::SHF_WRITE,
113 ELF::SHF_ALLOC |
114 ELF::SHF_WRITE,
115115 SectionKind::getDataRel());
116116 }
117117 bool ParseDirectiveSection(StringRef, SMLoc);
194194 }
195195
196196 static SectionKind computeSectionKind(unsigned Flags) {
197 if (Flags & MCSectionELF::SHF_EXECINSTR)
197 if (Flags & ELF::SHF_EXECINSTR)
198198 return SectionKind::getText();
199 if (Flags & MCSectionELF::SHF_TLS)
199 if (Flags & ELF::SHF_TLS)
200200 return SectionKind::getThreadData();
201201 return SectionKind::getDataRel();
202202 }
207207 for (unsigned i = 0; i < flagsStr.size(); i++) {
208208 switch (flagsStr[i]) {
209209 case 'a':
210 flags |= MCSectionELF::SHF_ALLOC;
210 flags |= ELF::SHF_ALLOC;
211211 break;
212212 case 'x':
213 flags |= MCSectionELF::SHF_EXECINSTR;
213 flags |= ELF::SHF_EXECINSTR;
214214 break;
215215 case 'w':
216 flags |= MCSectionELF::SHF_WRITE;
216 flags |= ELF::SHF_WRITE;
217217 break;
218218 case 'M':
219 flags |= MCSectionELF::SHF_MERGE;
219 flags |= ELF::SHF_MERGE;
220220 break;
221221 case 'S':
222 flags |= MCSectionELF::SHF_STRINGS;
222 flags |= ELF::SHF_STRINGS;
223223 break;
224224 case 'T':
225 flags |= MCSectionELF::SHF_TLS;
225 flags |= ELF::SHF_TLS;
226226 break;
227227 case 'c':
228 flags |= MCSectionELF::XCORE_SHF_CP_SECTION;
228 flags |= ELF::XCORE_SHF_CP_SECTION;
229229 break;
230230 case 'd':
231 flags |= MCSectionELF::XCORE_SHF_DP_SECTION;
231 flags |= ELF::XCORE_SHF_DP_SECTION;
232232 break;
233233 case 'G':
234 flags |= MCSectionELF::SHF_GROUP;
234 flags |= ELF::SHF_GROUP;
235235 break;
236236 default:
237237 return -1;
256256 // Set the defaults first.
257257 if (SectionName == ".fini" || SectionName == ".init" ||
258258 SectionName == ".rodata")
259 Flags |= MCSectionELF::SHF_ALLOC;
259 Flags |= ELF::SHF_ALLOC;
260260 if (SectionName == ".fini" || SectionName == ".init")
261 Flags |= MCSectionELF::SHF_EXECINSTR;
261 Flags |= ELF::SHF_EXECINSTR;
262262
263263 if (getLexer().is(AsmToken::Comma)) {
264264 Lex();
274274 return TokError("unknown flag");
275275 Flags |= extraFlags;
276276
277 bool Mergeable = Flags & MCSectionELF::SHF_MERGE;
278 bool Group = Flags & MCSectionELF::SHF_GROUP;
277 bool Mergeable = Flags & ELF::SHF_MERGE;
278 bool Group = Flags & ELF::SHF_GROUP;
279279
280280 if (getLexer().isNot(AsmToken::Comma)) {
281281 if (Mergeable)
416416 const MCSection *OldSection = getStreamer().getCurrentSection();
417417 const MCSection *Comment =
418418 getContext().getELFSection(".comment", ELF::SHT_PROGBITS,
419 MCSectionELF::SHF_MERGE |
420 MCSectionELF::SHF_STRINGS,
419 ELF::SHF_MERGE |
420 ELF::SHF_STRINGS,
421421 SectionKind::getReadOnly(),
422422 1, "");
423423
4242
4343 // Handle the weird solaris syntax if desired.
4444 if (MAI.usesSunStyleELFSectionSwitchSyntax() &&
45 !(Flags & MCSectionELF::SHF_MERGE)) {
46 if (Flags & MCSectionELF::SHF_ALLOC)
45 !(Flags & ELF::SHF_MERGE)) {
46 if (Flags & ELF::SHF_ALLOC)
4747 OS << ",#alloc";
48 if (Flags & MCSectionELF::SHF_EXECINSTR)
48 if (Flags & ELF::SHF_EXECINSTR)
4949 OS << ",#execinstr";
50 if (Flags & MCSectionELF::SHF_WRITE)
50 if (Flags & ELF::SHF_WRITE)
5151 OS << ",#write";
52 if (Flags & MCSectionELF::SHF_TLS)
52 if (Flags & ELF::SHF_TLS)
5353 OS << ",#tls";
5454 OS << '\n';
5555 return;
5656 }
5757
5858 OS << ",\"";
59 if (Flags & MCSectionELF::SHF_ALLOC)
59 if (Flags & ELF::SHF_ALLOC)
6060 OS << 'a';
61 if (Flags & MCSectionELF::SHF_EXECINSTR)
61 if (Flags & ELF::SHF_EXECINSTR)
6262 OS << 'x';
63 if (Flags & MCSectionELF::SHF_WRITE)
63 if (Flags & ELF::SHF_WRITE)
6464 OS << 'w';
65 if (Flags & MCSectionELF::SHF_MERGE)
65 if (Flags & ELF::SHF_MERGE)
6666 OS << 'M';
67 if (Flags & MCSectionELF::SHF_STRINGS)
67 if (Flags & ELF::SHF_STRINGS)
6868 OS << 'S';
69 if (Flags & MCSectionELF::SHF_TLS)
69 if (Flags & ELF::SHF_TLS)
7070 OS << 'T';
7171
7272 // If there are target-specific flags, print them.
73 if (Flags & MCSectionELF::XCORE_SHF_CP_SECTION)
73 if (Flags & ELF::XCORE_SHF_CP_SECTION)
7474 OS << 'c';
75 if (Flags & MCSectionELF::XCORE_SHF_DP_SECTION)
75 if (Flags & ELF::XCORE_SHF_DP_SECTION)
7676 OS << 'd';
7777
7878 OS << '"';
9999 OS << "progbits";
100100
101101 if (EntrySize) {
102 assert(Flags & MCSectionELF::SHF_MERGE);
102 assert(Flags & ELF::SHF_MERGE);
103103 OS << "," << EntrySize;
104104 }
105105
107107 }
108108
109109 bool MCSectionELF::UseCodeAlign() const {
110 return getFlags() & MCSectionELF::SHF_EXECINSTR;
110 return getFlags() & ELF::SHF_EXECINSTR;
111111 }
112112
113113 bool MCSectionELF::isVirtualSection() const {
2727 if (TM.getSubtarget().isAAPCS_ABI()) {
2828 StaticCtorSection =
2929 getContext().getELFSection(".init_array", ELF::SHT_INIT_ARRAY,
30 MCSectionELF::SHF_WRITE |
31 MCSectionELF::SHF_ALLOC,
30 ELF::SHF_WRITE |
31 ELF::SHF_ALLOC,
3232 SectionKind::getDataRel());
3333 StaticDtorSection =
3434 getContext().getELFSection(".fini_array", ELF::SHT_FINI_ARRAY,
35 MCSectionELF::SHF_WRITE |
36 MCSectionELF::SHF_ALLOC,
35 ELF::SHF_WRITE |
36 ELF::SHF_ALLOC,
3737 SectionKind::getDataRel());
3838 }
3939
2424
2525 SmallDataSection =
2626 getContext().getELFSection(".sdata", ELF::SHT_PROGBITS,
27 MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
27 ELF::SHF_WRITE |ELF::SHF_ALLOC,
2828 SectionKind::getDataRel());
2929
3030 SmallBSSSection =
3131 getContext().getELFSection(".sbss", ELF::SHT_NOBITS,
32 MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
32 ELF::SHF_WRITE |ELF::SHF_ALLOC,
3333 SectionKind::getBSS());
3434
3535 }
2828
2929 SmallDataSection =
3030 getContext().getELFSection(".sdata", ELF::SHT_PROGBITS,
31 MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
31 ELF::SHF_WRITE |ELF::SHF_ALLOC,
3232 SectionKind::getDataRel());
3333
3434 SmallBSSSection =
3535 getContext().getELFSection(".sbss", ELF::SHT_NOBITS,
36 MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
36 ELF::SHF_WRITE |ELF::SHF_ALLOC,
3737 SectionKind::getBSS());
3838
3939 }
296296
297297 virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
298298 const MCSectionELF &ES = static_cast(Section);
299 return ES.getFlags() & MCSectionELF::SHF_MERGE;
299 return ES.getFlags() & ELF::SHF_MERGE;
300300 }
301301 };
302302
2020
2121 DataSection =
2222 Ctx.getELFSection(".dp.data", ELF::SHT_PROGBITS,
23 MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
24 MCSectionELF::XCORE_SHF_DP_SECTION,
23 ELF::SHF_ALLOC | ELF::SHF_WRITE |
24 ELF::XCORE_SHF_DP_SECTION,
2525 SectionKind::getDataRel());
2626 BSSSection =
2727 Ctx.getELFSection(".dp.bss", ELF::SHT_NOBITS,
28 MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
29 MCSectionELF::XCORE_SHF_DP_SECTION,
28 ELF::SHF_ALLOC | ELF::SHF_WRITE |
29 ELF::XCORE_SHF_DP_SECTION,
3030 SectionKind::getBSS());
3131
3232 MergeableConst4Section =
3333 Ctx.getELFSection(".cp.rodata.cst4", ELF::SHT_PROGBITS,
34 MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
35 MCSectionELF::XCORE_SHF_CP_SECTION,
34 ELF::SHF_ALLOC | ELF::SHF_MERGE |
35 ELF::XCORE_SHF_CP_SECTION,
3636 SectionKind::getMergeableConst4());
3737 MergeableConst8Section =
3838 Ctx.getELFSection(".cp.rodata.cst8", ELF::SHT_PROGBITS,
39 MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
40 MCSectionELF::XCORE_SHF_CP_SECTION,
39 ELF::SHF_ALLOC | ELF::SHF_MERGE |
40 ELF::XCORE_SHF_CP_SECTION,
4141 SectionKind::getMergeableConst8());
4242 MergeableConst16Section =
4343 Ctx.getELFSection(".cp.rodata.cst16", ELF::SHT_PROGBITS,
44 MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
45 MCSectionELF::XCORE_SHF_CP_SECTION,
44 ELF::SHF_ALLOC | ELF::SHF_MERGE |
45 ELF::XCORE_SHF_CP_SECTION,
4646 SectionKind::getMergeableConst16());
4747
4848 // TLS globals are lowered in the backend to arrays indexed by the current
5353
5454 ReadOnlySection =
5555 Ctx.getELFSection(".cp.rodata", ELF::SHT_PROGBITS,
56 MCSectionELF::SHF_ALLOC |
57 MCSectionELF::XCORE_SHF_CP_SECTION,
56 ELF::SHF_ALLOC |
57 ELF::XCORE_SHF_CP_SECTION,
5858 SectionKind::getReadOnlyWithRel());
5959
6060 // Dynamic linking is not supported. Data with relocations is placed in the