[llvm-dev] a lld linker script bug
Davide Italiano via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 21 16:48:16 PDT 2015
On Fri, Aug 21, 2015 at 4:41 AM, zan jyu Wong via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> 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.
>
The patch looks good to me.
CC:ing Rafael and Michael as they wrote large part of the linker script support.
> 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
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
--
Davide
"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
More information about the llvm-dev
mailing list