[llvm-dev] a lld linker script bug
zan jyu Wong via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 21 01:41:58 PDT 2015
Hi,
I've found a crash in lld when using linker script with wildcard matching.
An example linker script:
INPUT(os/main.o os/foo.o os/startup.o)
OUTPUT(k.bin)
SECTIONS
{
. = 0x0
.text : { *startup.o (.text) }
.text.2 : { *(.tex*) }
}
I've wrote up a patch to fix this crash.
Index: tools/lld/lib/ReaderWriter/LinkerScript.cpp
<+>UTF-8
===================================================================
--- tools/lld/lib/ReaderWriter/LinkerScript.cpp (revision
8570c61c3fce7de2f655a20f8b184efa1bd97c00)
+++ tools/lld/lib/ReaderWriter/LinkerScript.cpp (revision )
@@ -2557,7 +2557,7 @@
switch (*j) {
case '*':
while (!wildcardMatch(pattern.drop_front(j - pattern.begin() + 1),
- name.drop_front(i - name.begin() + 1))) {
+ name.drop_front(i - name.begin()))) {
if (i == name.end())
return false;
++i;
@@ -2565,6 +2565,7 @@
break;
case '?':
// Matches any character
+ ++i;
break;
case '[': {
// Matches a range of characters specified between brackets
@@ -2577,20 +2578,22 @@
return false;
j = pattern.begin() + end;
+ ++i;
break;
}
case '\\':
++j;
if (*j != *i)
return false;
+ ++i;
break;
default:
// No wildcard character means we must match exactly the same char
if (*j != *i)
return false;
+ ++i;
break;
}
- ++i;
}
// If our pattern has't consumed the entire string, it is not a match
Cheers,
Huang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150821/d858d000/attachment.html>
More information about the llvm-dev
mailing list