-
Notifications
You must be signed in to change notification settings - Fork 46
Fix parsing of "archive:mem" input section description pattern
#681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
11b25c9 to
90f1426
Compare
90f1426 to
19a4ea3
Compare
19a4ea3 to
a4f5fed
Compare
3756a39 to
f784281
Compare
quic-seaswara
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git a/lib/Script/ScriptFile.cpp b/lib/Script/ScriptFile.cpp
index 8c048bb9..00feb8f9 100644
--- a/lib/Script/ScriptFile.cpp
+++ b/lib/Script/ScriptFile.cpp
@@ -538,13 +538,28 @@ StrToken *ScriptFile::createParserStr(const char *PText, size_t PLength) {
StrToken *ScriptFile::createParserStr(llvm::StringRef S) {
bool IsQuoted = false;
+ bool IsLeftQuoted = false;
+ bool IsRightQuoted = false;
if (S.starts_with("\"")) {
- S = S.substr(1, S.size() - 2);
- IsQuoted = true;
+ if (S.ends_with("\"")) {
+ S = S.substr(1, S.size() - 2);
+ IsQuoted = true;
+ }
+ else {
+ S = S.substr(1, S.size() - 1);
+ IsLeftQuoted = true;
+ }
+ } else if (S.ends_with("\"")) {
+ S = S.substr(0, S.size() - 1);
+ IsRightQuoted = true;
}
StrToken *Tok = make<eld::StrToken>(S.str());
if (IsQuoted)
Tok->setQuoted();
+ if (IsLeftQuoted)
+ Tok->setLeftQuote();
+ if (IsRightQuoted)
+ Tok->setRightQuote();
return Tok;
}
diff --git a/lib/ScriptParser/ScriptParser.cpp b/lib/ScriptParser/ScriptParser.cpp
index 4e0b2047..126a8405 100644
--- a/lib/ScriptParser/ScriptParser.cpp
+++ b/lib/ScriptParser/ScriptParser.cpp
@@ -661,18 +661,11 @@ InputSectDesc::Spec ScriptParser::readInputSectionDescSpec(StringRef Tok) {
if (!Tok.contains(':'))
FilePat = createAndRegisterWildcardPattern(Tok);
else {
- bool isQuoted = Tok.starts_with("\"");
- Tok = unquote(Tok);
std::pair<llvm::StringRef, llvm::StringRef> Split = Tok.split(':');
FilePat = createAndRegisterWildcardPattern(Split.first);
if (!Split.second.empty()) {
ArchiveMem = createAndRegisterWildcardPattern(Split.second);
}
- if (isQuoted) {
- FilePat->setLeftQuote();
- if (ArchiveMem)
- ArchiveMem->setRightQuote();
- }
llvm::StringRef peekTok = peek();
if (!atEOF() && peekTok != "(" &&
computeLineNumber(peekTok) == getCurrentLineNumber()) {
I was approaching the problem in the way above.
The core issue is in createParserStr.
Can you please look into it ?
f784281 to
a43d294
Compare
This commit fixes the parsing / interpretation of `"archive:mem"` file pattern. Previously, it was getting incorrectly stored because we were not properly handling quotes when a single quoted token in the linker script (`"archive:member"`) is stored as two separate patterns in the linker implementation. Resolves qualcomm#680 Signed-off-by: Parth Arora <partaror@qti.qualcomm.com>
a4a731b to
619e653
Compare
I have updated the code to the solution suggested by you. |
This commit fixes the parsing / interpretation of
"archive:mem"file pattern. Previously, it was getting incorrectly stored because we were not properly handling quotes when a single quoted token in the linker script ("archive:member") is stored as two separate patterns in the linker implementation.Resolves #680