https://bugs.llvm.org/show_bug.cgi?id=34546

            Bug ID: 34546
           Summary: LLD crashed with special sections in linker script
           Product: lld
           Version: unspecified
          Hardware: Other
                OS: other
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedb...@nondot.org
          Reporter: eblot...@gmail.com
                CC: llvm-bugs@lists.llvm.org

Created attachment 19131
  --> https://bugs.llvm.org/attachment.cgi?id=19131&action=edit
XZ-tarball to reproduce the issue

I bumped into two potential new issues with LLD 5.0 with variations in linker
scripts.

See attached sample tar archive to reproduce both the issues.
They seems to be similar, hence the single ticker. Let me know if I'm wrong,
or if you want be to create one ticker for each issue.

Host: macOS 10.12.6
Target: Cortex M4 (w/ FPU)
LLD: v5.0.0 final, with patches from 33714 and 34407 applied.

See target.ld in the attached tarball to uncomment the sections that cause
LLD to crash

Use build.sh to build the sample C file and trigger the LLD issue.
By default, both section declarations are disabled, so LDD should run fine.


First issue: .foo2 section with no input content

$ ./build.sh
0  ld.lld                   0x000000010bd1c428
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  ld.lld                   0x000000010bd1ca36 SignalHandler(int) + 342
2  libsystem_platform.dylib 0x00007fffb24b2b3a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000000000001 _sigtramp + 1303696609
4  ld.lld                   0x000000010be71468 (anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
>::finalizeSections() + 11944
5  ld.lld                   0x000000010be60c39 (anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
>::run() + 7561
6  ld.lld                   0x000000010be5ee21 void
lld::elf::writeResult<llvm::object::ELFType<(llvm::support::endianness)1,
false> >() + 161
7  ld.lld                   0x000000010bd7d090 void
lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1,
false> >(llvm::opt::InputArgList&) + 3344
8  ld.lld                   0x000000010bd77c9e
lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>, bool) + 3374
9  ld.lld                   0x000000010bd7683a
lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&) + 490
10 ld.lld                   0x000000010bca3431 main + 673
11 libdyld.dylib            0x00007fffb22a3235 start + 1
12 libdyld.dylib            0x000000000000000d start + 1305857497
Stack dump:
0. Program arguments: /usr/local/clang50/bin/ld.lld --Map output.map
--gc-sections --no-whole-archive main.o startup.o -Bstatic
-L/usr/local/clang50/lib/clang/5.0.0/lib/baremetal -T target.ld -o
lld-output.elf
clang-5.0: error: unable to execute command: Segmentation fault: 11
clang-5.0: error: ld.lld command failed due to signal (use -v to see
invocation)

Something unexpected is that moving the same declaration right above the
previous section does not trigger the issue (see .foo1)


Second issue: empty DISCARD section

$ ./build.sh
0  ld.lld                   0x000000010299d428
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  ld.lld                   0x000000010299da36 SignalHandler(int) + 342
2  libsystem_platform.dylib 0x00007fffb24b2b3a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000111d29da8 _sigtramp + 1602712200
4  ld.lld                   0x0000000102a4f879
lld::elf::LinkerScript::adjustSectionsAfterSorting() + 73
5  ld.lld                   0x0000000102af0e58 (anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
>::finalizeSections() + 6296
6  ld.lld                   0x0000000102ae1c39 (anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, false>
>::run() + 7561
7  ld.lld                   0x0000000102adfe21 void
lld::elf::writeResult<llvm::object::ELFType<(llvm::support::endianness)1,
false> >() + 161
8  ld.lld                   0x00000001029fe090 void
lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1,
false> >(llvm::opt::InputArgList&) + 3344
9  ld.lld                   0x00000001029f8c9e
lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>, bool) + 3374
10 ld.lld                   0x00000001029f783a
lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&) + 490
11 ld.lld                   0x0000000102924431 main + 673
12 libdyld.dylib            0x00007fffb22a3235 start + 1
13 libdyld.dylib            0x000000000000000d start + 1305857497
Stack dump:
0. Program arguments: /usr/local/clang50/bin/ld.lld --Map output.map
--gc-sections --no-whole-archive main.o startup.o -Bstatic
-L/usr/local/clang50/lib/clang/5.0.0/lib/baremetal -T target.ld -o
lld-output.elf
clang-5.0: error: unable to execute command: Segmentation fault: 11
clang-5.0: error: ld.lld command failed due to signal (use -v to see
invocation)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to