llvm.org GIT mirror llvm / fdf229e
Remove HasCrazyBSS and add a flag in TAI to indicate that '.section' must be emitted for PowerPC-Linux '.bss' section git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78958 91177308-0d34-0410-b5e6-96231b3b80d8 Bruno Cardoso Lopes 10 years ago
9 changed file(s) with 39 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
2929 /// below.
3030 unsigned Flags;
3131
32 /// HasCrazyBSS - PPC/Linux doesn't support the .bss directive, it
33 /// needs .section .bss. TODO: replace this with a TAI method.
34 bool HasCrazyBSS;
35
3632 /// IsExplicit - Indicates that this section comes from globals with an
3733 /// explicit section specfied.
3834 bool IsExplicit;
3935
4036 MCSectionELF(const StringRef &Section, unsigned T, unsigned F,
41 SectionKind K, bool hasCrazyBSS, bool isExplicit)
37 SectionKind K, bool isExplicit)
4238 : MCSection(K), SectionName(Section.str()), Type(T), Flags(F),
43 HasCrazyBSS(hasCrazyBSS), IsExplicit(isExplicit) {}
39 IsExplicit(isExplicit) {}
4440 public:
4541
4642 static MCSectionELF *Create(const StringRef &Section, unsigned Type,
47 unsigned Flags, SectionKind K,
48 bool hasCrazyBSS, bool isExplicit,
43 unsigned Flags, SectionKind K, bool isExplicit,
4944 MCContext &Ctx);
5045
5146 /// ShouldOmitSectionDirective - Decides whether a '.section' directive
5247 /// should be printed before the section name
53 bool ShouldOmitSectionDirective(const char *Name) const;
48 bool ShouldOmitSectionDirective(const char *Name,
49 const TargetAsmInfo &TAI) const;
5450
5551 /// ShouldPrintSectionType - Only prints the section type if supported
5652 bool ShouldPrintSectionType(unsigned Ty) const;
163163 /// Style" syntax for section switching ("#alloc,#write" etc) instead of the
164164 /// normal ELF syntax (,"a,w") in .section directives.
165165 bool SunStyleELFSectionSwitchSyntax; // Defaults to false.
166
167 /// UsesELFSectionDirectiveForBSS - This is true if this target uses ELF
168 /// '.section' directive before the '.bss' one. It's used for PPC/Linux
169 /// which doesn't support the '.bss' directive only.
170 bool UsesELFSectionDirectiveForBSS; // Defaults to false.
166171
167172 //===--- Alignment Information ----------------------------------------===//
168173
335340 return SunStyleELFSectionSwitchSyntax;
336341 }
337342
343 bool usesELFSectionDirectiveForBSS() const {
344 return UsesELFSectionDirectiveForBSS;
345 }
338346
339347 // Accessors.
340348 //
182182
183183
184184 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
185 bool HasCrazyBSS;
186185 mutable void *UniquingMap;
187186 protected:
188187 /// TLSDataSection - Section directive for Thread Local data.
208207 unsigned Flags, SectionKind Kind,
209208 bool IsExplicit = false) const;
210209 public:
211 TargetLoweringObjectFileELF(// FIXME: REMOVE AFTER UNIQUING IS FIXED.
212 bool hasCrazyBSS = false)
213 : HasCrazyBSS(hasCrazyBSS), UniquingMap(0) {}
214
210 TargetLoweringObjectFileELF() : UniquingMap(0) {}
215211 ~TargetLoweringObjectFileELF();
216
217212
218213 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
219214
1515
1616 MCSectionELF *MCSectionELF::
1717 Create(const StringRef &Section, unsigned Type, unsigned Flags,
18 SectionKind K, bool hasCrazyBSS, bool isExplicit, MCContext &Ctx) {
18 SectionKind K, bool isExplicit, MCContext &Ctx) {
1919 return new
20 (Ctx) MCSectionELF(Section, Type, Flags, K, hasCrazyBSS, isExplicit);
20 (Ctx) MCSectionELF(Section, Type, Flags, K, isExplicit);
2121 }
2222
2323 // ShouldOmitSectionDirective - Decides whether a '.section' directive
2424 // should be printed before the section name
25 bool MCSectionELF::ShouldOmitSectionDirective(const char *Name) const {
25 bool MCSectionELF::ShouldOmitSectionDirective(const char *Name,
26 const TargetAsmInfo &TAI) const {
2627
27 // PPC/Linux doesn't support the .bss directive, it needs .section .bss.
2828 // FIXME: Does .section .bss/.data/.text work everywhere??
29 if ((!HasCrazyBSS && strncmp(Name, ".bss", 4) == 0) ||
30 strncmp(Name, ".text", 5) == 0 ||
31 strncmp(Name, ".data", 5) == 0)
29 if (strncmp(Name, ".text", 5) == 0 ||
30 strncmp(Name, ".data", 5) == 0 ||
31 (strncmp(Name, ".bss", 4) == 0 &&
32 !TAI.usesELFSectionDirectiveForBSS()))
3233 return true;
3334
3435 return false;
4546
4647 void MCSectionELF::PrintSwitchToSection(const TargetAsmInfo &TAI,
4748 raw_ostream &OS) const {
48
49 if (ShouldOmitSectionDirective(SectionName.c_str())) {
49
50 if (ShouldOmitSectionDirective(SectionName.c_str(), TAI)) {
5051 OS << '\t' << getSectionName() << '\n';
5152 return;
5253 }
5959 static TargetLoweringObjectFile *CreateTLOF(const PPCTargetMachine &TM) {
6060 if (TM.getSubtargetImpl()->isDarwin())
6161 return new TargetLoweringObjectFileMachO();
62 return new TargetLoweringObjectFileELF(true);
62 return new TargetLoweringObjectFileELF();
6363 }
6464
6565
2929 PrivateGlobalPrefix = ".L";
3030 UsedDirective = "\t# .no_dead_strip\t";
3131 WeakRefDirective = "\t.weak\t";
32
33 // Uses '.section' before '.bss' directive
34 UsesELFSectionDirectiveForBSS = true;
3235
3336 // Debug Information
3437 AbsoluteDebugSectionOffsets = true;
4949 Data32bitsDirective = "\t.long\t";
5050 Data64bitsDirective = "\t.quad\t";
5151 SunStyleELFSectionSwitchSyntax = false;
52 UsesELFSectionDirectiveForBSS = false;
5253 AlignDirective = "\t.align\t";
5354 AlignmentIsInBytes = true;
5455 TextAlignFillValue = 0;
297297 const MCSectionELF *&Entry = Map[Section];
298298 if (Entry) return Entry;
299299
300 return Entry = MCSectionELF::Create(Section, Type, Flags, Kind, HasCrazyBSS,
301 IsExplicit, getContext());
300 return Entry = MCSectionELF::Create(Section, Type, Flags, Kind, IsExplicit,
301 getContext());
302302 }
303303
304304 void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
0 ; Test to make sure that bss sections are printed with '.section' directive.
1 ; RUN: llvm-as < %s | llc -mtriple=powerpc-unknown-linux-gnu | FileCheck %s
2
3 @A = global i32 0
4
5 ; CHECK: .section .bss,"aw",@nobits
6 ; CHECK: .global A
7