[llvm-dev] a lld linker script bug
Rafael Auler via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 21 17:17:09 PDT 2015
Hi,
Thanks for your patch, Huang. It looks good to me. Just one comment:
can you write a testcase, similar to the others used for linker script
testing, with your example? Alternatively, you can modify
lld/test/elf/linkerscript/sections-with-wildcards.test to test your
case. This will make your patch complete and ready for commit, and
will ensure we do not regress on this bug if this code is ever
rewritten.
Best regards,
Rafael Auler
On Fri, Aug 21, 2015 at 8:48 PM, Davide Italiano <davide at freebsd.org> wrote:
> 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