diff options
author | Sam Clegg <sbc@chromium.org> | 2023-04-04 10:24:40 -0700 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2023-04-04 11:55:01 -0700 |
commit | d9d840cdaf51a9795930750d1b91d614a3849137 (patch) | |
tree | bc2c707a6cc365157952f350cefea96ac5c7d3bb /lld/wasm | |
parent | 2f268b74fdcda025e176f7f47676cdd1507f9709 (diff) | |
download | llvm-d9d840cdaf51a9795930750d1b91d614a3849137.tar.gz |
[lld][WebAssembly] Fix stub library parsing with windows line endings
Also, fix checking of first line in ::parse. We can't use the
::getLines helper here since that already does comment stripping
internally.
Differential Revision: https://reviews.llvm.org/D147548
Diffstat (limited to 'lld/wasm')
-rw-r--r-- | lld/wasm/Driver.cpp | 2 | ||||
-rw-r--r-- | lld/wasm/InputFiles.cpp | 18 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index 7ce221e1f663..3867b9cb3c37 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -280,7 +280,7 @@ void LinkerDriver::addFile(StringRef path) { files.push_back(createObjectFile(mbref)); break; case file_magic::unknown: - if (mbref.getBuffer().starts_with("#STUB\n")) { + if (mbref.getBuffer().starts_with("#STUB")) { files.push_back(make<StubFile>(mbref)); break; } diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp index 2d9768c768f2..fef560457217 100644 --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -691,12 +691,16 @@ StringRef strip(StringRef s) { } void StubFile::parse() { - bool first = false; + bool first = true; + + SmallVector<StringRef> lines; + mb.getBuffer().split(lines, '\n'); + for (StringRef line : lines) { + line = line.trim(); - for (StringRef line : args::getLines(mb)) { // File must begin with #STUB if (first) { - assert(line == "#STUB\n"); + assert(line == "#STUB"); first = false; } @@ -713,10 +717,10 @@ void StubFile::parse() { symbolDependencies[sym] = {}; while (rest.size()) { - StringRef first; - std::tie(first, rest) = rest.split(','); - first = strip(first); - symbolDependencies[sym].push_back(first); + StringRef dep; + std::tie(dep, rest) = rest.split(','); + dep = strip(dep); + symbolDependencies[sym].push_back(dep); } } } |