<html>
    <head>
      <base href="https://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 - crash with --emit-relocs and --strip-debug when debug sections present"
   href="https://bugs.llvm.org/show_bug.cgi?id=44878">44878</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>crash with --emit-relocs and --strip-debug when debug sections present
          </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>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>keescook@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Combining --emit-relocs with --strip-debug on an object with debug sections
will crash during orphan placement:

$ echo "a;" > test.c
$ clang -g -c -o test.o test.c
...
$ objdump -wh test.o

test.o:     file format elf64-x86-64

Sections:
Idx Name            Size      VMA               LMA               File off 
Algn  Flags
  0 .text           00000000  0000000000000000  0000000000000000  00000040 
2**2  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .debug_str      00000091  0000000000000000  0000000000000000  00000040 
2**0  CONTENTS, READONLY, DEBUGGING
  2 .debug_abbrev   0000002c  0000000000000000  0000000000000000  000000d1 
2**0  CONTENTS, READONLY, DEBUGGING
  3 .debug_info     0000003b  0000000000000000  0000000000000000  000000fd 
2**0  CONTENTS, RELOC, READONLY, DEBUGGING
  4 .<a href="show_bug.cgi?id=44878#c0000006">comment        0000006</a>a  0000000000000000  0000000000000000  00000138 
2**0  CONTENTS, READONLY
  5 .note.GNU-stack 00000000  0000000000000000  0000000000000000  000001a2 
2**0  CONTENTS, READONLY
  6 .debug_line     0000002e  0000000000000000  0000000000000000  000001a2 
2**0  CONTENTS, READONLY, DEBUGGING
  7 .llvm_addrsig   00000000  0000000000000000  0000000000000000  00000320 
2**0  CONTENTS, READONLY, EXCLUDE

$ ld.lld --emit-relocs --strip-debug -o /dev/null test.o
Stack dump:
0.      Program arguments: ld.lld --emit-relocs --strip-debug -o /dev/null
test.o 
 #0 0x000055a6d904b68e llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/kees/src/llvm-build/x86/bin/lld+0x51168e)
 #1 0x000055a6d9049514 llvm::sys::RunSignalHandlers()
(/home/kees/src/llvm-build/x86/bin/lld+0x50f514)
 #2 0x000055a6d9049658 SignalHandler(int)
(/home/kees/src/llvm-build/x86/bin/lld+0x50f658)
 #3 0x00007fe35d416540 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x15540)
 #4 0x000055a6d9028122 llvm::Twine::printOneChild(llvm::raw_ostream&,
llvm::Twine::Child, llvm::Twine::NodeKind) const
(/home/kees/src/llvm-build/x86/bin/lld+0x4ee122)
 #5 0x000055a6d90282a1 llvm::Twine::toVector(llvm::SmallVectorImpl<char>&)
const (/home/kees/src/llvm-build/x86/bin/lld+0x4ee2a1)
 #6 0x000055a6d902834b llvm::Twine::str[abi:cxx11]() const
(/home/kees/src/llvm-build/x86/bin/lld+0x4ee34b)
 #7 0x000055a6d9261a9f
lld::elf::getOutputSectionName(lld::elf::InputSectionBase const*)
(/home/kees/src/llvm-build/x86/bin/lld+0x727a9f)
 #8 0x000055a6d91a8a5e
lld::elf::LinkerScript::addOrphanSections()::'lambda'(lld::elf::InputSectionBase*)::operator()(lld::elf::InputSectionBase*)
const (/home/kees/src/llvm-build/x86/bin/lld+0x66ea5e)
 #9 0x000055a6d91a6177 lld::elf::LinkerScript::addOrphanSections()
(/home/kees/src/llvm-build/x86/bin/lld+0x66c177)
#10 0x000055a6d912ce0e void
lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1,
true> >(llvm::opt::InputArgList&)
(/home/kees/src/llvm-build/x86/bin/lld+0x5f2e0e)
#11 0x000055a6d8f7c833 lld::elf::LinkerDriver::main(llvm::ArrayRef<char
const*>) (/home/kees/src/llvm-build/x86/bin/lld+0x442833)
#12 0x000055a6d9130dfb lld::elf::link(llvm::ArrayRef<char const*>, bool,
llvm::raw_ostream&, llvm::raw_ostream&)
(/home/kees/src/llvm-build/x86/bin/lld+0x5f6dfb)
#13 0x000055a6d8f79ede main (/home/kees/src/llvm-build/x86/bin/lld+0x43fede)
#14 0x00007fe35ce921e3 __libc_start_main
/build/glibc-4WA41p/glibc-2.30/csu/../csu/libc-start.c:342:3
#15 0x000055a6d900aa4e _start (/home/kees/src/llvm-build/x86/bin/lld+0x4d0a4e)
Segmentation fault (core dumped)</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>