[llvm-bugs] [Bug 42038] New: ld.lld crashes while linking baremetal RISC-V binary

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 27 12:59:35 PDT 2019


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

            Bug ID: 42038
           Summary: ld.lld crashes while linking baremetal RISC-V binary
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: aykevanlaethem at gmail.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

Created attachment 22024
  --> https://bugs.llvm.org/attachment.cgi?id=22024&action=edit
The 3 files to reproduce

ld.lld crashes while trying to link some RISC-V firmware.

The full backtrace is here:
https://gist.github.com/aykevl/b4220bcd8637106f2a53146b6557bfbd (with LLVM
compiled using RelWithDebInfo)

Here is the part that looks the most interesting to me:

 #4 0x0000000000bfe2b5 getRISCVPCRelHi20(lld::elf::Symbol const*, unsigned
long)::$_1::operator()(lld::elf::Relocation const&, lld::elf::Relocation
const&) const
/home/ayke/src/github.com/tinygo-org/tinygo/llvm/tools/lld/ELF/InputSection.cpp:572:37
 #5 0x0000000000bfe2b5 bool
__gnu_cxx::__ops::_Iter_comp_val<getRISCVPCRelHi20(lld::elf::Symbol const*,
unsigned
long)::$_1>::operator()<__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
lld::elf::Relocation const>(__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
lld::elf::Relocation const&)
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/predefined_ops.h:147:0
 #6 0x0000000000bfe2b5
std::pair<__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > > >
std::__equal_range<__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
lld::elf::Relocation,
__gnu_cxx::__ops::_Iter_comp_val<getRISCVPCRelHi20(lld::elf::Symbol const*,
unsigned long)::$_1>,
__gnu_cxx::__ops::_Val_comp_iter<getRISCVPCRelHi20(lld::elf::Symbol const*,
unsigned long)::$_1> >(__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
lld::elf::Relocation const&,
__gnu_cxx::__ops::_Iter_comp_val<getRISCVPCRelHi20(lld::elf::Symbol const*,
unsigned long)::$_1>,
__gnu_cxx::__ops::_Val_comp_iter<getRISCVPCRelHi20(lld::elf::Symbol const*,
unsigned long)::$_1>)
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_algo.h:2135:0
 #7 0x0000000000bfe2b5
std::pair<__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > > >
std::equal_range<__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
lld::elf::Relocation, getRISCVPCRelHi20(lld::elf::Symbol const*, unsigned
long)::$_1>(__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
__gnu_cxx::__normal_iterator<lld::elf::Relocation*,
std::vector<lld::elf::Relocation, std::allocator<lld::elf::Relocation> > >,
lld::elf::Relocation const&, getRISCVPCRelHi20(lld::elf::Symbol const*,
unsigned long)::$_1)
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_algo.h:2225:0
 #8 0x0000000000bfe2b5 getRISCVPCRelHi20(lld::elf::Symbol const*, unsigned
long)
/home/ayke/src/github.com/tinygo-org/tinygo/llvm/tools/lld/ELF/InputSection.cpp:570:0
 #9 0x0000000000bfe2b5 getRelocTargetVA(lld::elf::InputFile const*, unsigned
int, long, unsigned long, lld::elf::Symbol const&, lld::elf::RelExpr)
/home/ayke/src/github.com/tinygo-org/tinygo/llvm/tools/lld/ELF/InputSection.cpp:691:0
#10 0x0000000000bfd848 lld::elf::InputSectionBase::relocateAlloc(unsigned
char*, unsigned char*)
/home/ayke/src/github.com/tinygo-org/tinygo/llvm/tools/lld/ELF/InputSection.cpp:888:9
#11 0x0000000000c2f2bf void
lld::elf::OutputSection::writeTo<llvm::object::ELFType<(llvm::support::endianness)1,
false> >(unsigned char*)::'lambda'(unsigned long)::operator()(unsigned long)
const
/home/ayke/src/github.com/tinygo-org/tinygo/llvm/tools/lld/ELF/OutputSections.cpp:243:9


LLVM (including Clang and LLD) was compiled with the following configuration:

cmake -G Ninja ../llvm "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;WebAssembly"
"-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR;RISCV"
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_ASSERTIONS=OFF
-DLIBCLANG_BUILD_STATIC=ON -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ZLIB=OFF

I have attached the files I tried to link, so it should be possible to
reproduce.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190527/abcac179/attachment.html>


More information about the llvm-bugs mailing list