@@ -41,7 +41,7 @@ class ELFAsmParser : public MCAsmParserExtension {
41
41
getParser ().addDirectiveHandler (Directive, Handler);
42
42
}
43
43
44
- bool ParseSectionSwitch (StringRef Section, unsigned Type, unsigned Flags,
44
+ bool parseSectionSwitch (StringRef Section, unsigned Type, unsigned Flags,
45
45
SectionKind Kind);
46
46
47
47
public:
@@ -51,108 +51,108 @@ class ELFAsmParser : public MCAsmParserExtension {
51
51
// Call the base implementation.
52
52
this ->MCAsmParserExtension ::Initialize (Parser);
53
53
54
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveData >(" .data" );
55
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveText >(" .text" );
56
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveBSS >(" .bss" );
57
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveRoData >(" .rodata" );
58
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTData >(" .tdata" );
59
- addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTBSS >(" .tbss" );
54
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveData >(" .data" );
55
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveText >(" .text" );
56
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveBSS >(" .bss" );
57
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveRoData >(" .rodata" );
58
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveTData >(" .tdata" );
59
+ addDirectiveHandler<&ELFAsmParser::parseSectionDirectiveTBSS >(" .tbss" );
60
60
addDirectiveHandler<
61
- &ELFAsmParser::ParseSectionDirectiveDataRel >(" .data.rel" );
61
+ &ELFAsmParser::parseSectionDirectiveDataRel >(" .data.rel" );
62
62
addDirectiveHandler<
63
- &ELFAsmParser::ParseSectionDirectiveDataRelRo >(" .data.rel.ro" );
63
+ &ELFAsmParser::parseSectionDirectiveDataRelRo >(" .data.rel.ro" );
64
64
addDirectiveHandler<
65
- &ELFAsmParser::ParseSectionDirectiveEhFrame >(" .eh_frame" );
66
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSection >(" .section" );
65
+ &ELFAsmParser::parseSectionDirectiveEhFrame >(" .eh_frame" );
66
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSection >(" .section" );
67
67
addDirectiveHandler<
68
- &ELFAsmParser::ParseDirectivePushSection >(" .pushsection" );
69
- addDirectiveHandler<&ELFAsmParser::ParseDirectivePopSection >(" .popsection" );
70
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSize >(" .size" );
71
- addDirectiveHandler<&ELFAsmParser::ParseDirectivePrevious >(" .previous" );
72
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveType >(" .type" );
73
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent >(" .ident" );
74
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver >(" .symver" );
75
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveVersion >(" .version" );
76
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref >(" .weakref" );
77
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute >(" .weak" );
78
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute >(" .local" );
68
+ &ELFAsmParser::parseDirectivePushSection >(" .pushsection" );
69
+ addDirectiveHandler<&ELFAsmParser::parseDirectivePopSection >(" .popsection" );
70
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSize >(" .size" );
71
+ addDirectiveHandler<&ELFAsmParser::parseDirectivePrevious >(" .previous" );
72
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveType >(" .type" );
73
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveIdent >(" .ident" );
74
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSymver >(" .symver" );
75
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveVersion >(" .version" );
76
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveWeakref >(" .weakref" );
77
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSymbolAttribute >(" .weak" );
78
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSymbolAttribute >(" .local" );
79
79
addDirectiveHandler<
80
- &ELFAsmParser::ParseDirectiveSymbolAttribute >(" .protected" );
80
+ &ELFAsmParser::parseDirectiveSymbolAttribute >(" .protected" );
81
81
addDirectiveHandler<
82
- &ELFAsmParser::ParseDirectiveSymbolAttribute >(" .internal" );
82
+ &ELFAsmParser::parseDirectiveSymbolAttribute >(" .internal" );
83
83
addDirectiveHandler<
84
- &ELFAsmParser::ParseDirectiveSymbolAttribute >(" .hidden" );
85
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveSubsection >(" .subsection" );
86
- addDirectiveHandler<&ELFAsmParser::ParseDirectiveCGProfile >(" .cg_profile" );
84
+ &ELFAsmParser::parseDirectiveSymbolAttribute >(" .hidden" );
85
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveSubsection >(" .subsection" );
86
+ addDirectiveHandler<&ELFAsmParser::parseDirectiveCGProfile >(" .cg_profile" );
87
87
}
88
88
89
89
// FIXME: Part of this logic is duplicated in the MCELFStreamer. What is
90
90
// the best way for us to get access to it?
91
- bool ParseSectionDirectiveData (StringRef, SMLoc) {
92
- return ParseSectionSwitch (" .data" , ELF::SHT_PROGBITS,
91
+ bool parseSectionDirectiveData (StringRef, SMLoc) {
92
+ return parseSectionSwitch (" .data" , ELF::SHT_PROGBITS,
93
93
ELF::SHF_WRITE | ELF::SHF_ALLOC,
94
94
SectionKind::getData ());
95
95
}
96
- bool ParseSectionDirectiveText (StringRef, SMLoc) {
97
- return ParseSectionSwitch (" .text" , ELF::SHT_PROGBITS,
96
+ bool parseSectionDirectiveText (StringRef, SMLoc) {
97
+ return parseSectionSwitch (" .text" , ELF::SHT_PROGBITS,
98
98
ELF::SHF_EXECINSTR |
99
99
ELF::SHF_ALLOC, SectionKind::getText ());
100
100
}
101
- bool ParseSectionDirectiveBSS (StringRef, SMLoc) {
102
- return ParseSectionSwitch (" .bss" , ELF::SHT_NOBITS,
101
+ bool parseSectionDirectiveBSS (StringRef, SMLoc) {
102
+ return parseSectionSwitch (" .bss" , ELF::SHT_NOBITS,
103
103
ELF::SHF_WRITE |
104
104
ELF::SHF_ALLOC, SectionKind::getBSS ());
105
105
}
106
- bool ParseSectionDirectiveRoData (StringRef, SMLoc) {
107
- return ParseSectionSwitch (" .rodata" , ELF::SHT_PROGBITS,
106
+ bool parseSectionDirectiveRoData (StringRef, SMLoc) {
107
+ return parseSectionSwitch (" .rodata" , ELF::SHT_PROGBITS,
108
108
ELF::SHF_ALLOC,
109
109
SectionKind::getReadOnly ());
110
110
}
111
- bool ParseSectionDirectiveTData (StringRef, SMLoc) {
112
- return ParseSectionSwitch (" .tdata" , ELF::SHT_PROGBITS,
111
+ bool parseSectionDirectiveTData (StringRef, SMLoc) {
112
+ return parseSectionSwitch (" .tdata" , ELF::SHT_PROGBITS,
113
113
ELF::SHF_ALLOC |
114
114
ELF::SHF_TLS | ELF::SHF_WRITE,
115
115
SectionKind::getThreadData ());
116
116
}
117
- bool ParseSectionDirectiveTBSS (StringRef, SMLoc) {
118
- return ParseSectionSwitch (" .tbss" , ELF::SHT_NOBITS,
117
+ bool parseSectionDirectiveTBSS (StringRef, SMLoc) {
118
+ return parseSectionSwitch (" .tbss" , ELF::SHT_NOBITS,
119
119
ELF::SHF_ALLOC |
120
120
ELF::SHF_TLS | ELF::SHF_WRITE,
121
121
SectionKind::getThreadBSS ());
122
122
}
123
- bool ParseSectionDirectiveDataRel (StringRef, SMLoc) {
124
- return ParseSectionSwitch (" .data.rel" , ELF::SHT_PROGBITS,
123
+ bool parseSectionDirectiveDataRel (StringRef, SMLoc) {
124
+ return parseSectionSwitch (" .data.rel" , ELF::SHT_PROGBITS,
125
125
ELF::SHF_ALLOC | ELF::SHF_WRITE,
126
126
SectionKind::getData ());
127
127
}
128
- bool ParseSectionDirectiveDataRelRo (StringRef, SMLoc) {
129
- return ParseSectionSwitch (" .data.rel.ro" , ELF::SHT_PROGBITS,
128
+ bool parseSectionDirectiveDataRelRo (StringRef, SMLoc) {
129
+ return parseSectionSwitch (" .data.rel.ro" , ELF::SHT_PROGBITS,
130
130
ELF::SHF_ALLOC |
131
131
ELF::SHF_WRITE,
132
132
SectionKind::getReadOnlyWithRel ());
133
133
}
134
- bool ParseSectionDirectiveEhFrame (StringRef, SMLoc) {
135
- return ParseSectionSwitch (" .eh_frame" , ELF::SHT_PROGBITS,
134
+ bool parseSectionDirectiveEhFrame (StringRef, SMLoc) {
135
+ return parseSectionSwitch (" .eh_frame" , ELF::SHT_PROGBITS,
136
136
ELF::SHF_ALLOC | ELF::SHF_WRITE,
137
137
SectionKind::getData ());
138
138
}
139
- bool ParseDirectivePushSection (StringRef, SMLoc);
140
- bool ParseDirectivePopSection (StringRef, SMLoc);
141
- bool ParseDirectiveSection (StringRef, SMLoc);
142
- bool ParseDirectiveSize (StringRef, SMLoc);
143
- bool ParseDirectivePrevious (StringRef, SMLoc);
144
- bool ParseDirectiveType (StringRef, SMLoc);
145
- bool ParseDirectiveIdent (StringRef, SMLoc);
146
- bool ParseDirectiveSymver (StringRef, SMLoc);
147
- bool ParseDirectiveVersion (StringRef, SMLoc);
148
- bool ParseDirectiveWeakref (StringRef, SMLoc);
149
- bool ParseDirectiveSymbolAttribute (StringRef, SMLoc);
150
- bool ParseDirectiveSubsection (StringRef, SMLoc);
151
- bool ParseDirectiveCGProfile (StringRef, SMLoc);
139
+ bool parseDirectivePushSection (StringRef, SMLoc);
140
+ bool parseDirectivePopSection (StringRef, SMLoc);
141
+ bool parseDirectiveSection (StringRef, SMLoc);
142
+ bool parseDirectiveSize (StringRef, SMLoc);
143
+ bool parseDirectivePrevious (StringRef, SMLoc);
144
+ bool parseDirectiveType (StringRef, SMLoc);
145
+ bool parseDirectiveIdent (StringRef, SMLoc);
146
+ bool parseDirectiveSymver (StringRef, SMLoc);
147
+ bool parseDirectiveVersion (StringRef, SMLoc);
148
+ bool parseDirectiveWeakref (StringRef, SMLoc);
149
+ bool parseDirectiveSymbolAttribute (StringRef, SMLoc);
150
+ bool parseDirectiveSubsection (StringRef, SMLoc);
151
+ bool parseDirectiveCGProfile (StringRef, SMLoc);
152
152
153
153
private:
154
- bool ParseSectionName (StringRef &SectionName);
155
- bool ParseSectionArguments (bool IsPush, SMLoc loc);
154
+ bool parseSectionName (StringRef &SectionName);
155
+ bool parseSectionArguments (bool IsPush, SMLoc loc);
156
156
unsigned parseSunStyleSectionFlags ();
157
157
bool maybeParseSectionType (StringRef &TypeName);
158
158
bool parseMergeSize (int64_t &Size );
@@ -165,7 +165,7 @@ class ELFAsmParser : public MCAsmParserExtension {
165
165
166
166
// / ParseDirectiveSymbolAttribute
167
167
// / ::= { ".local", ".weak", ... } [ identifier ( , identifier )* ]
168
- bool ELFAsmParser::ParseDirectiveSymbolAttribute (StringRef Directive, SMLoc) {
168
+ bool ELFAsmParser::parseDirectiveSymbolAttribute (StringRef Directive, SMLoc) {
169
169
MCSymbolAttr Attr = StringSwitch<MCSymbolAttr>(Directive)
170
170
.Case (" .weak" , MCSA_Weak)
171
171
.Case (" .local" , MCSA_Local)
@@ -204,7 +204,7 @@ bool ELFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
204
204
return false ;
205
205
}
206
206
207
- bool ELFAsmParser::ParseSectionSwitch (StringRef Section, unsigned Type,
207
+ bool ELFAsmParser::parseSectionSwitch (StringRef Section, unsigned Type,
208
208
unsigned Flags, SectionKind Kind) {
209
209
const MCExpr *Subsection = nullptr ;
210
210
if (getLexer ().isNot (AsmToken::EndOfStatement)) {
@@ -219,7 +219,7 @@ bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type,
219
219
return false ;
220
220
}
221
221
222
- bool ELFAsmParser::ParseDirectiveSize (StringRef, SMLoc) {
222
+ bool ELFAsmParser::parseDirectiveSize (StringRef, SMLoc) {
223
223
StringRef Name;
224
224
if (getParser ().parseIdentifier (Name))
225
225
return TokError (" expected identifier" );
@@ -241,7 +241,7 @@ bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
241
241
return false ;
242
242
}
243
243
244
- bool ELFAsmParser::ParseSectionName (StringRef &SectionName) {
244
+ bool ELFAsmParser::parseSectionName (StringRef &SectionName) {
245
245
// A section name can contain -, so we cannot just use
246
246
// parseIdentifier.
247
247
SMLoc FirstLoc = getLexer ().getLoc ();
@@ -392,25 +392,25 @@ unsigned ELFAsmParser::parseSunStyleSectionFlags() {
392
392
}
393
393
394
394
395
- bool ELFAsmParser::ParseDirectivePushSection (StringRef s, SMLoc loc) {
395
+ bool ELFAsmParser::parseDirectivePushSection (StringRef s, SMLoc loc) {
396
396
getStreamer ().pushSection ();
397
397
398
- if (ParseSectionArguments (/* IsPush=*/ true , loc)) {
398
+ if (parseSectionArguments (/* IsPush=*/ true , loc)) {
399
399
getStreamer ().popSection ();
400
400
return true ;
401
401
}
402
402
403
403
return false ;
404
404
}
405
405
406
- bool ELFAsmParser::ParseDirectivePopSection (StringRef, SMLoc) {
406
+ bool ELFAsmParser::parseDirectivePopSection (StringRef, SMLoc) {
407
407
if (!getStreamer ().popSection ())
408
408
return TokError (" .popsection without corresponding .pushsection" );
409
409
return false ;
410
410
}
411
411
412
- bool ELFAsmParser::ParseDirectiveSection (StringRef, SMLoc loc) {
413
- return ParseSectionArguments (/* IsPush=*/ false , loc);
412
+ bool ELFAsmParser::parseDirectiveSection (StringRef, SMLoc loc) {
413
+ return parseSectionArguments (/* IsPush=*/ false , loc);
414
414
}
415
415
416
416
bool ELFAsmParser::maybeParseSectionType (StringRef &TypeName) {
@@ -536,10 +536,10 @@ static bool allowSectionTypeMismatch(const Triple &TT, StringRef SectionName,
536
536
return false ;
537
537
}
538
538
539
- bool ELFAsmParser::ParseSectionArguments (bool IsPush, SMLoc loc) {
539
+ bool ELFAsmParser::parseSectionArguments (bool IsPush, SMLoc loc) {
540
540
StringRef SectionName;
541
541
542
- if (ParseSectionName (SectionName))
542
+ if (parseSectionName (SectionName))
543
543
return TokError (" expected identifier" );
544
544
545
545
StringRef TypeName;
@@ -724,7 +724,7 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
724
724
return false ;
725
725
}
726
726
727
- bool ELFAsmParser::ParseDirectivePrevious (StringRef DirName, SMLoc) {
727
+ bool ELFAsmParser::parseDirectivePrevious (StringRef DirName, SMLoc) {
728
728
MCSectionSubPair PreviousSection = getStreamer ().getPreviousSection ();
729
729
if (PreviousSection.first == nullptr )
730
730
return TokError (" .previous without corresponding .section" );
@@ -752,7 +752,7 @@ static MCSymbolAttr MCAttrForString(StringRef Type) {
752
752
// / ::= .type identifier , @attribute
753
753
// / ::= .type identifier , %attribute
754
754
// / ::= .type identifier , "attribute"
755
- bool ELFAsmParser::ParseDirectiveType (StringRef, SMLoc) {
755
+ bool ELFAsmParser::parseDirectiveType (StringRef, SMLoc) {
756
756
StringRef Name;
757
757
if (getParser ().parseIdentifier (Name))
758
758
return TokError (" expected identifier" );
@@ -805,7 +805,7 @@ bool ELFAsmParser::ParseDirectiveType(StringRef, SMLoc) {
805
805
806
806
// / ParseDirectiveIdent
807
807
// / ::= .ident string
808
- bool ELFAsmParser::ParseDirectiveIdent (StringRef, SMLoc) {
808
+ bool ELFAsmParser::parseDirectiveIdent (StringRef, SMLoc) {
809
809
if (getLexer ().isNot (AsmToken::String))
810
810
return TokError (" expected string" );
811
811
@@ -823,7 +823,7 @@ bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) {
823
823
824
824
// / ParseDirectiveSymver
825
825
// / ::= .symver foo, bar2@zed
826
- bool ELFAsmParser::ParseDirectiveSymver (StringRef, SMLoc) {
826
+ bool ELFAsmParser::parseDirectiveSymver (StringRef, SMLoc) {
827
827
StringRef OriginalName, Name, Action;
828
828
if (getParser ().parseIdentifier (OriginalName))
829
829
return TokError (" expected identifier" );
@@ -860,7 +860,7 @@ bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) {
860
860
861
861
// / ParseDirectiveVersion
862
862
// / ::= .version string
863
- bool ELFAsmParser::ParseDirectiveVersion (StringRef, SMLoc) {
863
+ bool ELFAsmParser::parseDirectiveVersion (StringRef, SMLoc) {
864
864
if (getLexer ().isNot (AsmToken::String))
865
865
return TokError (" expected string" );
866
866
@@ -884,7 +884,7 @@ bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) {
884
884
885
885
// / ParseDirectiveWeakref
886
886
// / ::= .weakref foo, bar
887
- bool ELFAsmParser::ParseDirectiveWeakref (StringRef, SMLoc) {
887
+ bool ELFAsmParser::parseDirectiveWeakref (StringRef, SMLoc) {
888
888
// FIXME: Share code with the other alias building directives.
889
889
890
890
StringRef AliasName;
@@ -908,7 +908,7 @@ bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) {
908
908
return false ;
909
909
}
910
910
911
- bool ELFAsmParser::ParseDirectiveSubsection (StringRef, SMLoc) {
911
+ bool ELFAsmParser::parseDirectiveSubsection (StringRef, SMLoc) {
912
912
const MCExpr *Subsection = MCConstantExpr::create (0 , getContext ());
913
913
if (getLexer ().isNot (AsmToken::EndOfStatement)) {
914
914
if (getParser ().parseExpression (Subsection))
@@ -924,7 +924,7 @@ bool ELFAsmParser::ParseDirectiveSubsection(StringRef, SMLoc) {
924
924
Subsection);
925
925
}
926
926
927
- bool ELFAsmParser::ParseDirectiveCGProfile (StringRef S, SMLoc Loc) {
927
+ bool ELFAsmParser::parseDirectiveCGProfile (StringRef S, SMLoc Loc) {
928
928
return MCAsmParserExtension::ParseDirectiveCGProfile (S, Loc);
929
929
}
930
930
0 commit comments