a lld linker script bug

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

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.

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

Hi,

I’ve wrote a test, which is modified from lld/test/elf/linkerscript/sections-with-wildcards.tes.

Index: tools/lld/test/elf/linkerscript/filename-with-wildcards.test
<+>UTF-8

I committed the patch and the test as r245792.
Thank you for your contribution.