//
// { symbol1; symbol2; [...]; symbolN };
//
-// Multiple groups can be defined in the same file and they are merged
-// in only one definition.
+// Multiple groups can be defined in the same file, and they are merged
+// into a single group.
class DynamicListParser final : public ScriptParserBase {
public:
DynamicListParser(StringRef S) : ScriptParserBase(S) {}
-
void run();
-
-private:
- void readGroup();
};
-// Parse the default group definition using C language symbol name.
-void DynamicListParser::readGroup() {
- expect("{");
- while (!Error) {
- Config->DynamicList.push_back(next());
- expect(";");
- if (peek() == "}") {
- next();
- break;
+void DynamicListParser::run() {
+ while (!atEOF()) {
+ expect("{");
+ while (!Error) {
+ Config->DynamicList.push_back(next());
+ expect(";");
+ if (skip("}"))
+ break;
}
+ expect(";");
}
- expect(";");
-}
-
-void DynamicListParser::run() {
- while (!atEOF())
- readGroup();
}
void elf::parseDynamicList(MemoryBufferRef MB) {
private:
void parseVersion(StringRef Version);
+ void parseGlobal(StringRef Version);
void parseLocal();
- void parseVersionSymbols(StringRef Version);
};
size_t elf::defineSymbolVersion(StringRef Version) {
}
void VersionScriptParser::parseVersion(StringRef Version) {
- expect("{");
defineSymbolVersion(Version);
- if (peek() == "global:") {
- next();
- parseVersionSymbols(Version);
- }
- if (peek() == "local:")
- parseLocal();
- else if (peek() != "}")
- parseVersionSymbols(Version);
+ if (skip("global:") || peek() != "local:")
+ parseGlobal(Version);
+ if (skip("local:"))
+ parseLocal();
expect("}");
// Each version may have a parent version. For example, "Ver2" defined as
}
void VersionScriptParser::parseLocal() {
- expect("local:");
+ Config->DefaultSymbolVersion = VER_NDX_LOCAL;
expect("*");
expect(";");
- Config->DefaultSymbolVersion = VER_NDX_LOCAL;
}
-void VersionScriptParser::parseVersionSymbols(StringRef Version) {
+void VersionScriptParser::parseGlobal(StringRef Version) {
std::vector<StringRef> *Globals;
if (Version.empty())
Globals = &Config->VersionScriptGlobals;
void VersionScriptParser::run() {
StringRef Msg = "anonymous version definition is used in "
"combination with other version definitions";
- if (peek() == "{") {
+ if (skip("{")) {
parseVersion("");
if (!atEOF())
setError(Msg);
}
while (!atEOF() && !Error) {
- if (peek() == "{") {
+ StringRef Version = next();
+ if (Version == "{") {
setError(Msg);
return;
}
- parseVersion(next());
+ expect("{");
+ parseVersion(Version);
}
}