<html>
    <head>
      <base href="http://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Segfaults when using --gc-sections with linker script"
   href="http://bugs.llvm.org/show_bug.cgi?id=32024">32024</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfaults when using --gc-sections with linker script
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>phosek@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Bisecting revealed this was introduced in r295485, the test input to reproduce
this issue is:

# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: echo "ENTRY(foo) \
# RUN: SECTIONS { \
# RUN:  . = 0x1000; \
# RUN:  .text : { *(.text*) }\
# RUN: }" > %t.script
# RUN: ld.lld %t --gc-sections --script %t.script -o %t1
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s

# CHECK:      Sections:
# CHECK-NEXT: Idx Name          Size      Address          Type
# CHECK-NEXT:   0               00000000 0000000000000000
# CHECK-NEXT:   1 .text         00000002 0000000000000000

.section .text.bar
.global bar
bar:
  nop

.section .text.foo
.global foo
foo:
  nop


The stack trace is as follows:

#0 0x00000000004da869 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../lib/Support/Unix/Signals.inc:402:11
#1 0x00000000004daa19 PrintStackTraceSignalHandler(void*)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../lib/Support/Unix/Signals.inc:466:1
#2 0x00000000004d90e3 llvm::sys::RunSignalHandlers()
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../lib/Support/Signals.cpp:0:5
#3 0x00000000004dad74 SignalHandler(int)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../lib/Support/Unix/Signals.inc:256:1
#4 0x00002b33c4c6b330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#5 0x000000000071a7ae
lld::elf::LinkerScript<llvm::object::ELFType<(llvm::support::endianness)1,
true> >::switchTo(lld::elf::OutputSectionBase*)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/ELF/LinkerScript.cpp:458:33
#6 0x000000000071aa10
lld::elf::LinkerScript<llvm::object::ELFType<(llvm::support::endianness)1,
true> >::process(lld::elf::BaseCommand&)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/ELF/LinkerScript.cpp:503:48
#7 0x000000000071a2a6
lld::elf::LinkerScript<llvm::object::ELFType<(llvm::support::endianness)1,
true> >::assignOffsets(lld::elf::OutputSectionCommand*)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/ELF/LinkerScript.cpp:0:5
#8 0x000000000071ae00
lld::elf::LinkerScript<llvm::object::ELFType<(llvm::support::endianness)1,
true> >::assignAddresses(std::vector<lld::elf::PhdrEntry,
std::allocator<lld::elf::PhdrEntry> >&)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/ELF/LinkerScript.cpp:0:5
#9 0x000000000085d9bd (anonymous
namespace)::Writer<llvm::object::ELFType<(llvm::support::endianness)1, true>
<span class="quote">>::run()</span >
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/ELF/Writer.cpp:250:5
#10 0x00000000008869f2 void
lld::elf::writeResult<llvm::object::ELFType<(llvm::support::endianness)1, true>
<span class="quote">>()</span >
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/ELF/Writer.cpp:140:64
#11 0x00000000006337fa void
lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1,
true> >(llvm::opt::InputArgList&)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/ELF/Driver.cpp:873:1
#12 0x0000000000624ae4 lld::elf::LinkerDriver::main(llvm::ArrayRef<char
const*>, bool)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/ELF/Driver.cpp:340:5
#13 0x0000000000624266 lld::elf::link(llvm::ArrayRef<char const*>, bool,
llvm::raw_ostream&)
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/ELF/Driver.cpp:79:3
#14 0x00000000004b666e main
/usr/local/google/home/phosek/clang-llvm/llvm/out/lld/../../tools/lld/tools/lld/lld.cpp:104:12
#15 0x00002b33c5f08f45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#16 0x00000000004b6419 _start (../bin/ld.lld+0x4b6419)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>